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:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user