fix issues related to raid time

This commit is contained in:
Aubri Seebauer committed 2023-04-18 16:05:03 -04:00
1 parent 011f54d4d6
commit e86af9b3c7
8 files changed
+333 -241

No files matched your search

@@ -227,7 +227,7 @@ public class RaidData {
* @Isaac this is for getting if a town can be raided, return (-2, -1, 0, 1, 2) based on status
* (no players online, 24 hours town cooldown, 6 hour war cooldown, town being raided already, valid time to raid)
*/
public static int isValidRaid(War war, @Nonnull Town town) {
public static int isValidRaid(War war, String side, @Nonnull Town town) {
long townTime = whenTownLastRaided(town);
//24 hours town cooldown
@@ -236,7 +236,7 @@ public class RaidData {
}
//6 hour raid cooldown for war
if ((System.currentTimeMillis() / 1000) - war.getLastRaidTime() <= 21600) {
if ((System.currentTimeMillis() / 1000) - (side.equals(war.getSide1()) ? war.getLastRaidTimeSide1() : war.getLastRaidTimeSide2()) <= 21600) {
return 0;
}
@@ -98,7 +98,11 @@ public class WarData
war.setSide1Towns((ArrayList<String>) fileData.get("side1Towns"));
war.setSide2Towns((ArrayList<String>) fileData.get("side2Towns"));
war.setLastRaidTime((Long) fileData.get("lastRaidTime"));
if(fileData.get("lastRaidTimeSide1") != null && fileData.get("lastRaidTimeSide2") != null) {
war.setLastRaidTimeSide1((long)((int) fileData.get("lastRaidTimeSide1")));
war.setLastRaidTimeSide2((long)((int) fileData.get("lastRaidTimeSide2")));
}
return war;
}
@@ -120,7 +124,8 @@ public class WarData
sHashMap.put("sieges", SiegeData.getSiegeMap(war));
sHashMap.put("raids", RaidData.getRaidMap(war));
sHashMap.put("lastRaidTime", war.getLastRaidTime());
sHashMap.put("lastRaidTimeSide1", war.getLastRaidTimeSide1());
sHashMap.put("lastRaidTimeSide2", war.getLastRaidTimeSide2());
DataManager.saveData("wars" + File.separator + war.getName() + ".yml", sHashMap);