From a697ef0e8834e2f5a9da1e5b5b9390c717a03825 Mon Sep 17 00:00:00 2001 From: Julian Arndt Date: Sun, 28 Jul 2024 22:16:22 +0200 Subject: [PATCH] Fix bug --- src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java | 3 ++- .../java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java index 4693919..34ca5e7 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java @@ -16,7 +16,7 @@ public class TLWMatchesManagerBase { protected int season; protected int league; protected int numberOfMatchdays; - protected int matchesPerMatchday; + protected Integer matchesPerMatchday = null; protected int ko; protected int betKOType; @@ -27,6 +27,7 @@ public class TLWMatchesManagerBase { TippligaConfigProvider prov = new TippligaConfigProvider(this.season); JSONObject config = prov.getTippligaConfig(configFileName); this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue(); + try { this.matchesPerMatchday = ((Long) config.get("matchesPerMatchday")).intValue(); } catch (Exception ignored) {} this.matchdayConfig = (JSONArray) config.get("matchdayConfig"); this.ko = ((Long) config.get("ko")).intValue(); Long parsedBetKOType = (Long) config.get("betKOType"); diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java index 20be530..f244ea7 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java @@ -196,6 +196,8 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { private void addPlaceholderMatches(ArrayList tlwMatches, JSONObject matchdayConfig) { + Integer numberOfMatches = this.matchesPerMatchday; + try { numberOfMatches = ((Long) matchdayConfig.get("numberOfMatches")).intValue();} catch (Exception ignored) {} ArrayList placeholderMatches = new ArrayList<>(); ArrayList tlwMatchesCopy = new ArrayList<>(tlwMatches); JSONArray matchesConfig = (JSONArray) matchdayConfig.get("matchesConfig"); @@ -224,7 +226,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { } } // check if total number of matches is not too high - if(tlwMatches.size() + placeholderMatches.size() > (Integer.parseInt(matchdayConfig.get("numberOfMatches").toString()))) { + if(tlwMatches.size() + placeholderMatches.size() > (numberOfMatches)) { logger.error("Too many matches in config: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday()); } else { // add placeholderMatches to tlwMatches