diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index 9f4489b5..f762f16b 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -202,12 +202,23 @@ public class dbNPCHandler extends dbHandlerBase { return result; } + public static void updateSpecialPricing(final NPC npc){ + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET specialPrice=? WHERE UID = ?")) { + preparedStatement.setInt(1, npc.getSpecialPrice()); + + preparedStatement.executeUpdate(); + + } catch (SQLException e) { + Logger.error(e); + } + } public void updateDatabase(final NPC npc) { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET npc_name=?, npc_contractID=?, npc_typeID=?, npc_guildID=?," + " npc_spawnX=?, npc_spawnY=?, npc_spawnZ=?, npc_level=? ," - + " npc_buyPercent=?, npc_sellPercent=?, npc_buildingID=?, specialPrice=? WHERE UID = ?")) { + + " npc_buyPercent=?, npc_sellPercent=?, npc_buildingID=? WHERE UID = ?")) { preparedStatement.setString(1, npc.getName()); preparedStatement.setInt(2, (npc.getContract() != null) ? npc.getContract().getObjectUUID() : 0); @@ -221,7 +232,6 @@ public class dbNPCHandler extends dbHandlerBase { preparedStatement.setFloat(10, npc.getSellPercent()); preparedStatement.setInt(11, (npc.getBuilding() != null) ? npc.getBuilding().getObjectUUID() : 0); preparedStatement.setInt(12, npc.getDBID()); - preparedStatement.setInt(13, npc.getSpecialPrice()); preparedStatement.executeUpdate(); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 853979f4..772347f4 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -804,7 +804,7 @@ public class NPC extends AbstractCharacter { @Override public void updateDatabase() { - DbManager.NPCQueries.updateDatabase(this); + DbManager.NPCQueries.updateSpecialPricing(this); } public int getSymbol() {