Begin constructor refactor

This commit is contained in:
2024-03-01 21:32:51 -05:00
parent 9ea44d7e1c
commit fa440e2885
20 changed files with 72 additions and 76 deletions
+17 -25
View File
@@ -45,18 +45,18 @@ public class Item extends AbstractWorldObject {
private final ArrayList<String> effectNames = new ArrayList<>();
public Enum.ItemContainerType containerType;
public ReentrantLock lootLock = new ReentrantLock();
private int ownerID; //may be character, account, npc, mob
public int ownerID; //may be character, account, npc, mob
private int flags; //1 = isIDed
private int numberOfItems;
private short durabilityCurrent;
private byte chargesRemaining;
public float durabilityCurrent;
public int chargesRemaining;
private byte equipSlot;
private boolean canDestroy;
private boolean rentable;
private boolean isRandom = false;
private int value;
private OwnerType ownerType;
private int itemBaseID;
public OwnerType ownerType;
public int templsteID;
private AbstractWorldObject lastOwner;
private ArrayList<EnchantmentBase> enchants = new ArrayList<>();
private long dateToUpgrade;
@@ -72,7 +72,11 @@ public class Item extends AbstractWorldObject {
public Item(int templateID) {
super();
this.template = ItemTemplate.itemTemplates.get(templateID);
this.chargesRemaining = this.template.item_initial_charges;
this.durabilityCurrent = this.template.combat_health_full;
loadEnchantments();
bakeInStats();
}
public Item(ItemBase itemBase, int ownerID,
@@ -81,7 +85,7 @@ public class Item extends AbstractWorldObject {
boolean rentable, Enum.ItemContainerType containerType, byte equipSlot,
ArrayList<EnchantmentBase> enchants, String name) {
super();
this.itemBaseID = itemBase.getUUID();
this.templsteID = itemBase.getUUID();
this.ownerID = ownerID;
this.ownerType = ownerType;
@@ -119,7 +123,7 @@ public class Item extends AbstractWorldObject {
ArrayList<EnchantmentBase> enchants, int newUUID) {
super(newUUID);
this.itemBaseID = itemBase.getUUID();
this.templsteID = itemBase.getUUID();
this.ownerID = ownerID;
this.ownerType = ownerType;
this.customName = "";
@@ -146,7 +150,7 @@ public class Item extends AbstractWorldObject {
public Item(ResultSet rs) throws SQLException {
super(rs);
this.itemBaseID = rs.getInt("item_itemBaseID");
this.templsteID = rs.getInt("item_itemBaseID");
// Set container enumeration
@@ -784,11 +788,11 @@ public class Item extends AbstractWorldObject {
}
public ItemBase getItemBase() {
return ItemBase.getItemBase(itemBaseID);
return ItemBase.getItemBase(templsteID);
}
public int getItemBaseID() {
return this.itemBaseID;
public int getTemplsteID() {
return this.templsteID;
}
public int getOwnerID() {
@@ -800,10 +804,6 @@ public class Item extends AbstractWorldObject {
this.ownerID = ownerID;
}
public OwnerType getOwnerType() {
return ownerType;
}
public AbstractGameObject getOwner() {
if (this.ownerType == OwnerType.Npc)
return NPC.getFromCache(this.ownerID);
@@ -850,15 +850,7 @@ public class Item extends AbstractWorldObject {
return chargesMax;
}
public byte getChargesRemaining() {
return chargesRemaining;
}
public short getDurabilityCurrent() {
return durabilityCurrent;
}
public void setDurabilityCurrent(short value) {
public void setDurabilityCurrent(float value) {
this.durabilityCurrent = value;
}
@@ -1194,7 +1186,7 @@ public class Item extends AbstractWorldObject {
if (this.customName.isEmpty() == false)
return this.customName;
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getItemBaseID());
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplsteID());
return template.item_base_name;
}