diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index d0e2bbe16..63344473b 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -876,7 +876,7 @@ public IHOTableEntry getTableEntry(Player player, Player playerCompare) { playerAdditionalArray[19] = new PlayerColumn(893, "ls.player.motherclub.name", 50) { @Override public IHOTableEntry getTableEntry(Player player, Player playerCompare) { - return new ColorLabelEntry(player.getMotherclubName(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.LEFT); + return new ColorLabelEntry(player.getOrDownloadMotherclubName(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.LEFT); } }; diff --git a/src/main/java/core/model/player/Player.java b/src/main/java/core/model/player/Player.java index 381ce3892..d1c52714e 100644 --- a/src/main/java/core/model/player/Player.java +++ b/src/main/java/core/model/player/Player.java @@ -418,19 +418,19 @@ public Player(java.util.Properties properties, HODateTime hrfdate, int hrf_id) { String temp = properties.getProperty("trainertype", "-1"); - if ((temp != null) && !temp.equals("")) { + if ((temp != null) && !temp.isEmpty()) { m_iTrainerTyp = TrainerType.fromInt(Integer.parseInt(temp)); } temp = properties.getProperty("trainerskill", "0"); - if ((temp != null) && !temp.equals("")) { + if ((temp != null) && !temp.isEmpty()) { m_iTrainer = Integer.parseInt(temp); } temp = properties.getProperty("playernumber", ""); - if ((temp != null) && !temp.equals("") && !temp.equals("null")) { + if ((temp != null) && !temp.isEmpty() && !temp.equals("null")) { shirtNumber = Integer.parseInt(temp); } @@ -474,17 +474,17 @@ public Player(java.util.Properties properties, HODateTime hrfdate, int hrf_id) { if (oldPlayer != null) { // Training blocked (could be done in the past) m_bTrainingBlock = oldPlayer.hasTrainingBlock(); - motherclubId = oldPlayer.getMotherclubId(); - motherclubName = oldPlayer.getMotherclubName(); + motherclubId = oldPlayer.getOrDownloadMotherclubId(); + motherclubName = oldPlayer.getOrDownloadMotherclubName(); } } - public String getMotherclubName() { + public String getOrDownloadMotherclubName() { downloadMotherclubInfoIfMissing(); return this.motherclubName; } - public Integer getMotherclubId() { + public Integer getOrDownloadMotherclubId() { downloadMotherclubInfoIfMissing(); return this.motherclubId; } @@ -498,6 +498,7 @@ private void downloadMotherclubInfoIfMissing() { // try to download missing mother club info var playerDetails = OnlineWorker.downloadPlayerDetails(String.valueOf(this.getPlayerID())); if (playerDetails != null) { + // do not use download again since this could lead to endless recursion if the playerdetails file has errors motherclubId = playerDetails.getMotherclubId(); motherclubName = playerDetails.getMotherclubName(); } @@ -511,6 +512,14 @@ private void downloadMotherclubInfoIfMissing() { } } + private String getMotherclubName() { + return this.motherclubName; + } + + private Integer getMotherclubId() { + return this.motherclubId; + } + //~ Methods ------------------------------------------------------------------------------------ /** @@ -2226,7 +2235,7 @@ public void setSubExperience( Double experience){ public List getFuturePlayerTrainings(){ if ( futurePlayerTrainings == null){ futurePlayerTrainings = DBManager.instance().getFuturePlayerTrainings(this.getPlayerID()); - if (futurePlayerTrainings.size()>0) { + if (!futurePlayerTrainings.isEmpty()) { var start = HOVerwaltung.instance().getModel().getBasics().getHattrickWeek(); var remove = new ArrayList(); for (var t : futurePlayerTrainings) { @@ -2358,7 +2367,7 @@ public void calcSubskills(int previousID, List trainingWeeks) { var valueBeforeTraining = playerBefore.getValue4Skill(skill); var valueAfterTraining = this.getValue4Skill(skill); - if (trainingWeeks.size() > 0) { + if (!trainingWeeks.isEmpty()) { if ( valueAfterTraining > valueBeforeTraining) { // Check if skill up is available var skillUps = this.getAllLevelUp(skill); @@ -2382,7 +2391,7 @@ public void calcSubskills(int previousID, List trainingWeeks) { sub += trainingPerPlayer.calcSubskillIncrement(skill, valueBeforeTraining + sub, training.getTrainingDate()); if (valueAfterTraining > valueBeforeTraining) { if (sub > 1) { - sub -= 1.; + sub -= 1.F; } else { sub = 0.f; } diff --git a/src/main/resources/release_notes.md b/src/main/resources/release_notes.md index bff70453c..134602a03 100644 --- a/src/main/resources/release_notes.md +++ b/src/main/resources/release_notes.md @@ -11,6 +11,7 @@ bug fixes ### Squad * fix display of wrong homegrown heart in player details (#1901) +* fix recursive download of mother club info. Handle chpp error in playerdetails file (#1913) ### Team Analyzer