Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed May 19, 2024
1 parent 6adc631 commit dae74df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String info(ConflictManager manager, Conflict conflict, boolean showParti
StringBuilder response = new StringBuilder();

response.append("**__" + conflict.getName() + " - `#" + conflict.getId() + "` - " + conflict.getCategory().name() + "__**\n");
response.append("wiki: `" + conflict.getWiki() + "`\n");
response.append("wiki: `" + (conflict.getWiki().isEmpty() ? "N/A" : conflict.getWiki()) + "`\n");
response.append("Start: " + DiscordUtil.timestamp(TimeUtil.getTimeFromTurn(conflict.getStartTurn()), null) + "\n");
response.append("End: " + (conflict.getEndTurn() == Long.MAX_VALUE ? "Ongoing" : DiscordUtil.timestamp(TimeUtil.getTimeFromTurn(conflict.getEndTurn()), null)) + "\n");
response.append("Casus Belli: `" + (conflict.getCasusBelli().isEmpty() ? "N/A" : conflict.getCasusBelli().isEmpty()) + "`\n");
Expand All @@ -80,8 +80,9 @@ public String info(ConflictManager manager, Conflict conflict, boolean showParti

List<CoalitionSide> sides = Arrays.asList(conflict.getSide(true), conflict.getSide(false));
if (showParticipants) {
int i = 1;
for (CoalitionSide side : sides) {
response.append("\n**" + side.getName() + "** (1)\n");
response.append("\n**" + side.getName() + "** (coalition " + (i++) + ")\n");
for (int aaId : side.getAllianceIdsSorted()) {
long start = conflict.getStartTurn(aaId);
long end = conflict.getEndTurn(aaId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ private AwsManager setupAws() {
if (!key.isEmpty() && !secret.isEmpty() && !region.isEmpty() && !bucket.isEmpty()) {
return new AwsManager(key, secret, bucket, region);
}
Locutus.imp().getCommandManager().getExecutor().scheduleWithFixedDelay(() -> {
try {
if (!conflictsLoaded) return;
pushDirtyConflicts();
} catch (Exception e) {
e.printStackTrace();
}
}, 8, 1, TimeUnit.MINUTES);
return null;
}

Expand Down Expand Up @@ -189,7 +181,10 @@ public boolean pushDirtyConflicts() {
}
if (hasDirty) {
pushIndex();
System.out.println("Pushed dirty conflicts");
return true;
} else {
System.out.println("No dirty conflicts");
}
return false;
}
Expand Down Expand Up @@ -492,7 +487,19 @@ public void loadConflicts() {
// if (legacyNames.isEmpty()) {
// saveDefaultNames();
// }
Locutus.imp().getExecutor().submit(() -> loadConflictWars(null, false));
Locutus.imp().getExecutor().submit(() -> {
loadConflictWars(null, false);
Locutus.imp().getCommandManager().getExecutor().scheduleWithFixedDelay(() -> {
try {
System.out.println("Update task " + (!conflictsLoaded) + " | " + (!TimeUtil.checkTurnChange()));
if (!conflictsLoaded || !TimeUtil.checkTurnChange()) return;
System.out.println("Pushing dirty conflicts");
pushDirtyConflicts();
} catch (Exception e) {
e.printStackTrace();
}
}, 1, 1, TimeUnit.MINUTES);
});
System.out.println("Load graph data: " + ((-start) + (start = System.currentTimeMillis()) + "ms"));
}

Expand Down

0 comments on commit dae74df

Please sign in to comment.