forked from MagicBane/Server
Refactor of item.name; simplification.
This commit is contained in:
@@ -55,7 +55,6 @@ public class Item extends AbstractWorldObject {
|
||||
public int templateID;
|
||||
private AbstractWorldObject lastOwner;
|
||||
private long dateToUpgrade;
|
||||
private String customName = "";
|
||||
private int magicValue;
|
||||
public ItemTemplate template;
|
||||
public String name;
|
||||
@@ -69,6 +68,7 @@ public class Item extends AbstractWorldObject {
|
||||
super();
|
||||
this.templateID = templateID;
|
||||
this.template = ItemTemplate.templates.get(templateID);
|
||||
this.name = this.template.item_base_name;
|
||||
this.chargesRemaining = this.template.item_initial_charges;
|
||||
this.durabilityCurrent = this.template.combat_health_full;
|
||||
this.equipSlot = EquipSlotType.NONE;
|
||||
@@ -88,8 +88,15 @@ public class Item extends AbstractWorldObject {
|
||||
this.template = ItemTemplate.templates.get(this.templateID);
|
||||
|
||||
if (this.template == null)
|
||||
Logger.error("Null template of " + this.templateID)
|
||||
;
|
||||
Logger.error("Null template of " + this.templateID);
|
||||
|
||||
this.name = rs.getString("item_name");
|
||||
|
||||
if (this.name == null)
|
||||
this.name = this.template.item_base_name;
|
||||
else if (this.name.isEmpty())
|
||||
this.name = this.template.item_base_name;
|
||||
|
||||
// Set container enumeration
|
||||
|
||||
String container = rs.getString("item_container");
|
||||
@@ -145,8 +152,6 @@ public class Item extends AbstractWorldObject {
|
||||
this.flags = rs.getInt("item_flags");
|
||||
this.dateToUpgrade = rs.getLong("item_dateToUpgrade");
|
||||
this.value = rs.getInt("item_value");
|
||||
this.customName = rs.getString("item_name");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -213,10 +218,7 @@ public class Item extends AbstractWorldObject {
|
||||
writer.putInt(itemColor);
|
||||
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
if (item.customName.isEmpty() || item.customName.isEmpty()) {
|
||||
writer.putInt(0);
|
||||
} else
|
||||
writer.putString(item.customName); // Unknown. pad?
|
||||
writer.putString(item.name); // Unknown. pad?
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
|
||||
writer.putFloat(item.template.item_health_full);
|
||||
@@ -655,10 +657,6 @@ public class Item extends AbstractWorldObject {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getCustomName() {
|
||||
return customName;
|
||||
}
|
||||
|
||||
public ItemBase getItemBase() {
|
||||
return ItemBase.getItemBase(templateID);
|
||||
}
|
||||
@@ -1006,21 +1004,6 @@ public class Item extends AbstractWorldObject {
|
||||
return this.magicValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
if (this.customName.isEmpty() == false)
|
||||
return this.customName;
|
||||
|
||||
ItemTemplate template = ItemTemplate.templates.get(this.getTemplateID());
|
||||
return template.item_base_name;
|
||||
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.customName = name;
|
||||
}
|
||||
|
||||
private void applyBakedInStats() {
|
||||
|
||||
EffectsBase effect;
|
||||
|
||||
Reference in New Issue
Block a user