HotZone availability reset at 01am.
This commit is contained in:
@@ -54,8 +54,7 @@ public class HotzoneCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input.equalsIgnoreCase("reset"))
|
if (input.equalsIgnoreCase("reset"))
|
||||||
for (Zone zone: ZoneManager.getAllZones())
|
ZoneManager.resetHotZones();
|
||||||
zone.hasBeenHotzone = false;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,10 @@ public enum ZoneManager {
|
|||||||
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static final ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static final ConcurrentHashMap<String, Zone> zonesByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<String, Zone> zonesByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
private static final Set<Zone> npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
private static final Set<Zone> npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
private static final Set<Zone> playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
private static final Set<Zone> playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
|
|
||||||
// Find all zones coordinates fit into, starting with Sea Floor
|
// Find all zones coordinates fit into, starting with Sea Floor
|
||||||
|
|
||||||
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
|
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
|
||||||
@@ -108,6 +109,30 @@ public enum ZoneManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the number of available hotZones
|
||||||
|
// remaining in this cycle (1am)
|
||||||
|
public static int availableHotZones() {
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
for (Zone zone : ZoneManager.macroZones)
|
||||||
|
if (zone.hasBeenHotzone)
|
||||||
|
count = count + 1;
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resets the availability of hotZones
|
||||||
|
// for this cycle
|
||||||
|
|
||||||
|
public static void resetHotZones() {
|
||||||
|
|
||||||
|
for (Zone zone : ZoneManager.macroZones)
|
||||||
|
if (zone.hasBeenHotzone)
|
||||||
|
zone.hasBeenHotzone = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Zone getZoneByUUID(final int zoneUUID) {
|
public static Zone getZoneByUUID(final int zoneUUID) {
|
||||||
return ZoneManager.zonesByUUID.get(zoneUUID);
|
return ZoneManager.zonesByUUID.get(zoneUUID);
|
||||||
}
|
}
|
||||||
@@ -129,7 +154,6 @@ public enum ZoneManager {
|
|||||||
ZoneManager.hotZone = zone;
|
ZoneManager.hotZone = zone;
|
||||||
ZoneManager.hotZoneCycle = 1; // Used with HOTZONE_DURATION from config.
|
ZoneManager.hotZoneCycle = 1; // Used with HOTZONE_DURATION from config.
|
||||||
zone.hasBeenHotzone = true;
|
zone.hasBeenHotzone = true;
|
||||||
zone.becameHotzone = LocalDateTime.now();
|
|
||||||
WorldServer.hotZoneLastUpdate = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant();
|
WorldServer.hotZoneLastUpdate = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ public class Zone extends AbstractGameObject {
|
|||||||
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
public boolean hasBeenHotzone = false;
|
public boolean hasBeenHotzone = false;
|
||||||
public LocalDateTime becameHotzone = null;
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -191,6 +191,13 @@ public class HourlyJobThread implements Runnable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// Reset zone availability at 1am
|
||||||
|
// or if we run out of hotZones
|
||||||
|
|
||||||
|
if (LocalDateTime.now().getHour() == 01 ||
|
||||||
|
ZoneManager.availableHotZones() == 0)
|
||||||
|
ZoneManager.resetHotZones();
|
||||||
|
|
||||||
// Use the same hotZone this hour up and until
|
// Use the same hotZone this hour up and until
|
||||||
// the HotZone_Duration from the ConfigManager
|
// the HotZone_Duration from the ConfigManager
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user