Browse Source

hotzone cleanup

master
FatBoy-DOTC 2 years ago
parent
commit
10cd3636f7
  1. 2
      src/engine/gameManager/ZoneManager.java
  2. 3
      src/engine/objects/Zone.java
  3. 14
      src/engine/workthreads/HourlyJobThread.java

2
src/engine/gameManager/ZoneManager.java

@ -20,6 +20,7 @@ import engine.server.MBServerStatics; @@ -20,6 +20,7 @@ import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -127,6 +128,7 @@ public enum ZoneManager { @@ -127,6 +128,7 @@ public enum ZoneManager {
return;
ZoneManager.hotzone = zone;
zone.hasBeenHotzone = true;
zone.becameHotzone = LocalDateTime.now();
}
public static boolean inHotZone(final Vector3fImmutable loc) {

3
src/engine/objects/Zone.java

@ -23,6 +23,7 @@ import org.pmw.tinylog.Logger; @@ -23,6 +23,7 @@ import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
@ -60,7 +61,7 @@ public class Zone extends AbstractGameObject { @@ -60,7 +61,7 @@ public class Zone extends AbstractGameObject {
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public boolean hasBeenHotzone = false;
public int hoursAsHotzone = 0;
public LocalDateTime becameHotzone = null;
/**
* ResultSet Constructor
*/

14
src/engine/workthreads/HourlyJobThread.java

@ -42,17 +42,21 @@ public class HourlyJobThread implements Runnable { @@ -42,17 +42,21 @@ public class HourlyJobThread implements Runnable {
Logger.info("Hourly job is now running.");
try {
ZoneManager.generateAndSetRandomHotzone();
Zone hotzone = ZoneManager.getHotZone();
if(hotzone == null){
//no hotzone? set one.
ZoneManager.generateAndSetRandomHotzone();
}
int hotzoneDuration = Integer.valueOf(ConfigManager.MB_HOTZONE_DURATION.getValue());
if(((LocalDateTime.now().getHour()) - hotzone.becameHotzone.getHour()) >= hotzoneDuration) {
ZoneManager.generateAndSetRandomHotzone();
hotzone = ZoneManager.getHotZone();
}
if (hotzone == null) {
Logger.error("Null hotzone returned from mapmanager");
} else {
hotzone.hoursAsHotzone += 1;
if(hotzone.hoursAsHotzone >= Integer.valueOf(ConfigManager.MB_HOTZONE_DURATION.getValue())) {
Logger.info("new hotzone: " + hotzone.getName());
WorldServer.setLastHZChange(System.currentTimeMillis());
}
}
} catch (Exception e) {

Loading…
Cancel
Save