Skip to content

Commit

Permalink
Update NationDB.java
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed Sep 4, 2024
1 parent 8c732d1 commit 4e905cf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/link/locutus/discord/db/NationDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -767,15 +767,16 @@ public Set<Integer> updateUnknownPositions(Consumer<Event> eventConsumer) {

public void updateTreaties(Consumer<Event> eventConsumer) {
PoliticsAndWarV3 v3 = Locutus.imp().getV3();
List<com.politicsandwar.graphql.model.Treaty> 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<com.politicsandwar.graphql.model.Treaty> 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<com.politicsandwar.graphql.model.Treaty> treatiesV3 = v3.fetchTreaties(r -> {});

// Don't call events if first time
if (treatiesByAlliance.isEmpty()) eventConsumer = f -> {};

updateTreaties(treatiesV3, eventConsumer, true);
}

Expand Down

0 comments on commit 4e905cf

Please sign in to comment.