Browse Source

Refactor of signature

combat-2
MagicBot 8 months ago
parent
commit
0cf4b5416d
  1. 9
      src/engine/db/handlers/dbItemHandler.java
  2. 68
      src/engine/objects/Item.java

9
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 //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, public boolean UPDATE_OWNER(final Item item, int newOwnerID,
boolean ownerAccount, ItemContainerType containerType, int slot) { ItemContainerType containerType, Enum.EquipSlotType slot) {
boolean worked = false; boolean worked = false;
@ -399,10 +399,11 @@ public class dbItemHandler extends dbHandlerBase {
preparedStatement.setString(3, "none"); //Shouldn't be here preparedStatement.setString(3, "none"); //Shouldn't be here
break; break;
} }
if (item.equipSlot.equals(Enum.EquipSlotType.NONE))
if (slot.equals(Enum.EquipSlotType.NONE))
preparedStatement.setString(4, ""); preparedStatement.setString(4, "");
else else
preparedStatement.setString(4, item.equipSlot.name()); preparedStatement.setString(4, slot.name());
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();

68
src/engine/objects/Item.java

@ -796,7 +796,7 @@ public class Item extends AbstractWorldObject {
// Removes all ownership of item and 'orphans' it. // Removes all ownership of item and 'orphans' it.
protected synchronized void junk() { 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(); this.zeroItem();
//cleanup item from server. //cleanup item from server.
@ -808,11 +808,11 @@ public class Item extends AbstractWorldObject {
if (!DbManager.ItemQueries.UPDATE_OWNER(this, if (!DbManager.ItemQueries.UPDATE_OWNER(this,
pc.getObjectUUID(), //tableID pc.getObjectUUID(), //tableID
false, //isNPC //isNPC
true, //isPlayer //isPlayer
false, //isAccount //isAccount
ItemContainerType.INVENTORY, ItemContainerType.INVENTORY,
0)) //Slot EquipSlotType.NONE)) //Slot
return false; return false;
this.ownerID = pc.getObjectUUID(); this.ownerID = pc.getObjectUUID();
@ -824,15 +824,15 @@ public class Item extends AbstractWorldObject {
protected synchronized boolean moveItemToInventory(NPC npc) { protected synchronized boolean moveItemToInventory(NPC npc) {
if (npc.isStatic()) { 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; return false;
} else if (!DbManager.ItemQueries.UPDATE_OWNER(this, } else if (!DbManager.ItemQueries.UPDATE_OWNER(this,
npc.getObjectUUID(), //UUID npc.getObjectUUID(), //UUID
true, //isNPC //isNPC
false, //isPlayer //isPlayer
false, //isAccount //isAccount
ItemContainerType.INVENTORY, ItemContainerType.INVENTORY,
0)) //Slot EquipSlotType.NONE)) //Slot
return false; return false;
this.zeroItem(); this.zeroItem();
@ -846,11 +846,11 @@ public class Item extends AbstractWorldObject {
protected synchronized boolean moveItemToInventory(Corpse corpse) { protected synchronized boolean moveItemToInventory(Corpse corpse) {
if (!DbManager.ItemQueries.UPDATE_OWNER(this, if (!DbManager.ItemQueries.UPDATE_OWNER(this,
0, //no ID for corpse 0, //no ID for corpse
false, //isNPC //isNPC
true, //isPlayer //isPlayer
false, //isAccount //isAccount
ItemContainerType.INVENTORY, ItemContainerType.INVENTORY,
0)) //Slot EquipSlotType.NONE)) //Slot
return false; return false;
this.zeroItem(); this.zeroItem();
@ -864,11 +864,11 @@ public class Item extends AbstractWorldObject {
protected synchronized boolean moveItemToBank(PlayerCharacter pc) { protected synchronized boolean moveItemToBank(PlayerCharacter pc) {
if (!DbManager.ItemQueries.UPDATE_OWNER(this, if (!DbManager.ItemQueries.UPDATE_OWNER(this,
pc.getObjectUUID(), //UUID pc.getObjectUUID(), //UUID
false, //isNPC //isNPC
true, //isPlayer //isPlayer
false, //isAccount //isAccount
ItemContainerType.BANK, ItemContainerType.BANK,
0)) //Slot EquipSlotType.NONE)) //Slot
return false; return false;
this.zeroItem(); this.zeroItem();
@ -882,11 +882,11 @@ public class Item extends AbstractWorldObject {
protected synchronized boolean moveItemToBank(NPC npc) { protected synchronized boolean moveItemToBank(NPC npc) {
if (!DbManager.ItemQueries.UPDATE_OWNER(this, if (!DbManager.ItemQueries.UPDATE_OWNER(this,
npc.getObjectUUID(), //UUID npc.getObjectUUID(), //UUID
true, //isNPC //isNPC
false, //isPlayer //isPlayer
false, //isAccount //isAccount
ItemContainerType.BANK, ItemContainerType.BANK,
0)) //Slot EquipSlotType.NONE)) //Slot
return false; return false;
this.zeroItem(); this.zeroItem();
@ -900,11 +900,11 @@ public class Item extends AbstractWorldObject {
protected synchronized boolean moveItemToVault(Account a) { protected synchronized boolean moveItemToVault(Account a) {
if (!DbManager.ItemQueries.UPDATE_OWNER(this, if (!DbManager.ItemQueries.UPDATE_OWNER(this,
a.getObjectUUID(), //UUID a.getObjectUUID(), //UUID
false, //isNPC //isNPC
false, //isPlayer //isPlayer
true, //isAccount //isAccount
ItemContainerType.VAULT, ItemContainerType.VAULT,
0)) //Slot EquipSlotType.NONE)) //Slot
return false; return false;
this.zeroItem(); this.zeroItem();
@ -919,11 +919,11 @@ public class Item extends AbstractWorldObject {
if (!DbManager.ItemQueries.UPDATE_OWNER(this, if (!DbManager.ItemQueries.UPDATE_OWNER(this,
pc.getObjectUUID(), //tableID pc.getObjectUUID(), //tableID
false, //isNPC //isNPC
true, //isPlayer //isPlayer
false, //isAccount //isAccount
ItemContainerType.EQUIPPED, ItemContainerType.EQUIPPED,
slot.ordinal())) //Slot slot)) //Slot
return false; return false;
this.zeroItem(); this.zeroItem();
@ -937,11 +937,11 @@ public class Item extends AbstractWorldObject {
protected synchronized boolean equipItem(NPC npc, Enum.EquipSlotType slot) { protected synchronized boolean equipItem(NPC npc, Enum.EquipSlotType slot) {
if (!DbManager.ItemQueries.UPDATE_OWNER(this, if (!DbManager.ItemQueries.UPDATE_OWNER(this,
npc.getObjectUUID(), //UUID npc.getObjectUUID(), //UUID
true, //isNPC //isNPC
false, //isPlayer //isPlayer
false, //isAccount //isAccount
ItemContainerType.EQUIPPED, ItemContainerType.EQUIPPED,
slot.ordinal())) //Slot slot)) //Slot
return false; return false;
this.zeroItem(); this.zeroItem();

Loading…
Cancel
Save