From ec90ef6174c604ecd1001cdc749d838992a7c92f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 2 Mar 2024 09:55:30 -0500 Subject: [PATCH] items PERSIST work. --- src/engine/db/handlers/dbItemHandler.java | 2 +- src/engine/devcmd/cmds/MakeItemCmd.java | 4 +-- src/engine/gameManager/BuildingManager.java | 2 +- .../client/handlers/OrderNPCMsgHandler.java | 2 +- src/engine/objects/Item.java | 34 ++++--------------- src/engine/objects/ItemFactory.java | 2 +- src/engine/objects/Kit.java | 2 +- src/engine/objects/MobLoot.java | 4 +-- src/engine/objects/PlayerCharacter.java | 4 +-- src/engine/objects/Warehouse.java | 4 +-- 10 files changed, 19 insertions(+), 41 deletions(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index f7d4723e..0284a984 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -55,7 +55,7 @@ public class dbItemHandler extends dbHandlerBase { return ret; } - public Item ADD_ITEM(Item toAdd) { + public Item PERSIST(Item toAdd) { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) { diff --git a/src/engine/devcmd/cmds/MakeItemCmd.java b/src/engine/devcmd/cmds/MakeItemCmd.java index eedc72e8..61e7a6da 100644 --- a/src/engine/devcmd/cmds/MakeItemCmd.java +++ b/src/engine/devcmd/cmds/MakeItemCmd.java @@ -57,7 +57,7 @@ public class MakeItemCmd extends AbstractDevCmd { item.setNumOfItems(Warehouse.getMaxResources().get(ibID)); try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); worked = true; } catch (Exception e) { throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage()); @@ -214,7 +214,7 @@ public class MakeItemCmd extends AbstractDevCmd { item.setNumOfItems(numItems); try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); worked = true; } catch (Exception e) { throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage()); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index f50d8550..01fceac3 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -833,7 +833,7 @@ public enum BuildingManager { item.containerType = Enum.ItemContainerType.INVENTORY; try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); itemWorked = true; } catch (Exception e) { Logger.error(e); diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index c7414459..08592353 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -73,7 +73,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { item.containerType = Enum.ItemContainerType.INVENTORY; try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); itemWorked = true; } catch (Exception e) { Logger.error(e); diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 23b48369..86db5e4c 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -52,7 +52,6 @@ public class Item extends AbstractWorldObject { public int chargesRemaining; private byte equipSlot; private boolean canDestroy; - private boolean rentable; private boolean isRandom = false; private int value; public OwnerType ownerType; @@ -101,7 +100,6 @@ public class Item extends AbstractWorldObject { this.durabilityCurrent = (short) itemBase.getDurability(); this.containerType = containerType; this.canDestroy = canDestroy; - this.rentable = rentable; this.equipSlot = equipSlot; this.enchants = enchants; this.flags = 1; @@ -134,7 +132,6 @@ public class Item extends AbstractWorldObject { this.durabilityMax = (short) itemBase.getDurability(); this.durabilityCurrent = (short) itemBase.getDurability(); this.canDestroy = canDestroy; - this.rentable = rentable; this.equipSlot = equipSlot; this.enchants = enchants; this.flags = 1; @@ -433,7 +430,7 @@ public class Item extends AbstractWorldObject { item.containerType = Enum.ItemContainerType.INVENTORY; try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); itemWorked = true; } catch (Exception e) { Logger.error(e); @@ -604,7 +601,7 @@ public class Item extends AbstractWorldObject { true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, new ArrayList<>(), ""); try { - item = DbManager.ItemQueries.ADD_ITEM(temp); + item = DbManager.ItemQueries.PERSIST(temp); } catch (Exception e) { Logger.error(e); } @@ -624,7 +621,7 @@ public class Item extends AbstractWorldObject { true, false, Enum.ItemContainerType.BANK, (byte) 0, new ArrayList<>(), ""); try { - item = DbManager.ItemQueries.ADD_ITEM(temp); + item = DbManager.ItemQueries.PERSIST(temp); } catch (Exception e) { } return item; @@ -642,7 +639,7 @@ public class Item extends AbstractWorldObject { true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, new ArrayList<>(), ""); try { - item = DbManager.ItemQueries.ADD_ITEM(temp); + item = DbManager.ItemQueries.PERSIST(temp); } catch (Exception e) { Logger.error(e); } @@ -681,7 +678,7 @@ public class Item extends AbstractWorldObject { if (persist) { try { - newGold = DbManager.ItemQueries.ADD_ITEM(newGold); + newGold = DbManager.ItemQueries.PERSIST(newGold); if (newGold != null) { synchronized (newGold) { newGold.numberOfItems = 0; @@ -742,7 +739,7 @@ public class Item extends AbstractWorldObject { if (persist) { try { - newGold = DbManager.ItemQueries.ADD_ITEM(newGold); + newGold = DbManager.ItemQueries.PERSIST(newGold); if (newGold != null) { synchronized (newGold) { newGold.numberOfItems = 0; @@ -834,18 +831,6 @@ public class Item extends AbstractWorldObject { return true; } - public boolean isOwnerNPC() { - return (ownerType == OwnerType.Npc); - } - - public boolean isOwnerCharacter() { - return (ownerType == OwnerType.PlayerCharacter); - } - - public boolean isOwnerAccount() { - return (ownerType == OwnerType.Account); - } - public byte getChargesMax() { return chargesMax; } @@ -862,17 +847,10 @@ public class Item extends AbstractWorldObject { return canDestroy; } - public boolean isRentable() { - return rentable; - } - public byte getEquipSlot() { return equipSlot; } - public ArrayList getEnchants() { - return enchants; - } public int getNumOfItems() { return this.numberOfItems; diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index feb75198..5360c5b9 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -61,7 +61,7 @@ public class ItemFactory { (short) 1, (short) 1, true, false, ItemContainerType.INVENTORY, (byte) 0, new ArrayList<>(), ""); try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); worked = true; } catch (Exception e) { Logger.error(e); diff --git a/src/engine/objects/Kit.java b/src/engine/objects/Kit.java index b44c4d86..3ec8354e 100644 --- a/src/engine/objects/Kit.java +++ b/src/engine/objects/Kit.java @@ -120,7 +120,7 @@ public class Kit extends AbstractGameObject { new ArrayList<>(), ""); try { - temp = DbManager.ItemQueries.ADD_ITEM(temp); + temp = DbManager.ItemQueries.PERSIST(temp); } catch (Exception e) { Logger.error(e); } diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index 235eccd1..f71c2fb7 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -149,7 +149,7 @@ public final class MobLoot extends Item { item.setNumOfItems(this.getNumOfItems()); try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); } catch (Exception e) { Logger.error("e"); return null; @@ -187,7 +187,7 @@ public final class MobLoot extends Item { item.setNumOfItems(this.getNumOfItems()); try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); } catch (Exception e) { Logger.error(e); return null; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index d9a47fde..0c7d722a 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1198,7 +1198,7 @@ public class PlayerCharacter extends AbstractCharacter { Item hair; try { - hair = DbManager.ItemQueries.ADD_ITEM(tempHair); + hair = DbManager.ItemQueries.PERSIST(tempHair); } catch (Exception e) { hair = null; } @@ -1218,7 +1218,7 @@ public class PlayerCharacter extends AbstractCharacter { (byte) MBServerStatics.SLOT_BEARDSTYLE, new ArrayList<>(), ""); Item beard; try { - beard = DbManager.ItemQueries.ADD_ITEM(tempBeard); + beard = DbManager.ItemQueries.PERSIST(tempBeard); } catch (Exception e) { beard = null; } diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 2eb2663c..5b0c8e0f 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -760,7 +760,7 @@ public class Warehouse extends AbstractWorldObject { item.containerType = Enum.ItemContainerType.INVENTORY; try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); itemWorked = true; } catch (Exception e) { Logger.error(e); @@ -836,7 +836,7 @@ public class Warehouse extends AbstractWorldObject { item.containerType = Enum.ItemContainerType.INVENTORY; try { - item = DbManager.ItemQueries.ADD_ITEM(item); + item = DbManager.ItemQueries.PERSIST(item); itemWorked = true; } catch (Exception e) { Logger.error(e);