Initial refactor: deleted all old code and replaced with something sensible. Driven from the guild's mine hour instead of calculating dates.

This commit is contained in:
2023-01-19 10:38:49 -05:00
parent 5ff4703b14
commit 6672f750d9
7 changed files with 34 additions and 276 deletions
+12 -9
View File
@@ -56,28 +56,31 @@ public class HourlyJobThread implements Runnable {
try {
ArrayList<Mine> mines = Mine.getMines();
LocalDateTime now = LocalDateTime.now();
for (Mine mine : mines) {
try {
// Open Errant Mines
if (mine.getOwningGuild() == null) {
mine.handleStartMineWindow();
Mine.setLastChange(System.currentTimeMillis());
continue;
}
//handle claimed mines
LocalDateTime mineWindow = mine.openDate.withMinute(0).withSecond(0).withNano(0);
// Open Mines with a current guild hour
if (mineWindow != null && now.plusMinutes(1).isAfter(mineWindow))
if (!mine.getIsActive()) {
mine.handleStartMineWindow();
if (mine.getOwningGuild().getMineTime() ==
LocalDateTime.now().getHour()) {
mine.handleStartMineWindow();
Mine.setLastChange(System.currentTimeMillis());
continue;
}
// Close all other mines
if (mine.handleEndMineWindow())
Mine.setLastChange(System.currentTimeMillis());
}
else if (mine.handleEndMineWindow())
Mine.setLastChange(System.currentTimeMillis());
} catch (Exception e) {
Logger.error ("mineID: " + mine.getObjectUUID(), e.toString());
}