From 6743114d1973f4e507ae1628cb0c46393e3d267b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 31 Dec 2024 16:25:34 -0600 Subject: [PATCH] update bane time first try --- src/engine/db/handlers/dbBaneHandler.java | 33 ++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/engine/db/handlers/dbBaneHandler.java b/src/engine/db/handlers/dbBaneHandler.java index 311304f9..771127d7 100644 --- a/src/engine/db/handlers/dbBaneHandler.java +++ b/src/engine/db/handlers/dbBaneHandler.java @@ -86,7 +86,7 @@ public class dbBaneHandler extends dbHandlerBase { } public boolean SET_BANE_TIME_NEW(int hour, int cityUUID) { - hour += 12; + hour += 12; // Adjust hour try (Connection connection = DbManager.getConnection(); PreparedStatement getStatement = connection.prepareStatement("SELECT `placementDate`, `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?"); PreparedStatement updateStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=?, `time_set`=? WHERE `cityUUID`=?")) { @@ -98,17 +98,20 @@ public class dbBaneHandler extends dbHandlerBase { DateTime placementDate = new DateTime(rs.getTimestamp("placementDate").getTime()); Timestamp liveDateTimestamp = rs.getTimestamp("liveDate"); + // Explicitly check if liveDate is null DateTime toSet; - - if (liveDateTimestamp != null) { - // liveDate is set, adjust its time - DateTime liveDate = new DateTime(liveDateTimestamp.getTime()); - toSet = liveDate.withHourOfDay(hour).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0); + if (liveDateTimestamp == null) { + // If liveDate is null, default to placementDate + toSet = placementDate; } else { - // liveDate is not set, use placementDate with updated time - toSet = placementDate.withHourOfDay(hour).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0); + // If liveDate is not null, use it + DateTime liveDate = new DateTime(liveDateTimestamp.getTime()); + toSet = liveDate; } + // Adjust the time + toSet = toSet.withHourOfDay(hour).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0); + // Update liveDate and time_set flag updateStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis())); updateStatement.setInt(2, 1); // time_set flag @@ -125,7 +128,6 @@ public class dbBaneHandler extends dbHandlerBase { return false; } - public boolean SET_BANE_DAY_NEW(int dayOffset, int cityUUID) { try (Connection connection = DbManager.getConnection(); PreparedStatement getStatement = connection.prepareStatement("SELECT `placementDate`, `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?"); @@ -136,7 +138,17 @@ public class dbBaneHandler extends dbHandlerBase { try (ResultSet rs = getStatement.executeQuery()) { if (rs.next()) { DateTime placementDate = new DateTime(rs.getTimestamp("placementDate").getTime()); - DateTime liveDate = new DateTime(rs.getTimestamp("liveDate").getTime()); + Timestamp liveDateTimestamp = rs.getTimestamp("liveDate"); + + // Explicitly check if liveDate is null + DateTime liveDate; + if (liveDateTimestamp == null) { + // If liveDate is null, default to placementDate + liveDate = placementDate; + } else { + // If liveDate is not null, use it + liveDate = new DateTime(liveDateTimestamp.getTime()); + } // Calculate the new liveDate while preserving the time component DateTime updatedDate = placementDate.plusDays(dayOffset) @@ -163,6 +175,7 @@ public class dbBaneHandler extends dbHandlerBase { + public boolean SET_BANE_CAP_NEW(int count, int cityUUID) { try (Connection connection = DbManager.getConnection();