hotzone cleanup
This commit is contained in:
@@ -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 {
|
||||
return;
|
||||
ZoneManager.hotzone = zone;
|
||||
zone.hasBeenHotzone = true;
|
||||
zone.becameHotzone = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public static boolean inHotZone(final Vector3fImmutable loc) {
|
||||
|
||||
@@ -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 {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user