Browse Source

bane commander NPC

lakebane2
FatBoy-DOTC 3 weeks ago
parent
commit
c5f47ffcd4
  1. 103
      src/engine/db/handlers/dbBaneHandler.java
  2. 10
      src/engine/objects/Bane.java
  3. 41
      src/engine/objects/Contract.java

103
src/engine/db/handlers/dbBaneHandler.java

@ -88,6 +88,109 @@ public class dbBaneHandler extends dbHandlerBase { @@ -88,6 +88,109 @@ 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);
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=? WHERE `cityUUID`=?")) {
preparedStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis()));
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
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;
}
public boolean SET_BANE_DAY_NEW(int day, int cityUUID, DateTime placementDate) {
DateTime toSet = placementDate.plusDays(day);
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=? WHERE `cityUUID`=?")) {
preparedStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis()));
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
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;
}
public boolean SET_BANE_CAP_NEW(int count, int cityUUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_size`=? WHERE `cityUUID`=?")) {
preparedStatement.setInt(1, count);
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_set`=? WHERE `cityUUID`=?")) {
preparedStatement.setInt(1, 1);
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_size`=? WHERE `cityUUID`=?")) {
preparedStatement.setInt(1, count);
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
} catch (SQLException e) {
Logger.error(e);
return false;
}
return true;
}
public boolean REMOVE_BANE(Bane bane) {
if (bane == null)

10
src/engine/objects/Bane.java

@ -46,6 +46,10 @@ public final class Bane { @@ -46,6 +46,10 @@ public final class Bane {
private DateTime placementDate = null;
private DateTime liveDate = null;
private BaneDefaultTimeJob defaultTimeJob;
public boolean timeSet = false;
public boolean daySet = false;
public boolean capSet = false;
public int capSize = 10;
// Internal cache for banes
private ActivateBaneJob activateBaneJob;
@ -62,6 +66,12 @@ public final class Bane { @@ -62,6 +66,12 @@ public final class Bane {
this.ownerUUID = rs.getInt("ownerUUID");
this.stoneUUID = rs.getInt("stoneUUID");
this.timeSet = rs.getInt("time_set") == 1;
this.daySet = rs.getInt("day_set") == 1;
this.capSet = rs.getInt("cap_set") == 1;
this.capSize = rs.getInt("cap_size");
sqlDateTime = rs.getTimestamp("placementDate");
if (sqlDateTime != null)

41
src/engine/objects/Contract.java

@ -199,6 +199,9 @@ public class Contract extends AbstractGameObject { @@ -199,6 +199,9 @@ public class Contract extends AbstractGameObject {
vd.getOptions().clear();
Building building = npc.building;
Bane bane = null;
int updateBaneTime = 0;
int updateBaneDay = 0;
int updateBaneCap = 0;
if(building != null)
{
City city = ZoneManager.getCityAtLocation(npc.loc);
@ -212,12 +215,18 @@ public class Contract extends AbstractGameObject { @@ -212,12 +215,18 @@ public class Contract extends AbstractGameObject {
DateTime placement = bane.getPlacementDate();
switch(optionId){
default:
if(!bane.daySet) {
MenuOption option1 = new MenuOption(796, "Set Bane Day", 796);
vd.getOptions().add(option1);
}
if(!bane.timeSet) {
MenuOption option2 = new MenuOption(797, "Set Bane Time", 797);
vd.getOptions().add(option2);
}
if(!bane.capSet) {
MenuOption option3 = new MenuOption(797, "Set Bane Cap", 798);
vd.getOptions().add(option3);
}
break;
case 796: // set bane day
DateTime dayOption1Date = placement.plusDays(3);
@ -276,50 +285,82 @@ public class Contract extends AbstractGameObject { @@ -276,50 +285,82 @@ public class Contract extends AbstractGameObject {
case 7961: //3 days after placement
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set 3 Days From Placement Date");
updateBaneDay = 3;
break;
case 7962: //4 days after placement
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set 4 Days From Placement Date");
updateBaneDay = 4;
break;
case 7963: //5 days after placement
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set 5 Days From Placement Date");
updateBaneDay = 5;
break;
case 7964: //6 days after placement
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set 6 Days From Placement Date");
updateBaneDay = 6;
break;
case 7965: //7 days after placement
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set 7 Days From Placement Date");
updateBaneDay = 7;
break;
case 7971: //6:00pm CST
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set For 6:00 pm CST");
updateBaneTime = 6;
break;
case 7972: //7:00pm CST
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set For 7:00 pm CST");
updateBaneTime = 7;
break;
case 7973: //8:00pm CST
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set For 8:00 pm CST");
updateBaneTime = 8;
break;
case 7974: //9:00pm CST
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set For 9:00 pm CST");
updateBaneTime = 9;
break;
case 7975: //10:00pm CST
ErrorPopupMsg.sendErrorMsg(pc, "Bane Set For 10:00 pm CST");
updateBaneTime = 10;
break;
case 7981: //cap = 10
ErrorPopupMsg.sendErrorMsg(pc, "Bane Cap Set To 10 Players On Each Side");
updateBaneCap = 10;
break;
case 7982: //cap = 20
ErrorPopupMsg.sendErrorMsg(pc, "Bane Cap Set To 20 Players On Each Side");
updateBaneCap = 20;
break;
case 7983: //cap = 30
ErrorPopupMsg.sendErrorMsg(pc, "Bane Cap Set To 30 Players On Each Side");
updateBaneCap = 30;
break;
case 7984: //cap = 40
ErrorPopupMsg.sendErrorMsg(pc, "Bane Cap Set To 40 Players On Each Side");
updateBaneCap = 40;
break;
case 7985: //cap = Unlimited
ErrorPopupMsg.sendErrorMsg(pc, "Bane Cap Set To Unlimited Players On Each Side");
updateBaneCap = 9999;
break;
}
if (updateBaneDay > 0) {
if(DbManager.BaneQueries.SET_BANE_DAY_NEW(updateBaneDay,bane.getCityUUID(), bane.getPlacementDate())){
bane.daySet = true;
}
}
if (updateBaneTime > 0) {
if(DbManager.BaneQueries.SET_BANE_TIME_NEW(updateBaneDay,bane.getCityUUID(), bane.getPlacementDate())){
bane.timeSet = true;
}
}
if (updateBaneCap > 0) {
if(DbManager.BaneQueries.SET_BANE_CAP_NEW(updateBaneCap,bane.getCityUUID())){
bane.capSet = true;
bane.capSize = updateBaneCap;
}
}
return vd;
}

Loading…
Cancel
Save