diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index f3f5a0ad..862ac29f 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -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 { } } - 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 { } } + 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 GET_ALL_MOBS_FOR_ZONE(Zone zone) { diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index fda1da21..fc84fe56 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -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 { 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) {