Browse Source

lastHotZoneUpdate instant moved to ZoneManager.

master
MagicBot 2 years ago
parent
commit
8fde121570
  1. 5
      src/engine/gameManager/ZoneManager.java
  2. 6
      src/engine/net/client/handlers/CityDataHandler.java
  3. 6
      src/engine/net/client/msg/HotzoneChangeMsg.java
  4. 3
      src/engine/server/world/WorldServer.java

5
src/engine/gameManager/ZoneManager.java

@ -17,9 +17,9 @@ import engine.objects.Building;
import engine.objects.City; import engine.objects.City;
import engine.objects.Zone; import engine.objects.Zone;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,6 +37,7 @@ public enum ZoneManager {
ZONEMANAGER; ZONEMANAGER;
public static Instant hotZoneLastUpdate;
/* Instance variables */ /* Instance variables */
private static Zone seaFloor = null; private static Zone seaFloor = null;
public static Zone hotZone = null; public static Zone hotZone = null;
@ -155,7 +156,7 @@ 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;
WorldServer.hotZoneLastUpdate = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant(); hotZoneLastUpdate = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant();
} }

6
src/engine/net/client/handlers/CityDataHandler.java

@ -10,13 +10,9 @@ import engine.net.DispatchMessage;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.*; import engine.net.client.msg.*;
import engine.objects.City; import engine.objects.City;
import engine.objects.Mine;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.server.world.WorldServer;
import engine.session.Session; import engine.session.Session;
import java.time.ZoneId;
/* /*
* @Author: * @Author:
* @Summary: Processes application protocol message which displays * @Summary: Processes application protocol message which displays
@ -68,7 +64,7 @@ public class CityDataHandler extends AbstractClientMsgHandler {
// If the hotZone has changed then update the client's map accordingly. // If the hotZone has changed then update the client's map accordingly.
if (playerCharacter.getTimeStamp("hotzoneupdate") <= WorldServer.hotZoneLastUpdate.toEpochMilli() && ZoneManager.hotZone != null) { if (playerCharacter.getTimeStamp("hotzoneupdate") <= ZoneManager.hotZoneLastUpdate.toEpochMilli() && ZoneManager.hotZone != null) {
HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID()); HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID());
dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg); dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);

6
src/engine/net/client/msg/HotzoneChangeMsg.java

@ -11,15 +11,13 @@ package engine.net.client.msg;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.math.FastMath; import engine.gameManager.ZoneManager;
import engine.net.AbstractConnection; import engine.net.AbstractConnection;
import engine.net.ByteBufferReader; import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
import engine.net.client.Protocol; import engine.net.client.Protocol;
import engine.server.world.WorldServer;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime;
public class HotzoneChangeMsg extends ClientNetMsg { public class HotzoneChangeMsg extends ClientNetMsg {
@ -38,7 +36,7 @@ public class HotzoneChangeMsg extends ClientNetMsg {
int hotZoneDuration = Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue()); int hotZoneDuration = Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue());
endOfCycle = Duration.between(WorldServer.hotZoneLastUpdate, WorldServer.hotZoneLastUpdate.plusSeconds(hotZoneDuration * 3600)); endOfCycle = Duration.between(ZoneManager.hotZoneLastUpdate, ZoneManager.hotZoneLastUpdate.plusSeconds(hotZoneDuration * 3600));
} }

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

@ -58,9 +58,7 @@ import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -72,7 +70,6 @@ import static java.lang.System.exit;
public class WorldServer { public class WorldServer {
private static LocalDateTime bootTime = LocalDateTime.now(); private static LocalDateTime bootTime = LocalDateTime.now();
public static Instant hotZoneLastUpdate;
public boolean isRunning = false; public boolean isRunning = false;
// Member variable declaration // Member variable declaration

Loading…
Cancel
Save