Seconds remaining calculated only once.
This commit is contained in:
@@ -156,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;
|
||||||
hotZoneLastUpdate = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant();
|
ZoneManager.hotZoneLastUpdate = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,15 @@ import engine.net.client.Protocol;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
|
||||||
|
|
||||||
public class HotzoneChangeMsg extends ClientNetMsg {
|
public class HotzoneChangeMsg extends ClientNetMsg {
|
||||||
|
|
||||||
private int zoneType;
|
private int zoneType;
|
||||||
private int zoneID;
|
private int zoneID;
|
||||||
private Duration endOfCycle;
|
private int secondsRemaining;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
@@ -36,8 +38,8 @@ public class HotzoneChangeMsg extends ClientNetMsg {
|
|||||||
this.zoneID = zoneID;
|
this.zoneID = zoneID;
|
||||||
|
|
||||||
int hotZoneDuration = Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue());
|
int hotZoneDuration = Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue());
|
||||||
|
Instant currentInstant = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant();
|
||||||
endOfCycle = Duration.between(Instant.now(), ZoneManager.hotZoneLastUpdate.plusSeconds(hotZoneDuration * 3600));
|
secondsRemaining = (int) Duration.between(currentInstant, ZoneManager.hotZoneLastUpdate.plusSeconds(hotZoneDuration * 3600)).getSeconds();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +61,7 @@ public class HotzoneChangeMsg extends ClientNetMsg {
|
|||||||
protected void _serialize(ByteBufferWriter writer) {
|
protected void _serialize(ByteBufferWriter writer) {
|
||||||
writer.putInt(this.zoneType);
|
writer.putInt(this.zoneType);
|
||||||
writer.putInt(this.zoneID);
|
writer.putInt(this.zoneID);
|
||||||
writer.putInt((int) endOfCycle.getSeconds());
|
writer.putInt(secondsRemaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user