Durability and initial charges migrated to template.

This commit is contained in:
2024-03-03 08:38:24 -05:00
parent 436d0cec9b
commit d7dfab5e74
6 changed files with 19 additions and 26 deletions
+5 -17
View File
@@ -39,8 +39,6 @@ import java.util.concurrent.locks.ReentrantLock;
public class Item extends AbstractWorldObject {
private static ConcurrentHashMap<String, Integer> enchantValues = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private short durabilityMax;
private byte chargesMax;
private final ConcurrentHashMap<AbstractEffectModifier, Float> bonuses = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final ArrayList<String> effectNames = new ArrayList<>();
public Enum.ItemContainerType containerType;
@@ -87,7 +85,11 @@ public class Item extends AbstractWorldObject {
super(rs);
this.templsteID = rs.getInt("item_itemBaseID");
this.template = ItemTemplate.itemTemplates.get(this.templsteID);
if (this.template == null)
Logger.error("Null template of " + this.templsteID)
;
// Set container enumeration
String container = rs.getString("item_container");
@@ -115,15 +117,9 @@ public class Item extends AbstractWorldObject {
this.ownerID = rs.getInt("parent");
if (this.getItemBase() != null)
this.chargesMax = (byte) this.getItemBase().getNumCharges();
else
this.chargesMax = 0;
this.chargesRemaining = rs.getByte("item_chargesRemaining");
this.durabilityCurrent = rs.getShort("item_durabilityCurrent");
this.durabilityMax = rs.getShort("item_durabilityMax");
DbObjectType ownerType;
ownerType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerID);
@@ -221,7 +217,7 @@ public class Item extends AbstractWorldObject {
writer.putString(item.customName); // Unknown. pad?
writer.put((byte) 1); // End Datablock byte
writer.putFloat((float) item.durabilityMax);
writer.putFloat(item.template.item_health_full);
writer.putFloat((float) item.durabilityCurrent);
writer.put((byte) 1); // End Datablock byte
@@ -708,18 +704,10 @@ public class Item extends AbstractWorldObject {
return true;
}
public byte getChargesMax() {
return chargesMax;
}
public void setDurabilityCurrent(float value) {
this.durabilityCurrent = value;
}
public short getDurabilityMax() {
return durabilityMax;
}
public boolean isCanDestroy() {
return canDestroy;
}