From 4e905cf8fb09d147fe006f9ba2f364ae6fca6eb9 Mon Sep 17 00:00:00 2001 From: test Date: Thu, 5 Sep 2024 01:45:32 +1000 Subject: [PATCH] Update NationDB.java --- src/main/java/link/locutus/discord/db/NationDB.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/link/locutus/discord/db/NationDB.java b/src/main/java/link/locutus/discord/db/NationDB.java index 4a63ed91..ad63f295 100644 --- a/src/main/java/link/locutus/discord/db/NationDB.java +++ b/src/main/java/link/locutus/discord/db/NationDB.java @@ -767,15 +767,16 @@ public Set updateUnknownPositions(Consumer eventConsumer) { public void updateTreaties(Consumer eventConsumer) { PoliticsAndWarV3 v3 = Locutus.imp().getV3(); - List treatiesV3 = v3.readSnapshot(PagePriority.API_TREATIES, com.politicsandwar.graphql.model.Treaty.class); - if (treatiesV3.isEmpty()) throw new IllegalStateException("No treaties returned from API! (updateTreaties())"); - treatiesV3 = new ObjectArrayList<>(treatiesV3); - treatiesV3.removeIf(f -> f.getTurns_left() <= 0); +// List treatiesV3 = v3.readSnapshot(PagePriority.API_TREATIES, com.politicsandwar.graphql.model.Treaty.class); +// if (treatiesV3.isEmpty()) throw new IllegalStateException("No treaties returned from API! (updateTreaties())"); +// treatiesV3 = new ObjectArrayList<>(treatiesV3); +// treatiesV3.removeIf(f -> f.getTurns_left() <= 0); + // The snapshots seem to return incorrect results, missing existing treaties and including ones that are gone? + List treatiesV3 = v3.fetchTreaties(r -> {}); // Don't call events if first time if (treatiesByAlliance.isEmpty()) eventConsumer = f -> {}; - updateTreaties(treatiesV3, eventConsumer, true); }