bane commander NPC
This commit is contained in:
@@ -88,67 +88,65 @@ public class dbBaneHandler extends dbHandlerBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean SET_BANE_TIME_NEW(int hour, int cityUUID, DateTime placementDate) {
|
public boolean SET_BANE_TIME_NEW(int hour, int cityUUID) {
|
||||||
|
|
||||||
DateTime toSet = placementDate.withHourOfDay(12 + hour).withMinuteOfHour(0).withSecondOfMinute(0);
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
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()));
|
// Retrieve the existing liveDate
|
||||||
preparedStatement.setLong(2, cityUUID);
|
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);
|
||||||
|
|
||||||
|
updateStatement.execute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
try (Connection connection = DbManager.getConnection();
|
return false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean SET_BANE_DAY_NEW(int day, int cityUUID, DateTime placementDate) {
|
public boolean SET_BANE_DAY_NEW(int dayOffset, int cityUUID) {
|
||||||
|
|
||||||
DateTime toSet = placementDate.plusDays(day);
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
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()));
|
// Retrieve the existing liveDate
|
||||||
preparedStatement.setLong(2, cityUUID);
|
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);
|
||||||
|
|
||||||
|
updateStatement.execute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
try (Connection connection = DbManager.getConnection();
|
return false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean SET_BANE_CAP_NEW(int count, int cityUUID) {
|
public boolean SET_BANE_CAP_NEW(int count, int cityUUID) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ public class Contract extends AbstractGameObject {
|
|||||||
if(bane == null){
|
if(bane == null){
|
||||||
return VendorDialog.getHostileVendorDialog();
|
return VendorDialog.getHostileVendorDialog();
|
||||||
}
|
}
|
||||||
|
if(bane.timeSet && bane.capSet && bane.daySet){
|
||||||
|
vd.getOptions().clear();
|
||||||
|
return vd;
|
||||||
|
}
|
||||||
DateTime placement = bane.getPlacementDate();
|
DateTime placement = bane.getPlacementDate();
|
||||||
switch(optionId){
|
switch(optionId){
|
||||||
default:
|
default:
|
||||||
@@ -345,12 +349,12 @@ public class Contract extends AbstractGameObject {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (updateBaneDay > 0) {
|
if (updateBaneDay > 0) {
|
||||||
if(DbManager.BaneQueries.SET_BANE_DAY_NEW(updateBaneDay,bane.getCityUUID(), bane.getPlacementDate())){
|
if(DbManager.BaneQueries.SET_BANE_DAY_NEW(updateBaneDay,bane.getCityUUID())){
|
||||||
bane.daySet = true;
|
bane.daySet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updateBaneTime > 0) {
|
if (updateBaneTime > 0) {
|
||||||
if(DbManager.BaneQueries.SET_BANE_TIME_NEW(updateBaneDay,bane.getCityUUID(), bane.getPlacementDate())){
|
if(DbManager.BaneQueries.SET_BANE_TIME_NEW(updateBaneDay,bane.getCityUUID())){
|
||||||
bane.timeSet = true;
|
bane.timeSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user