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());
|
||||
|
||||
@@ -22,7 +22,7 @@ import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.UpdateClientAlliancesMsg;
|
||||
import engine.net.client.msg.guild.GuildInfoMsg;
|
||||
import engine.server.world.WorldServer;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -612,8 +612,8 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
//Add to Guild History
|
||||
if (pc.getGuild() != null) {
|
||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, DateTime.now(), historyType)) {
|
||||
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name, DateTime.now(), historyType);
|
||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, Instant.now(), historyType)) {
|
||||
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name, Instant.now(), historyType);
|
||||
pc.getGuildHistory().add(guildHistory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ package engine.objects;
|
||||
import engine.mbEnums.GameObjectType;
|
||||
import engine.mbEnums.GuildHistoryType;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
|
||||
public class GuildHistory {
|
||||
@@ -24,12 +25,12 @@ public class GuildHistory {
|
||||
|
||||
private int guildID;
|
||||
private String guildName;
|
||||
private DateTime time;
|
||||
private Instant time;
|
||||
private GuildHistoryType historyType;
|
||||
|
||||
|
||||
public GuildHistory(int guildID, String guildName,
|
||||
DateTime dateTime, GuildHistoryType historyType) {
|
||||
Instant dateTime, GuildHistoryType historyType) {
|
||||
super();
|
||||
this.guildID = guildID;
|
||||
this.guildName = guildName;
|
||||
@@ -49,9 +50,9 @@ public class GuildHistory {
|
||||
|
||||
sqlDateTime = rs.getTimestamp("historyDate");
|
||||
if (sqlDateTime != null)
|
||||
this.time = new DateTime(sqlDateTime);
|
||||
this.time = sqlDateTime.toInstant();
|
||||
else
|
||||
this.time = DateTime.now().minusYears(1);
|
||||
this.time = Instant.now().minus(1, ChronoUnit.YEARS);
|
||||
this.historyType = GuildHistoryType.valueOf(rs.getString("historyType"));
|
||||
}
|
||||
|
||||
@@ -77,11 +78,11 @@ public class GuildHistory {
|
||||
writer.putDateTime(this.time);
|
||||
}
|
||||
|
||||
public DateTime getTime() {
|
||||
public Instant getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(DateTime time) {
|
||||
public void setTime(Instant time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ import engine.net.client.msg.PetMsg;
|
||||
import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -71,7 +72,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
public long nextAttackTime = System.currentTimeMillis();
|
||||
private int lastMobPowerToken = 0;
|
||||
private DeferredPowerJob weaponPower;
|
||||
private DateTime upgradeDateTime = null;
|
||||
private LocalDateTime upgradeDateTime = null;
|
||||
private boolean lootSync = false;
|
||||
|
||||
// New Mobile constructor. Fill in the blanks and then call
|
||||
@@ -126,7 +127,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
sqlDateTime = rs.getTimestamp("upgradeDate");
|
||||
|
||||
if (sqlDateTime != null)
|
||||
upgradeDateTime = new DateTime(sqlDateTime);
|
||||
upgradeDateTime = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
|
||||
else
|
||||
upgradeDateTime = null;
|
||||
|
||||
@@ -593,8 +594,8 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
|
||||
// Submit upgrade job for future date or current instant
|
||||
|
||||
if (mob.getUpgradeDateTime().isAfter(DateTime.now()))
|
||||
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), mob.getUpgradeDateTime().getMillis());
|
||||
if (mob.getUpgradeDateTime().isAfter(LocalDateTime.now()))
|
||||
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), mob.getUpgradeDateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
else
|
||||
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), 0);
|
||||
|
||||
@@ -620,7 +621,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
return upgradeCost;
|
||||
}
|
||||
|
||||
public static void setUpgradeDateTime(Mob mob, DateTime upgradeDateTime) {
|
||||
public static void setUpgradeDateTime(Mob mob, LocalDateTime upgradeDateTime) {
|
||||
|
||||
if (!DbManager.MobQueries.updateUpgradeTime(mob, upgradeDateTime)) {
|
||||
Logger.error("Failed to set upgradeTime for building " + mob.currentID);
|
||||
@@ -1353,7 +1354,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
this.weaponPower = weaponPower;
|
||||
}
|
||||
|
||||
public DateTime getUpgradeDateTime() {
|
||||
public LocalDateTime getUpgradeDateTime() {
|
||||
|
||||
lock.readLock().lock();
|
||||
|
||||
@@ -1433,7 +1434,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
if (!building.transferGold(-rankCost, false))
|
||||
return;
|
||||
|
||||
DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this));
|
||||
LocalDateTime dateToUpgrade = LocalDateTime.now().plusHours(Mob.getUpgradeTime(this));
|
||||
Mob.setUpgradeDateTime(this, dateToUpgrade);
|
||||
|
||||
// Schedule upgrade job
|
||||
|
||||
@@ -24,7 +24,8 @@ import engine.net.Dispatch;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
import engine.net.client.msg.PlaceAssetMsg;
|
||||
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;
|
||||
@@ -67,7 +68,7 @@ public class NPC extends AbstractCharacter {
|
||||
protected int symbol;
|
||||
// Variables NOT to be stored in db
|
||||
protected boolean isStatic = false;
|
||||
private DateTime upgradeDateTime = null;
|
||||
private LocalDateTime upgradeDateTime = null;
|
||||
private HashSet<Integer> canRoll = null;
|
||||
public int parentZoneUUID;
|
||||
public int equipmentSetID = 0;
|
||||
@@ -131,7 +132,7 @@ public class NPC extends AbstractCharacter {
|
||||
sqlDateTime = rs.getTimestamp("upgradeDate");
|
||||
|
||||
if (sqlDateTime != null)
|
||||
upgradeDateTime = new DateTime(sqlDateTime);
|
||||
upgradeDateTime = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
|
||||
else
|
||||
upgradeDateTime = null;
|
||||
|
||||
@@ -527,9 +528,9 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
// Submit upgrade job for future date or current instant
|
||||
|
||||
if (this.getUpgradeDateTime().isAfter(DateTime.now()))
|
||||
if (this.getUpgradeDateTime().isAfter(LocalDateTime.now()))
|
||||
jc = JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(this),
|
||||
this.getUpgradeDateTime().getMillis());
|
||||
this.getUpgradeDateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
else
|
||||
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(this), 0);
|
||||
|
||||
@@ -907,7 +908,7 @@ public class NPC extends AbstractCharacter {
|
||||
return new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
}
|
||||
|
||||
public DateTime getUpgradeDateTime() {
|
||||
public LocalDateTime getUpgradeDateTime() {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return upgradeDateTime;
|
||||
@@ -916,7 +917,7 @@ public class NPC extends AbstractCharacter {
|
||||
}
|
||||
}
|
||||
|
||||
public void setUpgradeDateTime(DateTime upgradeDateTime) {
|
||||
public void setUpgradeDateTime(LocalDateTime upgradeDateTime) {
|
||||
|
||||
if (!DbManager.NPCQueries.updateUpgradeTime(this, upgradeDateTime)) {
|
||||
Logger.error("Failed to set upgradeTime for building " + currentID);
|
||||
@@ -1059,7 +1060,7 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
int rankCost;
|
||||
Building building;
|
||||
DateTime dateToUpgrade;
|
||||
LocalDateTime dateToUpgrade;
|
||||
|
||||
|
||||
this.lock.writeLock().lock();
|
||||
@@ -1102,7 +1103,7 @@ public class NPC extends AbstractCharacter {
|
||||
if (!building.transferGold(-rankCost, false))
|
||||
return;
|
||||
|
||||
dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime());
|
||||
dateToUpgrade = LocalDateTime.now().plusHours(this.getUpgradeTime());
|
||||
|
||||
this.setUpgradeDateTime(dateToUpgrade);
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ import engine.server.MBServerStatics;
|
||||
import engine.server.login.LoginServer;
|
||||
import engine.server.world.WorldServer;
|
||||
import engine.util.MiscUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -702,11 +703,11 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
writer.putInt(token);
|
||||
writer.putInt((int) timeLeft / 1000);
|
||||
}
|
||||
DateTime enterWorld = new DateTime(playerCharacter.timestamps.get("EnterWorld"));
|
||||
Instant enterWorld = Instant.ofEpochMilli(playerCharacter.timestamps.get("EnterWorld"));
|
||||
writer.putDateTime(enterWorld);
|
||||
|
||||
writer.putInt(0x49EF1E98); //DUnno what playerCharacter is.
|
||||
writer.putFloat(DateTime.now().hourOfDay().get()); //daylight in float.
|
||||
writer.putFloat(Instant.now().atZone(ZoneId.systemDefault()).toLocalTime().getHour()); //daylight in float.
|
||||
writer.putFloat(6); //interval of light to change per game hour //float
|
||||
//writer.putInt(1637194901); //playerCharacter is actually an opcode taht is in recordings, no clue what it is, dumped it and it changes nothing
|
||||
} else {
|
||||
@@ -4364,7 +4365,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
this.timestamps.put("RealmClaim", DateTime.now().plusMinutes(3).getMillis());
|
||||
this.timestamps.put("RealmClaim", Instant.now().plusSeconds(180).toEpochMilli());
|
||||
for (PlayerCharacter toSend : SessionManager.getAllActivePlayerCharacters()) {
|
||||
ChatManager.chatSystemInfo(toSend, this.getCombinedName() + " is seeking to claim a realm and already has " + count + " blessngs!");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ package engine.objects;
|
||||
import engine.mbEnums;
|
||||
import engine.mbEnums.GameObjectType;
|
||||
import engine.mbEnums.TransactionType;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -24,7 +24,7 @@ public class Transaction implements Comparable<Transaction> {
|
||||
private final int warehouseUUID;
|
||||
private final int targetUUID;
|
||||
private final mbEnums.ResourceType resource;
|
||||
private final DateTime date;
|
||||
private final Instant date;
|
||||
private final int amount;
|
||||
private final TransactionType transactionType;
|
||||
private GameObjectType targetType;
|
||||
@@ -41,15 +41,15 @@ public class Transaction implements Comparable<Transaction> {
|
||||
Date sqlDateTime = rs.getTimestamp("date");
|
||||
|
||||
if (sqlDateTime != null)
|
||||
this.date = new DateTime(sqlDateTime);
|
||||
this.date = sqlDateTime.toInstant();
|
||||
else
|
||||
this.date = DateTime.now();
|
||||
this.date = Instant.now();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Transaction(int warehouseUUID, GameObjectType targetType, int targetUUID, TransactionType transactionType, mbEnums.ResourceType resource, int amount,
|
||||
DateTime date) {
|
||||
Instant date) {
|
||||
this.warehouseUUID = warehouseUUID;
|
||||
this.targetUUID = targetUUID;
|
||||
this.resource = resource;
|
||||
@@ -75,7 +75,7 @@ public class Transaction implements Comparable<Transaction> {
|
||||
}
|
||||
|
||||
|
||||
public DateTime getDate() {
|
||||
public Instant getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import engine.net.Dispatch;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -576,10 +576,10 @@ public class Warehouse {
|
||||
|
||||
public static void AddTransactionToWarehouse(Warehouse warehouse, mbEnums.GameObjectType targetType, int targetUUID, mbEnums.TransactionType transactionType, mbEnums.ResourceType resource, int amount) {
|
||||
|
||||
if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now()))
|
||||
if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, Instant.now()))
|
||||
return;
|
||||
|
||||
Transaction transaction = new Transaction(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now());
|
||||
Transaction transaction = new Transaction(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, Instant.now());
|
||||
warehouse.transactions.add(transaction);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user