Browse Source

new mine handling system

lakebane-master
FatBoy-DOTC 5 months ago
parent
commit
a8e3cfa8f7
  1. 16
      src/engine/server/world/WorldServer.java
  2. 12
      src/engine/workthreads/MineThread.java

16
src/engine/server/world/WorldServer.java

@ -209,6 +209,7 @@ public class WorldServer { @@ -209,6 +209,7 @@ public class WorldServer {
LocalDateTime nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(0);
LocalDateTime nextWareHousePushTime = LocalDateTime.now();
LocalDateTime nextDiscSpawn = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1);
LocalDateTime nextMinePulse = LocalDateTime.now().withMinute(0).withSecond(0);
// Begin execution of main game loop
@ -265,6 +266,13 @@ public class WorldServer { @@ -265,6 +266,13 @@ public class WorldServer {
}
nextDiscSpawn = nextDiscSpawn.plusHours(1);
}
if (LocalDateTime.now().isAfter(nextMinePulse)) {
Thread mineThread = new Thread(new MineThread());
mineThread.setName("mineThread");
mineThread.start();
nextMinePulse = nextMinePulse.plusMinutes(30);
}
ThreadUtils.sleep(50);
}
}
@ -544,10 +552,10 @@ public class WorldServer { @@ -544,10 +552,10 @@ public class WorldServer {
Logger.info("Running garbage collection...");
System.gc();
Logger.info("Starting Mine Thread...");
Thread mineThread = new Thread(new MineThread());
mineThread.setName("mine thread");
mineThread.start();
//Logger.info("Starting Mine Thread...");
//Thread mineThread = new Thread(new MineThread());
//mineThread.setName("mine thread");
//mineThread.start();
//Logger.info("Starting Power Thread...");
//Thread powerThread = new Thread(new PowersThread());

12
src/engine/workthreads/MineThread.java

@ -16,18 +16,12 @@ import org.pmw.tinylog.Logger; @@ -16,18 +16,12 @@ import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
public class MineThread implements Runnable {
public static LocalDateTime nextPulse;
public MineThread(){
}
@Override
public void run() {
nextPulse = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
while (true) {
if(LocalDateTime.now().isAfter(nextPulse)) {
processMineWindows(nextPulse);
}
}
processMineWindows();
}
public static void mineWindowOpen(Mine mine) {
@ -104,7 +98,8 @@ public class MineThread implements Runnable { @@ -104,7 +98,8 @@ public class MineThread implements Runnable {
return true;
}
public static void processMineWindows(LocalDateTime currentTime){
public static void processMineWindows(){
LocalDateTime currentTime = LocalDateTime.now();
for (Mine mine : Mine.getMines()) {
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
//if the tower comes back null, skip this mine
@ -139,6 +134,5 @@ public class MineThread implements Runnable { @@ -139,6 +134,5 @@ public class MineThread implements Runnable {
}
}
nextPulse = nextPulse.plusMinutes(30);
}
}

Loading…
Cancel
Save