|
|
|
@ -57,7 +57,6 @@ public class Item extends AbstractWorldObject {
@@ -57,7 +57,6 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
public OwnerType ownerType; |
|
|
|
|
public int templsteID; |
|
|
|
|
private AbstractWorldObject lastOwner; |
|
|
|
|
private ArrayList<EnchantmentBase> enchants = new ArrayList<>(); |
|
|
|
|
private long dateToUpgrade; |
|
|
|
|
private String customName = ""; |
|
|
|
|
private int magicValue; |
|
|
|
@ -73,7 +72,7 @@ public class Item extends AbstractWorldObject {
@@ -73,7 +72,7 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
this.template = ItemTemplate.itemTemplates.get(templateID); |
|
|
|
|
this.chargesRemaining = this.template.item_initial_charges; |
|
|
|
|
this.durabilityCurrent = this.template.combat_health_full; |
|
|
|
|
|
|
|
|
|
this.equipSlot = 0; |
|
|
|
|
loadEnchantments(); |
|
|
|
|
bakeInStats(); |
|
|
|
|
} |
|
|
|
@ -82,7 +81,7 @@ public class Item extends AbstractWorldObject {
@@ -82,7 +81,7 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
OwnerType ownerType, byte chargesMax, byte chargesRemaining, |
|
|
|
|
short durabilityCurrent, short durabilityMax, boolean canDestroy, |
|
|
|
|
boolean rentable, Enum.ItemContainerType containerType, byte equipSlot, |
|
|
|
|
ArrayList<EnchantmentBase> enchants, String name) { |
|
|
|
|
String name) { |
|
|
|
|
super(); |
|
|
|
|
this.templsteID = itemBase.getUUID(); |
|
|
|
|
this.ownerID = ownerID; |
|
|
|
@ -101,7 +100,6 @@ public class Item extends AbstractWorldObject {
@@ -101,7 +100,6 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
this.containerType = containerType; |
|
|
|
|
this.canDestroy = canDestroy; |
|
|
|
|
this.equipSlot = equipSlot; |
|
|
|
|
this.enchants = enchants; |
|
|
|
|
this.flags = 1; |
|
|
|
|
this.value = this.magicValue; |
|
|
|
|
this.customName = name; |
|
|
|
@ -133,7 +131,6 @@ public class Item extends AbstractWorldObject {
@@ -133,7 +131,6 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
this.durabilityCurrent = (short) itemBase.getDurability(); |
|
|
|
|
this.canDestroy = canDestroy; |
|
|
|
|
this.equipSlot = equipSlot; |
|
|
|
|
this.enchants = enchants; |
|
|
|
|
this.flags = 1; |
|
|
|
|
this.value = this.magicValue; |
|
|
|
|
|
|
|
|
@ -420,14 +417,12 @@ public class Item extends AbstractWorldObject {
@@ -420,14 +417,12 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
|
|
|
|
|
boolean itemWorked = false; |
|
|
|
|
|
|
|
|
|
Item item = new Item(toCreate, reciever.getObjectUUID(), OwnerType.PlayerCharacter, (byte) 0, (byte) 0, |
|
|
|
|
(short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, |
|
|
|
|
new ArrayList<>(), ""); |
|
|
|
|
Item item = new Item(toCreate.getUUID()); |
|
|
|
|
|
|
|
|
|
synchronized (item) { |
|
|
|
|
item.numberOfItems = amount; |
|
|
|
|
} |
|
|
|
|
item.ownerID = reciever.getObjectUUID(); |
|
|
|
|
item.ownerType = OwnerType.PlayerCharacter; |
|
|
|
|
item.containerType = Enum.ItemContainerType.INVENTORY; |
|
|
|
|
item.numberOfItems = amount; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
item = DbManager.ItemQueries.PERSIST(item); |
|
|
|
@ -589,57 +584,13 @@ public class Item extends AbstractWorldObject {
@@ -589,57 +584,13 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Item createItemForPlayer(PlayerCharacter pc, ItemBase ib) { |
|
|
|
|
Item item = null; |
|
|
|
|
byte charges = 0; |
|
|
|
|
|
|
|
|
|
charges = (byte) ib.getNumCharges(); |
|
|
|
|
|
|
|
|
|
short durability = (short) ib.getDurability(); |
|
|
|
|
|
|
|
|
|
Item temp = new Item(ib, pc.getObjectUUID(), |
|
|
|
|
OwnerType.PlayerCharacter, charges, charges, durability, durability, |
|
|
|
|
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, |
|
|
|
|
new ArrayList<>(), ""); |
|
|
|
|
try { |
|
|
|
|
item = DbManager.ItemQueries.PERSIST(temp); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
} |
|
|
|
|
return item; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Item createItemForPlayerBank(PlayerCharacter pc, ItemBase ib) { |
|
|
|
|
Item item = null; |
|
|
|
|
byte charges = 0; |
|
|
|
|
|
|
|
|
|
charges = (byte) ib.getNumCharges(); |
|
|
|
|
|
|
|
|
|
short durability = (short) ib.getDurability(); |
|
|
|
|
Item item = new Item(ib.getUUID()); |
|
|
|
|
item.ownerID = pc.getObjectUUID(); |
|
|
|
|
item.ownerType = OwnerType.PlayerCharacter; |
|
|
|
|
|
|
|
|
|
Item temp = new Item(ib, pc.getObjectUUID(), |
|
|
|
|
OwnerType.PlayerCharacter, charges, charges, durability, durability, |
|
|
|
|
true, false, Enum.ItemContainerType.BANK, (byte) 0, |
|
|
|
|
new ArrayList<>(), ""); |
|
|
|
|
try { |
|
|
|
|
item = DbManager.ItemQueries.PERSIST(temp); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
} |
|
|
|
|
return item; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Item createItemForMob(Mob mob, ItemBase ib) { |
|
|
|
|
Item item = null; |
|
|
|
|
byte charges = 0; |
|
|
|
|
|
|
|
|
|
charges = (byte) ib.getNumCharges(); |
|
|
|
|
short durability = (short) ib.getDurability(); |
|
|
|
|
|
|
|
|
|
Item temp = new Item(ib, mob.getObjectUUID(), |
|
|
|
|
OwnerType.Mob, charges, charges, durability, durability, |
|
|
|
|
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, |
|
|
|
|
new ArrayList<>(), ""); |
|
|
|
|
try { |
|
|
|
|
item = DbManager.ItemQueries.PERSIST(temp); |
|
|
|
|
item = DbManager.ItemQueries.PERSIST(item); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
} |
|
|
|
@ -667,23 +618,16 @@ public class Item extends AbstractWorldObject {
@@ -667,23 +618,16 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
ownerID = accountID; |
|
|
|
|
ownerType = OwnerType.Account; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Item newGold = new Item(ib, ownerID, ownerType, |
|
|
|
|
(byte) 0, (byte) 0, (short) 0, (short) 0, true, false, containerType, (byte) 0, |
|
|
|
|
new ArrayList<>(), ""); |
|
|
|
|
|
|
|
|
|
synchronized (newGold) { |
|
|
|
|
Item newGold = new Item(ib.getUUID()); |
|
|
|
|
newGold.ownerID = ownerID; |
|
|
|
|
newGold.ownerType = ownerType; |
|
|
|
|
newGold.containerType = containerType; |
|
|
|
|
newGold.numberOfItems = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (persist) { |
|
|
|
|
try { |
|
|
|
|
newGold = DbManager.ItemQueries.PERSIST(newGold); |
|
|
|
|
if (newGold != null) { |
|
|
|
|
synchronized (newGold) { |
|
|
|
|
newGold.numberOfItems = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
} |
|
|
|
@ -729,28 +673,20 @@ public class Item extends AbstractWorldObject {
@@ -729,28 +673,20 @@ public class Item extends AbstractWorldObject {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Item newGold = new Item(ib, ownerID, ownerType, |
|
|
|
|
(byte) 0, (byte) 0, (short) 0, (short) 0, true, false, containerType, (byte) 0, |
|
|
|
|
new ArrayList<>(), ""); |
|
|
|
|
|
|
|
|
|
synchronized (newGold) { |
|
|
|
|
Item newGold = new Item(ib.getUUID()); |
|
|
|
|
newGold.ownerID = ownerID; |
|
|
|
|
newGold.ownerType = ownerType; |
|
|
|
|
newGold.containerType = containerType; |
|
|
|
|
newGold.numberOfItems = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (persist) { |
|
|
|
|
try { |
|
|
|
|
newGold = DbManager.ItemQueries.PERSIST(newGold); |
|
|
|
|
if (newGold != null) { |
|
|
|
|
synchronized (newGold) { |
|
|
|
|
newGold.numberOfItems = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
} |
|
|
|
|
DbManager.ItemQueries.ZERO_ITEM_STACK(newGold); |
|
|
|
|
} |
|
|
|
|
newGold.containerType = containerType; |
|
|
|
|
|
|
|
|
|
return newGold; |
|
|
|
|
} |
|
|
|
|