From cd767dc68cdb676601549c21dbc10a64b11dfe2b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 31 Dec 2024 13:59:23 -0600 Subject: [PATCH] bane system work --- src/engine/db/handlers/dbBaneHandler.java | 21 +++++++++++++++++++++ src/engine/objects/Contract.java | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/src/engine/db/handlers/dbBaneHandler.java b/src/engine/db/handlers/dbBaneHandler.java index 72d9c679..311304f9 100644 --- a/src/engine/db/handlers/dbBaneHandler.java +++ b/src/engine/db/handlers/dbBaneHandler.java @@ -223,4 +223,25 @@ public class dbBaneHandler extends dbHandlerBase { return true; } + + public DateTime getLiveDate(int cityUUID) { + try (Connection connection = DbManager.getConnection(); + PreparedStatement statement = connection.prepareStatement("SELECT `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?")) { + + statement.setInt(1, cityUUID); + + try (ResultSet rs = statement.executeQuery()) { + if (rs.next()) { + Timestamp liveDateTimestamp = rs.getTimestamp("liveDate"); + if (liveDateTimestamp != null) { + return new DateTime(liveDateTimestamp.getTime()); + } + } + } + + } catch (SQLException e) { + Logger.error(e); + } + return null; // Return null if liveDate is not found or an error occurs + } } diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index a4529ce7..a66772a0 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -376,6 +376,7 @@ public class Contract extends AbstractGameObject { bane.setLiveDate_NEW(bane.getLiveDate().plusDays(updateBaneDay)); } } + bane.setLiveDate(DbManager.BaneQueries.getLiveDate(bane.getCityUUID())); } if (updateBaneTime > 0) { if(DbManager.BaneQueries.SET_BANE_TIME_NEW(updateBaneTime,bane.getCityUUID())){ @@ -386,6 +387,7 @@ public class Contract extends AbstractGameObject { bane.setLiveDate_NEW(bane.getLiveDate().withHourOfDay(12 + updateBaneTime)); } } + bane.setLiveDate(DbManager.BaneQueries.getLiveDate(bane.getCityUUID())); } if (updateBaneCap > 0) { if(DbManager.BaneQueries.SET_BANE_CAP_NEW(updateBaneCap,bane.getCityUUID())){ @@ -394,6 +396,10 @@ public class Contract extends AbstractGameObject { } } + if(bane.timeSet && bane.daySet && bane.capSet){ + bane.getSiegePhase(); + } + return vd; }