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;
|
||||
|
||||
@@ -563,7 +563,9 @@ public class ItemFactory {
|
||||
ml = new MobLoot(npc, template, false);
|
||||
|
||||
ml.containerType = Enum.ItemContainerType.FORGE;
|
||||
ml.setName(customName);
|
||||
|
||||
if (customName.isEmpty() == false)
|
||||
ml.name = customName;
|
||||
|
||||
if (prefix != null) {
|
||||
ml.addPermanentEnchantment(prefix.getIDString(), 0, 0, true);
|
||||
@@ -610,8 +612,8 @@ public class ItemFactory {
|
||||
if (pc != null)
|
||||
playerID = pc.getObjectUUID();
|
||||
|
||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID);
|
||||
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID);
|
||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, prefixString, suffixString, ml.name, false, playerID);
|
||||
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, prefixString, suffixString, ml.name, playerID);
|
||||
pi.setProducedItemID(ml.getObjectUUID());
|
||||
pi.setAmount(itemsToRoll);
|
||||
|
||||
@@ -748,9 +750,9 @@ public class ItemFactory {
|
||||
if (playerCharacter != null)
|
||||
playerID = playerCharacter.getObjectUUID();
|
||||
|
||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID);
|
||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, prefix, suffix, toRoll.name, true, playerID);
|
||||
|
||||
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID);
|
||||
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, true, prefix, suffix, toRoll.name, playerID);
|
||||
pi.setProducedItemID(toRoll.getObjectUUID());
|
||||
pi.setAmount(itemsToRoll);
|
||||
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));
|
||||
|
||||
@@ -111,14 +111,11 @@ public final class MobLoot extends Item {
|
||||
if (this.template.item_type.equals(ItemType.GOLD))
|
||||
return null;
|
||||
|
||||
Item item = (Item) this;
|
||||
Item item = this;
|
||||
|
||||
item.setOwner(looter);
|
||||
//item.setIsID(false);
|
||||
|
||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||
item.setValue(0);
|
||||
item.setName(this.getCustomName());
|
||||
item.setIsID(this.isID());
|
||||
|
||||
if (this.getNumOfItems() > 1)
|
||||
@@ -131,9 +128,8 @@ public final class MobLoot extends Item {
|
||||
return null;
|
||||
}
|
||||
|
||||
// for (String effectName : this.effectNames)
|
||||
// item.addPermanentEnchantment(effectName, 0);
|
||||
//transfer enchantments to item
|
||||
|
||||
if (this.prefix.length() != 0)
|
||||
item.addPermanentEnchantment(this.prefix, 0);
|
||||
if (this.suffix.length() != 0)
|
||||
|
||||
Reference in New Issue
Block a user