Browse Source

Name is all that's needed.

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

15
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(); 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.setLong(1, captainUID);
preparedStatement.setInt(2, mobBaseID); preparedStatement.setString(2, name);
preparedStatement.setString(3, name);
preparedStatement.setInt(4, slot);
return (preparedStatement.executeUpdate() > 0); 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(); 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.setLong(1, captainUID);
preparedStatement.setInt(2, mobBaseID); preparedStatement.setString(2, minionName);
preparedStatement.setInt(3, slot);
return (preparedStatement.executeUpdate() > 0); return (preparedStatement.executeUpdate() > 0);

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

@ -182,7 +182,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (!npc.getSiegeMinionMap().containsKey(toRemove)) if (!npc.getSiegeMinionMap().containsKey(toRemove))
return true; 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; return true;
npc.getSiegeMinionMap().remove(toRemove); npc.getSiegeMinionMap().remove(toRemove);
@ -273,7 +273,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (toCreate == null) if (toCreate == null)
return true; 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; return true;
if (toCreate != null) { if (toCreate != null) {

Loading…
Cancel
Save