forked from MagicBane/Server
Migrate JodaTime usage in several database handlers to java.time.*
This commit is contained in:
@@ -14,7 +14,7 @@ import engine.Enum.GuildHistoryType;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.server.world.WorldServer;
|
import engine.server.world.WorldServer;
|
||||||
import org.joda.time.DateTime;
|
import java.time.Instant;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
@@ -125,7 +125,7 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ADD_TO_GUILDHISTORY(int target, PlayerCharacter playerCharacter, DateTime historyDate, GuildHistoryType historyType) {
|
public boolean ADD_TO_GUILDHISTORY(int target, PlayerCharacter playerCharacter, Instant historyDate, GuildHistoryType historyType) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_guildhistory` (`GuildID`, `CharacterID`, `historyDate`, `historyType`) VALUES (?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_guildhistory` (`GuildID`, `CharacterID`, `historyDate`, `historyType`) VALUES (?,?,?,?)")) {
|
||||||
@@ -136,7 +136,7 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
if (historyDate == null)
|
if (historyDate == null)
|
||||||
preparedStatement.setNull(3, java.sql.Types.DATE);
|
preparedStatement.setNull(3, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
preparedStatement.setTimestamp(3, new Timestamp(historyDate.getMillis()));
|
preparedStatement.setTimestamp(3, java.sql.Timestamp.from(historyDate));
|
||||||
|
|
||||||
preparedStatement.setString(4, historyType.name());
|
preparedStatement.setString(4, historyType.name());
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ package engine.db.handlers;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import org.joda.time.DateTime;
|
import java.time.Instant;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -69,7 +69,7 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) {
|
public boolean updateUpgradeTime(Mob mob, Instant upgradeDateTime) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_mob SET upgradeDate=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_mob SET upgradeDate=? "
|
||||||
@@ -78,7 +78,7 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
if (upgradeDateTime == null)
|
if (upgradeDateTime == null)
|
||||||
preparedStatement.setNull(1, java.sql.Types.DATE);
|
preparedStatement.setNull(1, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.getMillis()));
|
preparedStatement.setTimestamp(1, java.sql.Timestamp.from(upgradeDateTime));
|
||||||
|
|
||||||
preparedStatement.setInt(2, mob.getObjectUUID());
|
preparedStatement.setInt(2, mob.getObjectUUID());
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import engine.objects.NPC;
|
|||||||
import engine.objects.NPCProfits;
|
import engine.objects.NPCProfits;
|
||||||
import engine.objects.ProducedItem;
|
import engine.objects.ProducedItem;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import org.joda.time.DateTime;
|
import java.time.Instant;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -203,7 +203,7 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateUpgradeTime(NPC npc, DateTime upgradeDateTime) {
|
public boolean updateUpgradeTime(NPC npc, Instant upgradeDateTime) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET upgradeDate=? "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET upgradeDate=? "
|
||||||
@@ -212,7 +212,7 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
if (upgradeDateTime == null)
|
if (upgradeDateTime == null)
|
||||||
preparedStatement.setNull(1, java.sql.Types.DATE);
|
preparedStatement.setNull(1, java.sql.Types.DATE);
|
||||||
else
|
else
|
||||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.getMillis()));
|
preparedStatement.setTimestamp(1, java.sql.Timestamp.from(upgradeDateTime));
|
||||||
|
|
||||||
preparedStatement.setInt(2, npc.getObjectUUID());
|
preparedStatement.setInt(2, npc.getObjectUUID());
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
+ NPC._pirateNames.size() + " mobBases");
|
+ NPC._pirateNames.size() + " mobBases");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ADD_TO_PRODUCTION_LIST(final long ID, final long npcUID, final long itemBaseID, DateTime dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) {
|
public boolean ADD_TO_PRODUCTION_LIST(final long ID, final long npcUID, final long itemBaseID, Instant dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_production` (`ID`,`npcUID`, `itemBaseID`,`dateToUpgrade`, `isRandom`, `prefix`, `suffix`, `name`,`playerID`) VALUES (?,?,?,?,?,?,?,?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_production` (`ID`,`npcUID`, `itemBaseID`,`dateToUpgrade`, `isRandom`, `prefix`, `suffix`, `name`,`playerID`) VALUES (?,?,?,?,?,?,?,?,?)")) {
|
||||||
@@ -316,7 +316,7 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setLong(1, ID);
|
preparedStatement.setLong(1, ID);
|
||||||
preparedStatement.setLong(2, npcUID);
|
preparedStatement.setLong(2, npcUID);
|
||||||
preparedStatement.setLong(3, itemBaseID);
|
preparedStatement.setLong(3, itemBaseID);
|
||||||
preparedStatement.setTimestamp(4, new java.sql.Timestamp(dateTime.getMillis()));
|
preparedStatement.setTimestamp(4, java.sql.Timestamp.from(dateTime));
|
||||||
preparedStatement.setBoolean(5, isRandom);
|
preparedStatement.setBoolean(5, isRandom);
|
||||||
preparedStatement.setString(6, prefix);
|
preparedStatement.setString(6, prefix);
|
||||||
preparedStatement.setString(7, suffix);
|
preparedStatement.setString(7, suffix);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import engine.math.Vector3fImmutable;
|
|||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.Building;
|
import engine.objects.Building;
|
||||||
import engine.objects.Shrine;
|
import engine.objects.Shrine;
|
||||||
import org.joda.time.DateTime;
|
import java.time.Instant;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -52,7 +52,7 @@ public class dbShrineHandler extends dbHandlerBase {
|
|||||||
public ArrayList<AbstractGameObject> CREATE_SHRINE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
public ArrayList<AbstractGameObject> CREATE_SHRINE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
||||||
Vector3fImmutable location, float meshScale, int currentHP,
|
Vector3fImmutable location, float meshScale, int currentHP,
|
||||||
ProtectionState protectionState, int currentGold, int rank,
|
ProtectionState protectionState, int currentGold, int rank,
|
||||||
DateTime upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
|
Instant upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
|
||||||
|
|
||||||
ArrayList<AbstractGameObject> shrineList = new ArrayList<>();
|
ArrayList<AbstractGameObject> shrineList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class dbShrineHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setInt(12, rank);
|
preparedStatement.setInt(12, rank);
|
||||||
|
|
||||||
if (upgradeDate != null)
|
if (upgradeDate != null)
|
||||||
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
|
preparedStatement.setTimestamp(13, java.sql.Timestamp.from(upgradeDate));
|
||||||
else
|
else
|
||||||
preparedStatement.setNull(13, java.sql.Types.DATE);
|
preparedStatement.setNull(13, java.sql.Types.DATE);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import engine.net.client.ClientConnection;
|
|||||||
import engine.net.client.msg.guild.AcceptInviteToGuildMsg;
|
import engine.net.client.msg.guild.AcceptInviteToGuildMsg;
|
||||||
import engine.net.client.msg.guild.GuildInfoMsg;
|
import engine.net.client.msg.guild.GuildInfoMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import org.joda.time.DateTime;
|
import java.time.Instant;
|
||||||
|
|
||||||
public enum GuildManager {
|
public enum GuildManager {
|
||||||
|
|
||||||
@@ -68,8 +68,8 @@ public enum GuildManager {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (playerCharacter.getGuild() != null && !playerCharacter.getGuild().isEmptyGuild()) {
|
if (playerCharacter.getGuild() != null && !playerCharacter.getGuild().isEmptyGuild()) {
|
||||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, DateTime.now(), GuildHistoryType.LEAVE)) {
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, Instant.now(), GuildHistoryType.LEAVE)) {
|
||||||
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(), playerCharacter.getGuild().getName(), DateTime.now(), GuildHistoryType.LEAVE);
|
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(), playerCharacter.getGuild().getName(), Instant.now(), GuildHistoryType.LEAVE);
|
||||||
playerCharacter.getGuildHistory().add(guildHistory);
|
playerCharacter.getGuildHistory().add(guildHistory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,8 +91,8 @@ public enum GuildManager {
|
|||||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
}
|
}
|
||||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, DateTime.now(), historyType)) {
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, Instant.now(), historyType)) {
|
||||||
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(), guild.getName(), DateTime.now(), historyType);
|
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(), guild.getName(), Instant.now(), historyType);
|
||||||
playerCharacter.getGuildHistory().add(guildHistory);
|
playerCharacter.getGuildHistory().add(guildHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user