diff --git a/src/main/java/core/file/hrf/HRFStringBuilder.java b/src/main/java/core/file/hrf/HRFStringBuilder.java index 211fee84d..e0a834857 100644 --- a/src/main/java/core/file/hrf/HRFStringBuilder.java +++ b/src/main/java/core/file/hrf/HRFStringBuilder.java @@ -203,7 +203,7 @@ public void createEconomy(Map economyDataMap) { private static String getPlayerIdByPositionValue(MatchLineupTeam team, int position){ var matchLineupPosition = team.getPlayerByPosition(position); if ( matchLineupPosition != null){ - return ""+matchLineupPosition.getPlayerId(); + return String.valueOf(matchLineupPosition.getPlayerId()); } return "0"; } @@ -211,7 +211,7 @@ private static String getPlayerIdByPositionValue(MatchLineupTeam team, int posit private static String getBehaviourByPositionValue(MatchLineupTeam team, int position){ var matchLineupPosition = team.getPlayerByPosition(position); if ( matchLineupPosition != null){ - return ""+ matchLineupPosition.getBehaviour(); + return String.valueOf(matchLineupPosition.getBehaviour()); } return "0"; } @@ -314,7 +314,7 @@ public void createLeague(Map ligaDataMap) { public void createLineUp(String trainerId, int teamId, Map nextLineup) { lineupStringBuilder = new StringBuilder("[lineup]\n"); if (nextLineup != null) { - var matchId = NumberUtils.toInt(nextLineup.get("MatchId"),0); + var matchId = NumberUtils.toInt(nextLineup.get("MatchID"),0); var matchtype = NumberUtils.toInt(nextLineup.get("MatchType"), MatchType.NONE.getMatchTypeId()); try { @@ -542,9 +542,7 @@ public void appendYouthPlayers(List playersData) { appendHRFLine(youthPlayersStringBuilder, player, "ScoutName"); appendHRFLine(youthPlayersStringBuilder, player, "ScoutingRegionID"); - for (int i = 0; appendScoutComment(youthPlayersStringBuilder, player, i); i++) { - ; - } + for (int i = 0; appendScoutComment(youthPlayersStringBuilder, player, i); i++) {} appendHRFLine(youthPlayersStringBuilder, player, "YouthMatchID"); appendHRFLine(youthPlayersStringBuilder, player, "YouthMatchDate"); diff --git a/src/main/java/core/gui/DebugMode.java b/src/main/java/core/gui/DebugMode.java index 346ce8a2c..f097e1c07 100644 --- a/src/main/java/core/gui/DebugMode.java +++ b/src/main/java/core/gui/DebugMode.java @@ -1,14 +1,8 @@ package core.gui; import core.db.frontend.SQLDialog; -//import core.gui.language.LanguageEditorDialog; import core.net.MyConnector; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - import javax.swing.JCheckBoxMenuItem; import javax.swing.JMenu; import javax.swing.JMenuItem; @@ -20,81 +14,24 @@ public static JMenu getDeveloperMenu() { menu.add(getSQLDialogMenuItem()); menu.add(getLookAndFeelDialogMenuItem()); menu.add(getSaveXMLMenuItem()); -// menu.add(getPlayerHistoryMenuItem()); -// menu.add(getMatchStatisticsMenuItem()); - //menu.add(getLanguageMenuItem()); return menu; } - -// private static JMenuItem getLanguageMenuItem() { -// JMenuItem newItem = new JMenuItem("Language File Editor"); -// newItem.addActionListener(new ActionListener() { -// -// @Override -// public void actionPerformed(ActionEvent e) { -// new LanguageEditorDialog().setVisible(true); -// } -// }); -// return newItem; -// } private static JMenuItem getLookAndFeelDialogMenuItem() { JMenuItem newItem = new JMenuItem("Look and Feel"); - newItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - new LookAndFeelDialog().setVisible(true); - } - }); + newItem.addActionListener(e -> new LookAndFeelDialog().setVisible(true)); return newItem; } private static JMenuItem getSQLDialogMenuItem() { JMenuItem newItem = new JMenuItem("SQL Editor"); - newItem.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - new SQLDialog().setVisible(true); - } - }); + newItem.addActionListener(e -> new SQLDialog().setVisible(true)); return newItem; } private static JMenuItem getSaveXMLMenuItem() { JMenuItem newItem = new JCheckBoxMenuItem("Save downloaded XML"); - newItem.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { - MyConnector.setDebugSave(e.getStateChange() == ItemEvent.SELECTED); - } - }); + newItem.addItemListener(e -> MyConnector.setDebugSave(e.getStateChange() == ItemEvent.SELECTED)); return newItem; } - -// private static JMenuItem getPlayerHistoryMenuItem() { -// JMenuItem newItem = new JMenuItem("Player History"); -// newItem.addActionListener(new ActionListener() { -// @Override -// public void actionPerformed(ActionEvent arg0) { -// new core.training.SkillDropTestFrame().setVisible(true); -// } -// }); -// return newItem; -// } -// -// private static JMenuItem getMatchStatisticsMenuItem() { -// JMenuItem newItem = new JMenuItem("Match Minutes"); -// newItem.addActionListener(new ActionListener() { -// @Override -// public void actionPerformed(ActionEvent arg0) { -// new core.model.match.StatisticsTestFrame().setVisible(true); -// } -// }); -// return newItem; -// } - - -} +} \ No newline at end of file diff --git a/src/main/java/core/net/MyConnector.java b/src/main/java/core/net/MyConnector.java index c09345c6d..12c3d5aa1 100644 --- a/src/main/java/core/net/MyConnector.java +++ b/src/main/java/core/net/MyConnector.java @@ -23,7 +23,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.net.URLConnection; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; @@ -90,18 +89,6 @@ public static MyConnector instance() { return m_clInstance; } - public static boolean hasInternetAccess(){ - try { - URL url = new URL("http://www.hattrick.org"); - URLConnection connection = url.openConnection(); - connection.connect(); - return true; - } - catch (IOException e) { - return false; - } - } - /** * Sets the DEBUGSAVE flag. Setting the flag to true will save downloaded * CHPP files. @@ -113,15 +100,6 @@ public static void setDebugSave(boolean debugSave) { DEBUGSAVE = debugSave; } - public static String getHOSite() { - return "http://ho1.sourceforge.net/"; - } - - public static String getPluginSite() { - return getHOSite() + "onlinefiles"; - } - - /** * Fetch a specific arena * diff --git a/src/main/java/core/training/TrainingPreviewPlayers.java b/src/main/java/core/training/TrainingPreviewPlayers.java index e6d96ee93..b6a2fb8c7 100644 --- a/src/main/java/core/training/TrainingPreviewPlayers.java +++ b/src/main/java/core/training/TrainingPreviewPlayers.java @@ -27,7 +27,7 @@ public class TrainingPreviewPlayers implements Refreshable { private final HashMap players = new HashMap<>(); private int nextWeekTraining = -1; - private boolean isFuturMatchInit =false; + private boolean isFutureMatchInit =false; private WeeklyTrainingType weekTrainTyp = null; private List lMatchStats = null; private List lineups = null; @@ -83,15 +83,14 @@ public void reInit() { * refresh object */ public void refresh() { - if (players != null) - players.clear(); + players.clear(); if (lMatchStats != null) lMatchStats.clear(); if (lineups != null) lineups.clear(); nextWeekTraining = -1; weekTrainTyp = null; - isFuturMatchInit = false; + isFutureMatchInit = false; } /** @@ -195,12 +194,12 @@ private void calculateWeeklyTrainingForPlayer(Player player) { */ private List getMatchesForTraining() { - if (!isFuturMatchInit) { + if (!isFutureMatchInit) { var lastTraining = TrainingManager.instance().getNextWeekTraining(); this.lMatchStats = new ArrayList<>(); this.lineups = new ArrayList<>(); - this.isFuturMatchInit = true; + this.isFutureMatchInit = true; if (lastTraining != null) { weekTrainTyp = WeeklyTrainingType.instance(lastTraining.getTrainingType()); diff --git a/src/main/java/module/lineup/substitution/LanguageStringLookup.java b/src/main/java/module/lineup/substitution/LanguageStringLookup.java index 56eeb25af..07382428f 100644 --- a/src/main/java/module/lineup/substitution/LanguageStringLookup.java +++ b/src/main/java/module/lineup/substitution/LanguageStringLookup.java @@ -70,6 +70,10 @@ public static String getStanding(GoalDiffCriteria standing) { case IN_THE_LEAD_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalLeadMT2"); case DOWN_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalDownMT2"); case MATCH_IS_NOT_TIED -> HOVerwaltung.instance().getLanguageString("subs.MatchIsNotTied"); + case NOT_IN_THE_LEAD_BY_MORE_THAN_ONE -> HOVerwaltung.instance().getLanguageString("subs.GoalNotLeadMT1"); + case NOT_DOWN_BY_MORE_THAN_ONE -> HOVerwaltung.instance().getLanguageString("subs.GoalNotDownMT1"); + case NOT_IN_THE_LEAD_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalNotLeadMT2"); + case NOT_DOWN_BY_MORE_THAN_TWO -> HOVerwaltung.instance().getLanguageString("subs.GoalNotDownMT2"); default -> ""; }; } diff --git a/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java b/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java index 1735146b3..6d98f1427 100644 --- a/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java +++ b/src/main/java/module/lineup/substitution/SubstitutionDataProvider.java @@ -2,10 +2,8 @@ import core.datatype.CBItem; import core.model.HOVerwaltung; -import core.model.player.IMatchRoleID; -import core.model.player.Player; import module.lineup.Lineup; -import module.lineup.substitution.model.Substitution; +import module.lineup.substitution.model.GoalDiffCriteria; import module.teamAnalyzer.SystemManager; import module.teamAnalyzer.ht.HattrickManager; import module.teamAnalyzer.vo.PlayerInfo; @@ -16,23 +14,17 @@ import java.util.Map; import static core.model.player.IMatchRoleID.aFieldAndSubsMatchRoleID; -import static core.model.player.IMatchRoleID.aFieldMatchRoleID; public class SubstitutionDataProvider { - public static void getSubstitutions() { - List subs = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc() - .getSubstitutionList(); - } - public static Map getFieldAndSubPlayerPosition() { LinkedHashMap positionMap = new LinkedHashMap<>(); Lineup lineup = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc(); for (Integer i : aFieldAndSubsMatchRoleID) { - Player player = lineup.getPlayerByPositionID(i); + var player = lineup.getPlayerByPositionID(i); if (player != null) { - positionMap.put(i, new PlayerPositionItem(Integer.valueOf(i), lineup.getPlayerByPositionID(i))); + positionMap.put(i, new PlayerPositionItem(i, lineup.getPlayerByPositionID(i))); } } return positionMap; @@ -40,26 +32,26 @@ public static Map getFieldAndSubPlayerPosition() { public static List getFieldPositions(List aMatchRoleID , boolean includeEmptyPositions) { - List playerItems = new ArrayList(); + List playerItems = new ArrayList<>(); Lineup lineup = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc(); for (Integer i : aMatchRoleID) { - Player player = lineup.getPlayerByPositionID(i); + var player = lineup.getPlayerByPositionID(i); if (player != null || includeEmptyPositions) { - playerItems.add(new PlayerPositionItem(Integer.valueOf(i), player)); + playerItems.add(new PlayerPositionItem(i, player)); } } return playerItems; } public static List getFieldPositions(int start, int end, boolean includeEmptyPositions) { - List playerItems = new ArrayList(); + List playerItems = new ArrayList<>(); Lineup lineup = HOVerwaltung.instance().getModel().getLineupWithoutRatingRecalc(); for (int i = start; i <= end; i++) { - Player player = lineup.getPlayerByPositionID(i); + var player = lineup.getPlayerByPositionID(i); if (player != null || includeEmptyPositions) { - playerItems.add(new PlayerPositionItem(Integer.valueOf(i), player)); + playerItems.add(new PlayerPositionItem(i, player)); } } return playerItems; @@ -72,19 +64,13 @@ public static List getFieldPositions(int start, int end, boo * @return an array with standing items */ public static CBItem[] getStandingItems() { - CBItem[] standingValues = { - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalAny"), -1), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalTied"), 0), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalLead"), 1), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalDown"), 2), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalLeadMT1"), 3), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalDownMT1"), 4), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalNotDown"), 5), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalNotLead"), 6), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalLeadMT2"), 7), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.GoalDownMT2"), 8), - new CBItem(HOVerwaltung.instance().getLanguageString("subs.MatchIsNotTied"), 9)}; - return standingValues; + var values = GoalDiffCriteria.values(); + CBItem[] ret = new CBItem[values.length]; + int i = 0; + for (var goalDifferenceCriteria : GoalDiffCriteria.values()){ + ret[i++] = new CBItem(LanguageStringLookup.getStanding(goalDifferenceCriteria), goalDifferenceCriteria.getId()); + } + return ret; } /** @@ -94,7 +80,7 @@ public static CBItem[] getStandingItems() { * @return an array with red card items */ public static CBItem[] getRedCardItems() { - CBItem[] redcardValues = { + return new CBItem[]{ new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedIgnore"), -1), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedMy"), 1), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOpp"), 2), @@ -108,14 +94,13 @@ public static CBItem[] getRedCardItems() { new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOppFW"), 23), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOppWB"), 24), new CBItem(HOVerwaltung.instance().getLanguageString("subs.RedOppWi"), 25), }; - return redcardValues; } /** * Returns an {@link CBItem} array with all behaviours which can be chosen * for a substitution. * - * @return an array with behaviour items + * @return a list of behaviour items */ public static List getBehaviourItems(boolean withInheritItem) { List behaviourValues = new ArrayList<>(); diff --git a/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java b/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java index 1fbc2a905..fd40f698b 100644 --- a/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java +++ b/src/main/java/module/lineup/substitution/model/GoalDiffCriteria.java @@ -32,7 +32,15 @@ public enum GoalDiffCriteria { @SerializedName("8") DOWN_BY_MORE_THAN_TWO((byte) 8), @SerializedName("9") - MATCH_IS_NOT_TIED((byte) 9); + MATCH_IS_NOT_TIED((byte) 9), + @SerializedName("10") + NOT_IN_THE_LEAD_BY_MORE_THAN_ONE((byte) 10), + @SerializedName("11") + NOT_DOWN_BY_MORE_THAN_ONE((byte) 11), + @SerializedName("12") + NOT_IN_THE_LEAD_BY_MORE_THAN_TWO((byte) 12), + @SerializedName("13") + NOT_DOWN_BY_MORE_THAN_TWO((byte) 13); private final byte id; diff --git a/src/main/resources/release_notes.md b/src/main/resources/release_notes.md index 25d0a6f8a..9ebb1b67d 100644 --- a/src/main/resources/release_notes.md +++ b/src/main/resources/release_notes.md @@ -21,6 +21,7 @@ bug fixes ### Lineup * fix nt team selection options of style of play combo box (#1873) +* fix download error of substitutions with undocumented goal difference criteria (#1881) ### Statistics * fix currency of secondary teams (#1856) diff --git a/src/main/resources/sprache/English.properties b/src/main/resources/sprache/English.properties index 7455d0744..426fafdc5 100644 --- a/src/main/resources/sprache/English.properties +++ b/src/main/resources/sprache/English.properties @@ -1599,6 +1599,10 @@ subs.GoalNotLead=Not in the lead subs.GoalLeadMT2=In the lead by more than two subs.GoalDownMT2=Down by more than two subs.MatchIsNotTied=Match is not tied +subs.GoalNotLeadMT1=Not in lead by more than one +subs.GoalNotDownMT1=Not down by more than one +subs.GoalNotLeadMT2=Not in lead by more than two +subs.GoalNotDownMT2=Not down by more than two #The red card statuses subs.RedIgnore=Ignore red status