forked from MagicBane/Server
Migrate JodaTime to java.time.* in dbBuildingHandler.java
This commit is contained in:
1 parent
e9ce418772
commit
800f72512d
4 files changed
+20
-19
No files matched your search
@@ -16,7 +16,9 @@ import engine.Enum.TaxType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -38,7 +40,7 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
public Building CREATE_BUILDING(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
||||
Vector3fImmutable location, float meshScale, int currentHP,
|
||||
ProtectionState protectionState, int currentGold, int rank,
|
||||
DateTime upgradeDate, int blueprintUUID, float w, float rotY) {
|
||||
Instant upgradeDate, int blueprintUUID, float w, float rotY) {
|
||||
|
||||
Building building = null;
|
||||
|
||||
@@ -59,7 +61,7 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
preparedStatement.setInt(12, rank);
|
||||
|
||||
if (upgradeDate != null)
|
||||
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
|
||||
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.toEpochMilli()));
|
||||
else
|
||||
preparedStatement.setNull(13, java.sql.Types.DATE);
|
||||
|
||||
@@ -752,7 +754,7 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateBuildingUpgradeTime(LocalDateTime upgradeDateTime, Building toUpgrade, int costToUpgrade) {
|
||||
public boolean updateBuildingUpgradeTime(Instant upgradeDateTime, Building toUpgrade, int costToUpgrade) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET upgradeDate=?, currentGold=? "
|
||||
@@ -761,8 +763,7 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
if (upgradeDateTime == null)
|
||||
preparedStatement.setNull(1, java.sql.Types.DATE);
|
||||
else
|
||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault())
|
||||
.toInstant().toEpochMilli()));
|
||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.toEpochMilli()));
|
||||
|
||||
preparedStatement.setInt(2, toUpgrade.getStrongboxValue() - costToUpgrade);
|
||||
preparedStatement.setInt(3, toUpgrade.getObjectUUID());
|
||||
@@ -841,7 +842,7 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxDate=? "
|
||||
+ "WHERE UID = ?")) {
|
||||
|
||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(DateTime.now().plusDays(7).getMillis()));
|
||||
preparedStatement.setTimestamp(1, new java.sql.Timestamp(Instant.now().plus(java.time.temporal.ChronoUnit.DAYS, 7).toEpochMilli()));
|
||||
preparedStatement.setInt(2, building.getObjectUUID());
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
Reference in new issue
Block a user