From 57ff1ede971950e9d715e6af37ad85eb64ee8016 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 4 Sep 2023 14:16:36 -0400 Subject: [PATCH] Name is all that's needed. --- src/engine/db/handlers/dbMobHandler.java | 15 ++++++--------- .../client/handlers/MinionTrainingMsgHandler.java | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 08a1e6e6..962a1cb6 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -127,15 +127,13 @@ public class dbMobHandler extends dbHandlerBase { } } - public boolean ADD_TO_GUARDS(final long captainUID, final int mobBaseID, final String name, final int slot) { + public boolean ADD_TO_GUARDS(final long captainUID, final String name) { try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `mobBaseID`,`name`, `slot`) VALUES (?,?,?,?)")) { + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `name`) VALUES (?,?)")) { preparedStatement.setLong(1, captainUID); - preparedStatement.setInt(2, mobBaseID); - preparedStatement.setString(3, name); - preparedStatement.setInt(4, slot); + preparedStatement.setString(2, name); return (preparedStatement.executeUpdate() > 0); @@ -145,14 +143,13 @@ public class dbMobHandler extends dbHandlerBase { } } - public boolean REMOVE_FROM_GUARDS(final long captainUID, final int mobBaseID, final int slot) { + public boolean REMOVE_FROM_GUARDS(final long captainUID, final String minionName) { try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `mobBaseID`=? AND `slot` =?")) { + PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `minionName`=? LIMIT 1;")) { preparedStatement.setLong(1, captainUID); - preparedStatement.setInt(2, mobBaseID); - preparedStatement.setInt(3, slot); + preparedStatement.setString(2, minionName); return (preparedStatement.executeUpdate() > 0); diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index 8d4f62f9..0d24d133 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.getSiegeMinionMap().containsKey(toRemove)) return true; - if (!DbManager.MobQueries.REMOVE_FROM_GUARDS(npc.getObjectUUID(), toRemove.getMobBaseID(), npc.getSiegeMinionMap().get(toRemove))) + if (!DbManager.MobQueries.REMOVE_FROM_GUARDS(npc.getObjectUUID(), toRemove.firstName)) return true; npc.getSiegeMinionMap().remove(toRemove); @@ -273,7 +273,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (toCreate == null) return true; - if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size())) + if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), pirateName)) return true; if (toCreate != null) {