refactor: migrate JodaTime to java.time (rebuild on subdate2 ab96cfc)
Complete the JodaTime -> java.time migration across 30 files on the correct subdate2 base. No org.joda references remain.
This commit is contained in:
1 parent
ab96cfcda4
commit
8a136d84f4
30 files changed
+184
-196
No files matched your search
@@ -25,7 +25,8 @@ import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -40,8 +41,8 @@ public final class Bane {
|
||||
private final int cityUUID;
|
||||
private final int stoneUUID;
|
||||
private int ownerUUID;
|
||||
private DateTime placementDate = null;
|
||||
private DateTime liveDate = null;
|
||||
private LocalDateTime placementDate = null;
|
||||
private LocalDateTime liveDate = null;
|
||||
private BaneDefaultTimeJob defaultTimeJob;
|
||||
|
||||
// Internal cache for banes
|
||||
@@ -62,12 +63,12 @@ public final class Bane {
|
||||
sqlDateTime = rs.getTimestamp("placementDate");
|
||||
|
||||
if (sqlDateTime != null)
|
||||
this.placementDate = new DateTime(sqlDateTime);
|
||||
this.placementDate = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
|
||||
|
||||
sqlDateTime = rs.getTimestamp("liveDate");
|
||||
|
||||
if (sqlDateTime != null)
|
||||
this.liveDate = new DateTime(sqlDateTime);
|
||||
this.liveDate = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
|
||||
|
||||
switch (this.getSiegePhase()) {
|
||||
|
||||
@@ -81,7 +82,7 @@ public final class Bane {
|
||||
this.activateBaneJob.cancelJob();
|
||||
|
||||
abtj = new ActivateBaneJob(cityUUID);
|
||||
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.getMillis());
|
||||
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
this.activateBaneJob = abtj;
|
||||
|
||||
break;
|
||||
@@ -93,7 +94,7 @@ public final class Bane {
|
||||
this.activateBaneJob.cancelJob();
|
||||
|
||||
abtj = new ActivateBaneJob(cityUUID);
|
||||
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.getMillis());
|
||||
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
this.activateBaneJob = abtj;
|
||||
|
||||
break;
|
||||
@@ -353,7 +354,7 @@ public final class Bane {
|
||||
return phase;
|
||||
}
|
||||
|
||||
if (DateTime.now().isAfter(this.liveDate)) {
|
||||
if (LocalDateTime.now().isAfter(this.liveDate)) {
|
||||
phase = SiegePhase.WAR; //war
|
||||
return phase;
|
||||
}
|
||||
@@ -368,15 +369,10 @@ public final class Bane {
|
||||
|
||||
private void setDefaultTime() {
|
||||
|
||||
DateTime timeToSetDefault = new DateTime(this.placementDate);
|
||||
timeToSetDefault = timeToSetDefault.plusDays(1);
|
||||
LocalDateTime timeToSetDefault = this.placementDate.plusDays(1);
|
||||
|
||||
DateTime currentTime = DateTime.now();
|
||||
DateTime defaultTime = new DateTime(this.placementDate);
|
||||
defaultTime = defaultTime.plusDays(2);
|
||||
defaultTime = defaultTime.hourOfDay().setCopy(22);
|
||||
defaultTime = defaultTime.minuteOfHour().setCopy(0);
|
||||
defaultTime = defaultTime.secondOfMinute().setCopy(0);
|
||||
LocalDateTime currentTime = LocalDateTime.now();
|
||||
LocalDateTime defaultTime = this.placementDate.plusDays(2).withHour(22).withMinute(0).withSecond(0);
|
||||
|
||||
if (currentTime.isAfter(timeToSetDefault))
|
||||
this.setLiveDate(defaultTime);
|
||||
@@ -386,7 +382,7 @@ public final class Bane {
|
||||
this.defaultTimeJob.cancelJob();
|
||||
|
||||
BaneDefaultTimeJob bdtj = new BaneDefaultTimeJob(this);
|
||||
JobScheduler.getInstance().scheduleJob(bdtj, timeToSetDefault.getMillis());
|
||||
JobScheduler.getInstance().scheduleJob(bdtj, timeToSetDefault.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
this.defaultTimeJob = bdtj;
|
||||
}
|
||||
}
|
||||
@@ -453,7 +449,7 @@ public final class Bane {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final DateTime getPlacementDate() {
|
||||
public final LocalDateTime getPlacementDate() {
|
||||
return placementDate;
|
||||
}
|
||||
|
||||
@@ -462,14 +458,14 @@ public final class Bane {
|
||||
return (this.getSiegePhase() != SiegePhase.CHALLENGE);
|
||||
}
|
||||
|
||||
public final DateTime getLiveDate() {
|
||||
public final LocalDateTime getLiveDate() {
|
||||
return liveDate;
|
||||
}
|
||||
|
||||
public void setLiveDate(DateTime baneTime) {
|
||||
public void setLiveDate(LocalDateTime baneTime) {
|
||||
|
||||
if (DbManager.BaneQueries.SET_BANE_TIME(baneTime, this.getCity().getObjectUUID())) {
|
||||
this.liveDate = new DateTime(baneTime);
|
||||
this.liveDate = baneTime;
|
||||
|
||||
// Push event to warehouse
|
||||
|
||||
@@ -511,7 +507,7 @@ public final class Bane {
|
||||
|
||||
ActivateBaneJob abtj = new ActivateBaneJob(cityUUID);
|
||||
|
||||
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.getMillis());
|
||||
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
this.activateBaneJob = abtj;
|
||||
} else {
|
||||
Logger.debug("error with city " + this.getCity().getName());
|
||||
|
||||
Reference in new issue
Block a user