From 0cf4b5416dc73b6fe63ead753631c3551c701499 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Mar 2024 14:04:08 -0400 Subject: [PATCH] Refactor of signature --- src/engine/db/handlers/dbItemHandler.java | 9 +-- src/engine/objects/Item.java | 68 +++++++++++------------ 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 3b241f74..bc8f5c88 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -364,8 +364,8 @@ public class dbItemHandler extends dbHandlerBase { } //Used to transfer a single item between owners or equip or vault or bank or inventory - public boolean UPDATE_OWNER(final Item item, int newOwnerID, boolean ownerNPC, boolean ownerPlayer, - boolean ownerAccount, ItemContainerType containerType, int slot) { + public boolean UPDATE_OWNER(final Item item, int newOwnerID, + ItemContainerType containerType, Enum.EquipSlotType slot) { boolean worked = false; @@ -399,10 +399,11 @@ public class dbItemHandler extends dbHandlerBase { preparedStatement.setString(3, "none"); //Shouldn't be here break; } - if (item.equipSlot.equals(Enum.EquipSlotType.NONE)) + + if (slot.equals(Enum.EquipSlotType.NONE)) preparedStatement.setString(4, ""); else - preparedStatement.setString(4, item.equipSlot.name()); + preparedStatement.setString(4, slot.name()); ResultSet rs = preparedStatement.executeQuery(); diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 715d34a4..e83bb91e 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -796,7 +796,7 @@ public class Item extends AbstractWorldObject { // Removes all ownership of item and 'orphans' it. protected synchronized void junk() { - DbManager.ItemQueries.UPDATE_OWNER(this, 0, false, false, false, ItemContainerType.NONE, 0); + DbManager.ItemQueries.UPDATE_OWNER(this, 0, ItemContainerType.NONE, EquipSlotType.NONE); this.zeroItem(); //cleanup item from server. @@ -808,11 +808,11 @@ public class Item extends AbstractWorldObject { if (!DbManager.ItemQueries.UPDATE_OWNER(this, pc.getObjectUUID(), //tableID - false, //isNPC - true, //isPlayer - false, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.INVENTORY, - 0)) //Slot + EquipSlotType.NONE)) //Slot return false; this.ownerID = pc.getObjectUUID(); @@ -824,15 +824,15 @@ public class Item extends AbstractWorldObject { protected synchronized boolean moveItemToInventory(NPC npc) { if (npc.isStatic()) { - if (!DbManager.ItemQueries.UPDATE_OWNER(this, 0, false, false, false, ItemContainerType.INVENTORY, 0)) + if (!DbManager.ItemQueries.UPDATE_OWNER(this, 0, ItemContainerType.INVENTORY, EquipSlotType.NONE)) return false; } else if (!DbManager.ItemQueries.UPDATE_OWNER(this, npc.getObjectUUID(), //UUID - true, //isNPC - false, //isPlayer - false, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.INVENTORY, - 0)) //Slot + EquipSlotType.NONE)) //Slot return false; this.zeroItem(); @@ -846,11 +846,11 @@ public class Item extends AbstractWorldObject { protected synchronized boolean moveItemToInventory(Corpse corpse) { if (!DbManager.ItemQueries.UPDATE_OWNER(this, 0, //no ID for corpse - false, //isNPC - true, //isPlayer - false, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.INVENTORY, - 0)) //Slot + EquipSlotType.NONE)) //Slot return false; this.zeroItem(); @@ -864,11 +864,11 @@ public class Item extends AbstractWorldObject { protected synchronized boolean moveItemToBank(PlayerCharacter pc) { if (!DbManager.ItemQueries.UPDATE_OWNER(this, pc.getObjectUUID(), //UUID - false, //isNPC - true, //isPlayer - false, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.BANK, - 0)) //Slot + EquipSlotType.NONE)) //Slot return false; this.zeroItem(); @@ -882,11 +882,11 @@ public class Item extends AbstractWorldObject { protected synchronized boolean moveItemToBank(NPC npc) { if (!DbManager.ItemQueries.UPDATE_OWNER(this, npc.getObjectUUID(), //UUID - true, //isNPC - false, //isPlayer - false, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.BANK, - 0)) //Slot + EquipSlotType.NONE)) //Slot return false; this.zeroItem(); @@ -900,11 +900,11 @@ public class Item extends AbstractWorldObject { protected synchronized boolean moveItemToVault(Account a) { if (!DbManager.ItemQueries.UPDATE_OWNER(this, a.getObjectUUID(), //UUID - false, //isNPC - false, //isPlayer - true, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.VAULT, - 0)) //Slot + EquipSlotType.NONE)) //Slot return false; this.zeroItem(); @@ -919,11 +919,11 @@ public class Item extends AbstractWorldObject { if (!DbManager.ItemQueries.UPDATE_OWNER(this, pc.getObjectUUID(), //tableID - false, //isNPC - true, //isPlayer - false, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.EQUIPPED, - slot.ordinal())) //Slot + slot)) //Slot return false; this.zeroItem(); @@ -937,11 +937,11 @@ public class Item extends AbstractWorldObject { protected synchronized boolean equipItem(NPC npc, Enum.EquipSlotType slot) { if (!DbManager.ItemQueries.UPDATE_OWNER(this, npc.getObjectUUID(), //UUID - true, //isNPC - false, //isPlayer - false, //isAccount + //isNPC + //isPlayer + //isAccount ItemContainerType.EQUIPPED, - slot.ordinal())) //Slot + slot)) //Slot return false; this.zeroItem();