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. 76
      src/engine/workthreads/HourlyJobThread.java

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

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

76
src/engine/workthreads/HourlyJobThread.java

@ -52,42 +52,9 @@ public class HourlyJobThread implements Runnable {
Logger.error( e.toString()); Logger.error( e.toString());
} }
//updateMines. // Open or Close mines for the current mine window.
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) { processMineWindow();
Logger.error ("mineID: " + mine.getObjectUUID(), e.toString());
}
}
} catch (Exception e) {
Logger.error( e.toString());
}
for (Mine mine : Mine.getMines()) { for (Mine mine : Mine.getMines()) {
@ -126,4 +93,43 @@ public class HourlyJobThread implements Runnable {
Logger.info( MessageDispatcher.getNetstatString()); Logger.info( MessageDispatcher.getNetstatString());
Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted"); 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