|
|
|
@ -88,67 +88,65 @@ public class dbBaneHandler extends dbHandlerBase {
@@ -88,67 +88,65 @@ public class dbBaneHandler extends dbHandlerBase {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean SET_BANE_TIME_NEW(int hour, int cityUUID, DateTime placementDate) { |
|
|
|
|
|
|
|
|
|
DateTime toSet = placementDate.withHourOfDay(12 + hour).withMinuteOfHour(0).withSecondOfMinute(0); |
|
|
|
|
|
|
|
|
|
public boolean SET_BANE_TIME_NEW(int hour, int cityUUID) { |
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=? WHERE `cityUUID`=?")) { |
|
|
|
|
PreparedStatement getStatement = connection.prepareStatement("SELECT `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?"); |
|
|
|
|
PreparedStatement updateStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=?, `time_set`=? WHERE `cityUUID`=?")) { |
|
|
|
|
|
|
|
|
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis())); |
|
|
|
|
preparedStatement.setLong(2, cityUUID); |
|
|
|
|
// Retrieve the existing liveDate
|
|
|
|
|
getStatement.setInt(1, cityUUID); |
|
|
|
|
try (ResultSet rs = getStatement.executeQuery()) { |
|
|
|
|
if (rs.next()) { |
|
|
|
|
DateTime existingDate = new DateTime(rs.getTimestamp("liveDate").getTime()); |
|
|
|
|
// Update only the time
|
|
|
|
|
DateTime updatedDate = existingDate.withHourOfDay(hour).withMinuteOfHour(0).withSecondOfMinute(0); |
|
|
|
|
|
|
|
|
|
preparedStatement.execute(); |
|
|
|
|
// Update liveDate and time_set flag
|
|
|
|
|
updateStatement.setTimestamp(1, new java.sql.Timestamp(updatedDate.getMillis())); |
|
|
|
|
updateStatement.setInt(2, 1); // time_set flag
|
|
|
|
|
updateStatement.setInt(3, cityUUID); |
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
return false; |
|
|
|
|
updateStatement.execute(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `time_set`=? WHERE `cityUUID`=?")) { |
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, 1); |
|
|
|
|
preparedStatement.setLong(2, cityUUID); |
|
|
|
|
|
|
|
|
|
preparedStatement.execute(); |
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean SET_BANE_DAY_NEW(int day, int cityUUID, DateTime placementDate) { |
|
|
|
|
|
|
|
|
|
DateTime toSet = placementDate.plusDays(day); |
|
|
|
|
public boolean SET_BANE_DAY_NEW(int dayOffset, int cityUUID) { |
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=? WHERE `cityUUID`=?")) { |
|
|
|
|
PreparedStatement getStatement = connection.prepareStatement("SELECT `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?"); |
|
|
|
|
PreparedStatement updateStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=?, `day_set`=? WHERE `cityUUID`=?")) { |
|
|
|
|
|
|
|
|
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis())); |
|
|
|
|
preparedStatement.setLong(2, cityUUID); |
|
|
|
|
// Retrieve the existing liveDate
|
|
|
|
|
getStatement.setInt(1, cityUUID); |
|
|
|
|
try (ResultSet rs = getStatement.executeQuery()) { |
|
|
|
|
if (rs.next()) { |
|
|
|
|
DateTime existingDate = new DateTime(rs.getTimestamp("liveDate").getTime()); |
|
|
|
|
// Update only the day
|
|
|
|
|
DateTime updatedDate = existingDate.plusDays(dayOffset); |
|
|
|
|
|
|
|
|
|
preparedStatement.execute(); |
|
|
|
|
// Update liveDate and day_set flag
|
|
|
|
|
updateStatement.setTimestamp(1, new java.sql.Timestamp(updatedDate.getMillis())); |
|
|
|
|
updateStatement.setInt(2, 1); // day_set flag
|
|
|
|
|
updateStatement.setInt(3, cityUUID); |
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
return false; |
|
|
|
|
updateStatement.execute(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `day_set`=? WHERE `cityUUID`=?")) { |
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, 1); |
|
|
|
|
preparedStatement.setLong(2, cityUUID); |
|
|
|
|
|
|
|
|
|
preparedStatement.execute(); |
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean SET_BANE_CAP_NEW(int count, int cityUUID) { |
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|