Refactor of item.name; simplification.
This commit is contained in:
@@ -94,7 +94,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
preparedStatement.setByte(8, (byte) toAdd.equipSlot.ordinal());
|
preparedStatement.setByte(8, (byte) toAdd.equipSlot.ordinal());
|
||||||
preparedStatement.setInt(9, toAdd.getFlags());
|
preparedStatement.setInt(9, toAdd.getFlags());
|
||||||
preparedStatement.setString(10, toAdd.getCustomName());
|
preparedStatement.setString(10, toAdd.name);
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
|||||||
@@ -278,11 +278,11 @@ public class ItemProductionMsg extends ClientNetMsg {
|
|||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.putString(toRoll.getCustomName());
|
writer.putString(toRoll.name);
|
||||||
;
|
|
||||||
writer.putInt(GameObjectType.MobLoot.ordinal());
|
writer.putInt(GameObjectType.MobLoot.ordinal());
|
||||||
writer.putInt(this.itemUUID);
|
writer.putInt(this.itemUUID);
|
||||||
writer.putInt(0); //items left to produce?
|
writer.putInt(0); //items left to produce?
|
||||||
|
|
||||||
if (toRoll != null) {
|
if (toRoll != null) {
|
||||||
writer.putInt(toRoll.getTemplateID());
|
writer.putInt(toRoll.getTemplateID());
|
||||||
writer.putInt(toRoll.getValue());
|
writer.putInt(toRoll.getValue());
|
||||||
|
|||||||
@@ -441,32 +441,32 @@ public class ManageNPCMsg extends ClientNetMsg {
|
|||||||
|
|
||||||
writer.putInt(itemList.size());
|
writer.putInt(itemList.size());
|
||||||
|
|
||||||
for (Item i : itemList) {
|
for (Item item : itemList) {
|
||||||
|
|
||||||
ItemBase ib = i.getItemBase();
|
ItemBase ib = item.getItemBase();
|
||||||
ItemTemplate template = ItemTemplate.templates.get(ib);
|
ItemTemplate template = ItemTemplate.templates.get(ib);
|
||||||
writer.put((byte) 0); // ? Unknown45
|
writer.put((byte) 0); // ? Unknown45
|
||||||
writer.putInt(i.getObjectType().ordinal());
|
writer.putInt(item.getObjectType().ordinal());
|
||||||
writer.putInt(i.getObjectUUID());
|
writer.putInt(item.getObjectUUID());
|
||||||
|
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
writer.putInt(i.getTemplateID());
|
writer.putInt(item.getTemplateID());
|
||||||
writer.putInt(template.item_value);
|
writer.putInt(template.item_value);
|
||||||
|
|
||||||
long timeLife = i.getDateToUpgrade() - System.currentTimeMillis();
|
long timeLife = item.getDateToUpgrade() - System.currentTimeMillis();
|
||||||
|
|
||||||
timeLife /= 1000;
|
timeLife /= 1000;
|
||||||
writer.putInt((int) timeLife);
|
writer.putInt((int) timeLife);
|
||||||
writer.putInt(npc.getRollingTimeInSeconds(i.getTemplateID()));
|
writer.putInt(npc.getRollingTimeInSeconds(item.getTemplateID()));
|
||||||
writer.putInt(1);
|
writer.putInt(1);
|
||||||
|
|
||||||
if (i.isComplete())
|
if (item.isComplete())
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
else
|
else
|
||||||
writer.put((byte) 0);
|
writer.put((byte) 0);
|
||||||
|
|
||||||
ArrayList<String> effectsList = i.getEffectNames();
|
ArrayList<String> effectsList = item.getEffectNames();
|
||||||
EffectsBase prefix = null;
|
EffectsBase prefix = null;
|
||||||
EffectsBase suffix = null;
|
EffectsBase suffix = null;
|
||||||
|
|
||||||
for (String effectName : effectsList) {
|
for (String effectName : effectsList) {
|
||||||
@@ -483,20 +483,19 @@ public class ManageNPCMsg extends ClientNetMsg {
|
|||||||
else
|
else
|
||||||
writer.putInt(-1497023830);
|
writer.putInt(-1497023830);
|
||||||
|
|
||||||
if ((prefix != null && !i.isRandom()) || (prefix != null && i.isComplete()))
|
if ((prefix != null && !item.isRandom()) || (prefix != null && item.isComplete()))
|
||||||
writer.putInt(prefix.getToken());
|
writer.putInt(prefix.getToken());
|
||||||
else
|
else
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
|
|
||||||
if ((suffix != null && !i.isRandom()) || (suffix != null && i.isComplete()))
|
if ((suffix != null && !item.isRandom()) || (suffix != null && item.isComplete()))
|
||||||
writer.putInt(suffix.getToken());
|
writer.putInt(suffix.getToken());
|
||||||
else
|
else
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
|
|
||||||
writer.putString(i.getCustomName());
|
writer.putString(item.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
writer.putInt(1);
|
writer.putInt(1);
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
public int templateID;
|
public int templateID;
|
||||||
private AbstractWorldObject lastOwner;
|
private AbstractWorldObject lastOwner;
|
||||||
private long dateToUpgrade;
|
private long dateToUpgrade;
|
||||||
private String customName = "";
|
|
||||||
private int magicValue;
|
private int magicValue;
|
||||||
public ItemTemplate template;
|
public ItemTemplate template;
|
||||||
public String name;
|
public String name;
|
||||||
@@ -69,6 +68,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
super();
|
super();
|
||||||
this.templateID = templateID;
|
this.templateID = templateID;
|
||||||
this.template = ItemTemplate.templates.get(templateID);
|
this.template = ItemTemplate.templates.get(templateID);
|
||||||
|
this.name = this.template.item_base_name;
|
||||||
this.chargesRemaining = this.template.item_initial_charges;
|
this.chargesRemaining = this.template.item_initial_charges;
|
||||||
this.durabilityCurrent = this.template.combat_health_full;
|
this.durabilityCurrent = this.template.combat_health_full;
|
||||||
this.equipSlot = EquipSlotType.NONE;
|
this.equipSlot = EquipSlotType.NONE;
|
||||||
@@ -88,8 +88,15 @@ public class Item extends AbstractWorldObject {
|
|||||||
this.template = ItemTemplate.templates.get(this.templateID);
|
this.template = ItemTemplate.templates.get(this.templateID);
|
||||||
|
|
||||||
if (this.template == null)
|
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
|
// Set container enumeration
|
||||||
|
|
||||||
String container = rs.getString("item_container");
|
String container = rs.getString("item_container");
|
||||||
@@ -145,8 +152,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
this.flags = rs.getInt("item_flags");
|
this.flags = rs.getInt("item_flags");
|
||||||
this.dateToUpgrade = rs.getLong("item_dateToUpgrade");
|
this.dateToUpgrade = rs.getLong("item_dateToUpgrade");
|
||||||
this.value = rs.getInt("item_value");
|
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.putInt(itemColor);
|
||||||
|
|
||||||
writer.put((byte) 1); // End Datablock byte
|
writer.put((byte) 1); // End Datablock byte
|
||||||
if (item.customName.isEmpty() || item.customName.isEmpty()) {
|
writer.putString(item.name); // Unknown. pad?
|
||||||
writer.putInt(0);
|
|
||||||
} else
|
|
||||||
writer.putString(item.customName); // Unknown. pad?
|
|
||||||
writer.put((byte) 1); // End Datablock byte
|
writer.put((byte) 1); // End Datablock byte
|
||||||
|
|
||||||
writer.putFloat(item.template.item_health_full);
|
writer.putFloat(item.template.item_health_full);
|
||||||
@@ -655,10 +657,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomName() {
|
|
||||||
return customName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBase getItemBase() {
|
public ItemBase getItemBase() {
|
||||||
return ItemBase.getItemBase(templateID);
|
return ItemBase.getItemBase(templateID);
|
||||||
}
|
}
|
||||||
@@ -1006,21 +1004,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
return this.magicValue;
|
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() {
|
private void applyBakedInStats() {
|
||||||
|
|
||||||
EffectsBase effect;
|
EffectsBase effect;
|
||||||
|
|||||||
@@ -563,7 +563,9 @@ public class ItemFactory {
|
|||||||
ml = new MobLoot(npc, template, false);
|
ml = new MobLoot(npc, template, false);
|
||||||
|
|
||||||
ml.containerType = Enum.ItemContainerType.FORGE;
|
ml.containerType = Enum.ItemContainerType.FORGE;
|
||||||
ml.setName(customName);
|
|
||||||
|
if (customName.isEmpty() == false)
|
||||||
|
ml.name = customName;
|
||||||
|
|
||||||
if (prefix != null) {
|
if (prefix != null) {
|
||||||
ml.addPermanentEnchantment(prefix.getIDString(), 0, 0, true);
|
ml.addPermanentEnchantment(prefix.getIDString(), 0, 0, true);
|
||||||
@@ -610,8 +612,8 @@ public class ItemFactory {
|
|||||||
if (pc != null)
|
if (pc != null)
|
||||||
playerID = pc.getObjectUUID();
|
playerID = pc.getObjectUUID();
|
||||||
|
|
||||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, 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.getCustomName(), playerID);
|
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, prefixString, suffixString, ml.name, playerID);
|
||||||
pi.setProducedItemID(ml.getObjectUUID());
|
pi.setProducedItemID(ml.getObjectUUID());
|
||||||
pi.setAmount(itemsToRoll);
|
pi.setAmount(itemsToRoll);
|
||||||
|
|
||||||
@@ -748,9 +750,9 @@ public class ItemFactory {
|
|||||||
if (playerCharacter != null)
|
if (playerCharacter != null)
|
||||||
playerID = playerCharacter.getObjectUUID();
|
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.setProducedItemID(toRoll.getObjectUUID());
|
||||||
pi.setAmount(itemsToRoll);
|
pi.setAmount(itemsToRoll);
|
||||||
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));
|
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))
|
if (this.template.item_type.equals(ItemType.GOLD))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Item item = (Item) this;
|
Item item = this;
|
||||||
|
|
||||||
item.setOwner(looter);
|
item.setOwner(looter);
|
||||||
//item.setIsID(false);
|
|
||||||
|
|
||||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||||
item.setValue(0);
|
item.setValue(0);
|
||||||
item.setName(this.getCustomName());
|
|
||||||
item.setIsID(this.isID());
|
item.setIsID(this.isID());
|
||||||
|
|
||||||
if (this.getNumOfItems() > 1)
|
if (this.getNumOfItems() > 1)
|
||||||
@@ -131,9 +128,8 @@ public final class MobLoot extends Item {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (String effectName : this.effectNames)
|
|
||||||
// item.addPermanentEnchantment(effectName, 0);
|
|
||||||
//transfer enchantments to item
|
//transfer enchantments to item
|
||||||
|
|
||||||
if (this.prefix.length() != 0)
|
if (this.prefix.length() != 0)
|
||||||
item.addPermanentEnchantment(this.prefix, 0);
|
item.addPermanentEnchantment(this.prefix, 0);
|
||||||
if (this.suffix.length() != 0)
|
if (this.suffix.length() != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user