Browse Source

db method to support removing all minions

combat-2
MagicBot 1 year ago
parent
commit
b7a907c8c8
  1. 18
      src/engine/db/handlers/dbMobHandler.java
  2. 4
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java

18
src/engine/db/handlers/dbMobHandler.java

@ -127,7 +127,7 @@ public class dbMobHandler extends dbHandlerBase { @@ -127,7 +127,7 @@ public class dbMobHandler extends dbHandlerBase {
}
}
public boolean ADD_TO_GUARDS(final long captainUID, final String minionName) {
public boolean ADD_GUARD_MINION(final long captainUID, final String minionName) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `minionName`) VALUES (?,?)")) {
@ -143,7 +143,7 @@ public class dbMobHandler extends dbHandlerBase { @@ -143,7 +143,7 @@ public class dbMobHandler extends dbHandlerBase {
}
}
public boolean REMOVE_FROM_GUARDS(final long captainUID, final String minionName) {
public boolean REMOVE_GUARD_MINION(final long captainUID, final String minionName) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `minionName`=? LIMIT 1;")) {
@ -159,6 +159,20 @@ public class dbMobHandler extends dbHandlerBase { @@ -159,6 +159,20 @@ public class dbMobHandler extends dbHandlerBase {
}
}
public boolean REMOVE_ALL_MINIONS(final long captainUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=?;")) {
preparedStatement.setLong(1, captainUID);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
return false;
}
}
public ArrayList<Mob> GET_ALL_MOBS_FOR_ZONE(Zone zone) {

4
src/engine/net/client/handlers/MinionTrainingMsgHandler.java

@ -182,7 +182,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -182,7 +182,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (!npc.minions.contains(toRemove.getObjectUUID()))
return true;
if (!DbManager.MobQueries.REMOVE_FROM_GUARDS(npc.getObjectUUID(), toRemove.firstName))
if (!DbManager.MobQueries.REMOVE_GUARD_MINION(npc.getObjectUUID(), toRemove.firstName))
return true;
npc.minions.remove(Integer.valueOf(toRemove.getObjectUUID()));
@ -273,7 +273,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -273,7 +273,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (toCreate == null)
return true;
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), pirateName))
if (!DbManager.MobQueries.ADD_GUARD_MINION(npc.getObjectUUID(), pirateName))
return true;
if (toCreate != null) {

Loading…
Cancel
Save