Browse Source

mine window processing

lakebane-master
FatBoy-DOTC 5 months ago
parent
commit
6313182c4f
  1. 7
      src/engine/workthreads/MineThread.java

7
src/engine/workthreads/MineThread.java

@ -25,7 +25,7 @@ public class MineThread implements Runnable {
nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
while (true) { while (true) {
if(LocalDateTime.now().isAfter(nextPulse)) { if(LocalDateTime.now().isAfter(nextPulse)) {
processMineWindows(); processMineWindows(nextPulse);
} }
} }
} }
@ -104,16 +104,13 @@ public class MineThread implements Runnable {
return true; return true;
} }
public static void processMineWindows(){ public static void processMineWindows(LocalDateTime currentTime){
for (Mine mine : Mine.getMines()) { for (Mine mine : Mine.getMines()) {
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
//if the tower comes back null, skip this mine //if the tower comes back null, skip this mine
if(tower == null) if(tower == null)
continue; continue;
//log the current time right now
LocalDateTime currentTime = LocalDateTime.now().plusMinutes(1);
//check if this mine needs to open //check if this mine needs to open
LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0); LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0);
if(currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened){ if(currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened){

Loading…
Cancel
Save