diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 67d64f45..ce9bd268 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -94,7 +94,7 @@ public class dbItemHandler extends dbHandlerBase { preparedStatement.setByte(8, (byte) toAdd.equipSlot.ordinal()); preparedStatement.setInt(9, toAdd.getFlags()); - preparedStatement.setString(10, toAdd.getCustomName()); + preparedStatement.setString(10, toAdd.name); ResultSet rs = preparedStatement.executeQuery(); diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index bb67ee30..c54e5f01 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -278,11 +278,11 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); } - writer.putString(toRoll.getCustomName()); - ; + writer.putString(toRoll.name); writer.putInt(GameObjectType.MobLoot.ordinal()); writer.putInt(this.itemUUID); writer.putInt(0); //items left to produce? + if (toRoll != null) { writer.putInt(toRoll.getTemplateID()); writer.putInt(toRoll.getValue()); diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 4c310294..af1566f7 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -441,32 +441,32 @@ public class ManageNPCMsg extends ClientNetMsg { 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); writer.put((byte) 0); // ? Unknown45 - writer.putInt(i.getObjectType().ordinal()); - writer.putInt(i.getObjectUUID()); + writer.putInt(item.getObjectType().ordinal()); + writer.putInt(item.getObjectUUID()); - writer.putInt(0); - writer.putInt(i.getTemplateID()); + writer.putInt(0); + writer.putInt(item.getTemplateID()); 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(npc.getRollingTimeInSeconds(i.getTemplateID())); + writer.putInt(npc.getRollingTimeInSeconds(item.getTemplateID())); writer.putInt(1); - if (i.isComplete()) - writer.put((byte) 1); - else - writer.put((byte) 0); + if (item.isComplete()) + writer.put((byte) 1); + else + writer.put((byte) 0); - ArrayList effectsList = i.getEffectNames(); - EffectsBase prefix = null; + ArrayList effectsList = item.getEffectNames(); + EffectsBase prefix = null; EffectsBase suffix = null; for (String effectName : effectsList) { @@ -483,20 +483,19 @@ public class ManageNPCMsg extends ClientNetMsg { else writer.putInt(-1497023830); - if ((prefix != null && !i.isRandom()) || (prefix != null && i.isComplete())) - writer.putInt(prefix.getToken()); - else - writer.putInt(0); + if ((prefix != null && !item.isRandom()) || (prefix != null && item.isComplete())) + writer.putInt(prefix.getToken()); + else + writer.putInt(0); - if ((suffix != null && !i.isRandom()) || (suffix != null && i.isComplete())) - writer.putInt(suffix.getToken()); - else - writer.putInt(0); + if ((suffix != null && !item.isRandom()) || (suffix != null && item.isComplete())) + writer.putInt(suffix.getToken()); + else + writer.putInt(0); - writer.putString(i.getCustomName()); + writer.putString(item.name); } - writer.putInt(0); writer.putInt(0); writer.putInt(1); diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 185933f4..52c5f57f 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -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; diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 3c523f84..f34f5d43 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -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()))); diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index e0f17353..4b64cac0 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -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)