Browse Source

Extracted open/close logic to method. Run at startup.

master
MagicBot 2 years ago
parent
commit
c89b60221e
  1. 5
      src/engine/server/world/WorldServer.java
  2. 78
      src/engine/workthreads/HourlyJobThread.java

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

@ -389,9 +389,12 @@ public class WorldServer { @@ -389,9 +389,12 @@ public class WorldServer {
}
Logger.info("Loading Mine data.");
//DbManager.MineQueries.syncMineWindowsWithToday();
Mine.loadAllMines();
// Open/Close mines for the current window
Logger.info("Processing mine window.");
HourlyJobThread.processMineWindow();
Logger.info("Loading Shrine data.");
DbManager.ShrineQueries.LOAD_ALL_SHRINES();

78
src/engine/workthreads/HourlyJobThread.java

@ -52,44 +52,11 @@ public class HourlyJobThread implements Runnable { @@ -52,44 +52,11 @@ public class HourlyJobThread implements Runnable {
Logger.error( e.toString());
}
//updateMines.
try {
ArrayList<Mine> mines = Mine.getMines();
for (Mine mine : mines) {
try {
// Open Errant Mines
if (mine.getOwningGuild() == null) {
mine.handleStartMineWindow();
Mine.setLastChange(System.currentTimeMillis());
continue;
}
// Open Mines with a current guild hour
if (mine.getOwningGuild().getMineTime() ==
LocalDateTime.now().getHour()) {
mine.handleStartMineWindow();
Mine.setLastChange(System.currentTimeMillis());
continue;
}
// Open or Close mines for the current mine window.
// Close all other mines
if (mine.handleEndMineWindow())
Mine.setLastChange(System.currentTimeMillis());
processMineWindow();
} catch (Exception e) {
Logger.error ("mineID: " + mine.getObjectUUID(), e.toString());
}
}
} catch (Exception e) {
Logger.error( e.toString());
}
for (Mine mine : Mine.getMines()) {
for (Mine mine : Mine.getMines()) {
try {
mine.depositMineResources();
@ -126,4 +93,43 @@ public class HourlyJobThread implements Runnable { @@ -126,4 +93,43 @@ public class HourlyJobThread implements Runnable {
Logger.info( MessageDispatcher.getNetstatString());
Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted");
}
public static void processMineWindow() {
try {
ArrayList<Mine> mines = Mine.getMines();
for (Mine mine : mines) {
try {
// Open Errant Mines
if (mine.getOwningGuild() == null) {
mine.handleStartMineWindow();
Mine.setLastChange(System.currentTimeMillis());
continue;
}
// Open Mines with a current guild hour
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());
} catch (Exception e) {
Logger.error ("mineID: " + mine.getObjectUUID(), e.toString());
}
}
} catch (Exception e) {
Logger.error( e.toString());
}
}
}

Loading…
Cancel
Save