|
|
|
@ -23,43 +23,45 @@ public class MineThread implements Runnable {
@@ -23,43 +23,45 @@ public class MineThread implements Runnable {
|
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
LocalDateTime nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); |
|
|
|
|
while (true){ |
|
|
|
|
if(LocalDateTime.now().isAfter(nextPulse)) { |
|
|
|
|
for (Mine mine : Mine.getMines()) { |
|
|
|
|
while (true) { |
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
|
|
|
|
|
if(nextPulse.getHour() == 2 && nextPulse.getMinute() == 0){ |
|
|
|
|
if (now.isAfter(nextPulse)) { |
|
|
|
|
for (Mine mine : Mine.getMines()) { |
|
|
|
|
// Reset mine at 4:00 AM
|
|
|
|
|
if (nextPulse.getHour() == 4 && nextPulse.getMinute() == 0) { |
|
|
|
|
mine.wasClaimed = false; |
|
|
|
|
mine.hasProduced = false; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
Building mineTower = BuildingManager.getBuilding(mine.getBuildingID()); |
|
|
|
|
|
|
|
|
|
if (mineTower == null) |
|
|
|
|
Building mineTower = BuildingManager.getBuilding(mine.getBuildingID()); |
|
|
|
|
if (mineTower == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int minute = 0; |
|
|
|
|
if (mine.firstThirty == false) |
|
|
|
|
minute = 30; |
|
|
|
|
|
|
|
|
|
LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveTime).withMinute(minute).withSecond(0); |
|
|
|
|
int minute = mine.firstThirty ? 0 : 30; |
|
|
|
|
LocalDateTime openTime = now.withHour(mine.liveTime).withMinute(minute).withSecond(0).withNano(0); |
|
|
|
|
LocalDateTime closeTime = openTime.plusMinutes(29); |
|
|
|
|
|
|
|
|
|
//current time is after start time and before close time, open mine window
|
|
|
|
|
if (LocalDateTime.now().isAfter(openTime.minusMinutes(1)) && !mine.wasClaimed && !mine.wasOpened) { |
|
|
|
|
if (!mine.wasClaimed && !mine.wasOpened && now.isAfter(openTime.minusMinutes(1))) { |
|
|
|
|
mineWindowOpen(mine); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (mine.isActive) { |
|
|
|
|
|
|
|
|
|
if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() > 0) |
|
|
|
|
mineWindowClose(mine); //mine was never knocked down, close window
|
|
|
|
|
|
|
|
|
|
if (LocalDateTime.now().isAfter(closeTime) && mineTower.getRank() < 1 && mine.lastClaimer != null) |
|
|
|
|
mineWindowClose(mine); //mine was knocked down and was claimed, close window
|
|
|
|
|
if (mine.isActive && now.isAfter(closeTime)) { |
|
|
|
|
if (mineTower.getRank() > 0 || (mineTower.getRank() < 1 && mine.lastClaimer != null)) { |
|
|
|
|
mineWindowClose(mine); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
nextPulse = nextPulse.plusMinutes(30); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
Thread.sleep(1000); // Avoid busy-waiting
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|