Browse Source

Refactor itembase.name to template.

combat-2
MagicBot 9 months ago
parent
commit
d9775dbf4e
  1. 3
      src/engine/devcmd/cmds/AuditFailedItemsCmd.java
  2. 3
      src/engine/devcmd/cmds/InfoCmd.java
  3. 3
      src/engine/devcmd/cmds/PrintBankCmd.java
  4. 3
      src/engine/devcmd/cmds/PrintBonusesCmd.java
  5. 9
      src/engine/devcmd/cmds/PrintEquipCmd.java
  6. 3
      src/engine/devcmd/cmds/PrintInventoryCmd.java
  7. 3
      src/engine/devcmd/cmds/PrintVaultCmd.java
  8. 3
      src/engine/devcmd/cmds/SimulateBootyCmd.java
  9. 7
      src/engine/gameManager/BuildingManager.java
  10. 3
      src/engine/gameManager/ChatManager.java
  11. 10
      src/engine/gameManager/LootManager.java
  12. 6
      src/engine/objects/City.java
  13. 9
      src/engine/objects/Item.java
  14. 4
      src/engine/objects/ItemBase.java
  15. 111
      src/engine/objects/ItemFactory.java
  16. 6
      src/engine/objects/MobEquipment.java
  17. 33
      src/engine/objects/Warehouse.java

3
src/engine/devcmd/cmds/AuditFailedItemsCmd.java

@ -65,9 +65,10 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
playerName = roller.getName(); playerName = roller.getName();
ItemBase ib = ItemBase.getItemBase(failedItem.getItemBaseID()); ItemBase ib = ItemBase.getItemBase(failedItem.getItemBaseID());
ItemTemplate template = ItemTemplate.itemTemplates.get(failedItem.getItemBaseID());
if (ib != null) { if (ib != null) {
itemName = ib.getName(); itemName = template.item_base_name;
} }
if (failedItem.isRandom() == false) { if (failedItem.isRandom() == false) {

3
src/engine/devcmd/cmds/InfoCmd.java

@ -506,6 +506,7 @@ public class InfoCmd extends AbstractDevCmd {
case MobLoot: case MobLoot:
Item item = (Item) target; Item item = (Item) target;
ItemBase itemBase = item.getItemBase(); ItemBase itemBase = item.getItemBase();
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20); output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
output += "Weight: " + itemBase.getWeight(); output += "Weight: " + itemBase.getWeight();
output += newline; output += newline;
@ -515,7 +516,7 @@ public class InfoCmd extends AbstractDevCmd {
output += "Charges: " + item.getChargesRemaining() output += "Charges: " + item.getChargesRemaining()
+ '/' + item.getChargesMax(); + '/' + item.getChargesMax();
output += newline; output += newline;
output += "Name: " + itemBase.getName(); output += "Name: " + template.item_base_name;
output += newline; output += newline;
output += item.getContainerInfo(); output += item.getContainerInfo();

3
src/engine/devcmd/cmds/PrintBankCmd.java

@ -51,7 +51,8 @@ public class PrintBankCmd extends AbstractDevCmd {
ArrayList<Item> list = cim.getBank(); ArrayList<Item> list = cim.getBank();
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) { for (Item item : list) {
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems()); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
} }
Item gold = cim.getGoldBank(); Item gold = cim.getGoldBank();
if (gold != null) if (gold != null)

3
src/engine/devcmd/cmds/PrintBonusesCmd.java

@ -33,7 +33,8 @@ public class PrintBonusesCmd extends AbstractDevCmd {
if (target instanceof Item) { if (target instanceof Item) {
type = "Item"; type = "Item";
tar = (Item) target; tar = (Item) target;
name = ((Item) tar).getItemBase().getName(); ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getItemBaseID());
name = template.item_base_name;
} else if (target instanceof AbstractCharacter) { } else if (target instanceof AbstractCharacter) {
tar = (AbstractCharacter) target; tar = (AbstractCharacter) target;
name = ((AbstractCharacter) tar).getFirstName(); name = ((AbstractCharacter) tar).getFirstName();

9
src/engine/devcmd/cmds/PrintEquipCmd.java

@ -65,7 +65,8 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot : tarMob.getEquip().keySet()) { for (int slot : tarMob.getEquip().keySet()) {
MobEquipment equip = tarMob.getEquip().get(slot); MobEquipment equip = tarMob.getEquip().get(slot);
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot); ItemTemplate template = ItemTemplate.itemTemplates.get(equip.getItemBase().getUUID());
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + template.item_base_name + ", slot: " + slot);
} }
return; return;
} }
@ -75,7 +76,8 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot : tarMob.getEquip().keySet()) { for (int slot : tarMob.getEquip().keySet()) {
MobEquipment equip = tarMob.getEquip().get(slot); MobEquipment equip = tarMob.getEquip().get(slot);
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot); ItemTemplate template = ItemTemplate.itemTemplates.get(equip.getItemBase().getUUID());
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + template.item_base_name + ", slot: " + slot);
} }
return; return;
} }
@ -85,7 +87,8 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Integer slot : list.keySet()) { for (Integer slot : list.keySet()) {
Item item = list.get(slot); Item item = list.get(slot);
throwbackInfo(pc, " " + item.getItemBase().getName() + ", slot: " + slot); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot);
} }
} }

3
src/engine/devcmd/cmds/PrintInventoryCmd.java

@ -82,7 +82,8 @@ public class PrintInventoryCmd extends AbstractDevCmd {
byte charges = item.getChargesRemaining(); byte charges = item.getChargesRemaining();
chargeInfo = " charges: " + charges + '/' + chargeMax; chargeInfo = " charges: " + charges + '/' + chargeMax;
} }
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems() + chargeInfo); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo);
} else } else
goldCount += item.getNumOfItems(); goldCount += item.getNumOfItems();
} }

3
src/engine/devcmd/cmds/PrintVaultCmd.java

@ -50,7 +50,8 @@ public class PrintVaultCmd extends AbstractDevCmd {
ArrayList<Item> list = cim.getVault(); ArrayList<Item> list = cim.getVault();
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) { for (Item item : list) {
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems()); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
} }
Item gold = cim.getGoldVault(); Item gold = cim.getGoldVault();
if (gold != null) if (gold != null)

3
src/engine/devcmd/cmds/SimulateBootyCmd.java

@ -35,7 +35,8 @@ public class SimulateBootyCmd extends AbstractDevCmd {
for (BootySetEntry entry : LootManager._bootySetMap.get(mob.bootySet)) { for (BootySetEntry entry : LootManager._bootySetMap.get(mob.bootySet)) {
ItemBase item = ItemBase.getItemBase(entry.itemBase); ItemBase item = ItemBase.getItemBase(entry.itemBase);
if (item != null) { if (item != null) {
output += "[" + entry.bootyType + "] " + item.getName() + " [Chance] " + entry.dropChance + newline; ItemTemplate template = ItemTemplate.itemTemplates.get(entry.itemBase);
output += "[" + entry.bootyType + "] " + template.item_base_name + " [Chance] " + entry.dropChance + newline;
} }
} }
} }

7
src/engine/gameManager/BuildingManager.java

@ -242,8 +242,11 @@ public enum BuildingManager {
if (resourceAmount <= 0) if (resourceAmount <= 0)
continue; continue;
if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true)) if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true)) {
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + resourceBase.getName()); ItemTemplate template = ItemTemplate.itemTemplates.get(resourceBase.getUUID());
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + template.item_base_name);
}
} }
break; break;

3
src/engine/gameManager/ChatManager.java

@ -612,7 +612,8 @@ public enum ChatManager {
name = amount + " gold "; name = amount + " gold ";
else { else {
String vowels = "aeiou"; String vowels = "aeiou";
String iName = item.getItemBase().getName(); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
String iName = template.item_base_name;
if (iName.length() > 0) if (iName.length() > 0)
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0) if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
name = "an " + iName + ' '; name = "an " + iName + ' ';

10
src/engine/gameManager/LootManager.java

@ -83,10 +83,14 @@ public enum LootManager {
for (Item it : mob.getInventory()) { for (Item it : mob.getInventory()) {
ItemBase ib = it.getItemBase(); ItemBase ib = it.getItemBase();
if(ib == null)
if (ib == null)
break; break;
if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) {
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + ib.getName() + ". Are you tough enough to take it?"); ItemTemplate template = ItemTemplate.itemTemplates.get(it.getItemBaseID());
if (ib.isDiscRune() || template.item_base_name.toLowerCase().contains("of the gods")) {
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?");
chatMsg.setMessageType(10); chatMsg.setMessageType(10);
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
DispatchMessage.dispatchMsgToAll(chatMsg); DispatchMessage.dispatchMsgToAll(chatMsg);

6
src/engine/objects/City.java

@ -1381,10 +1381,14 @@ public class City extends AbstractWorldObject {
for (Integer itemBaseID : resources) { for (Integer itemBaseID : resources) {
ItemBase ib = ItemBase.getItemBase(itemBaseID); ItemBase ib = ItemBase.getItemBase(itemBaseID);
if (ib == null) if (ib == null)
continue; continue;
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
if (Warehouse.isAboveCap(ruledWarehouse, ib, (int) (city.getWarehouse().resources.get(ib) * taxPercent))) { if (Warehouse.isAboveCap(ruledWarehouse, ib, (int) (city.getWarehouse().resources.get(ib) * taxPercent))) {
ErrorPopupMsg.sendErrorMsg(player, "You're warehouse has enough " + ib.getName() + " already!"); ErrorPopupMsg.sendErrorMsg(player, "You're warehouse has enough " + template.item_base_name + " already!");
return true; return true;
} }

9
src/engine/objects/Item.java

@ -1212,10 +1212,13 @@ public class Item extends AbstractWorldObject {
@Override @Override
public String getName() { public String getName() {
if (this.customName.isEmpty())
if (this.getItemBase() != null) if (this.customName.isEmpty() == false)
return this.getItemBase().getName();
return this.customName; return this.customName;
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getItemBaseID());
return template.item_base_name;
} }
public void setName(String name) { public void setName(String name) {

4
src/engine/objects/ItemBase.java

@ -37,7 +37,7 @@ public class ItemBase {
private static final HashMap<String, Integer> _IDsByNames = new HashMap<>(); private static final HashMap<String, Integer> _IDsByNames = new HashMap<>();
private static final ArrayList<ItemBase> _resourceList = new ArrayList<>(); private static final ArrayList<ItemBase> _resourceList = new ArrayList<>();
private final int uuid; private final int uuid;
private final String name; private String name;
//requirements/restrictions //requirements/restrictions
public EnumSet<Enum.MonsterType> restrictedRaces; public EnumSet<Enum.MonsterType> restrictedRaces;
public EnumSet<Enum.MonsterType> requiredRaces; public EnumSet<Enum.MonsterType> requiredRaces;
@ -91,7 +91,7 @@ public class ItemBase {
public ItemBase(ResultSet rs) throws SQLException { public ItemBase(ResultSet rs) throws SQLException {
this.uuid = rs.getInt("ID"); this.uuid = rs.getInt("ID");
this.name = rs.getString("name");
this.durability = rs.getInt("durability"); this.durability = rs.getInt("durability");
this.value = rs.getInt("value"); this.value = rs.getInt("value");
this.weight = rs.getShort("weight"); this.weight = rs.getShort("weight");

111
src/engine/objects/ItemFactory.java

@ -83,6 +83,7 @@ public class ItemFactory {
boolean useWarehouse = false; boolean useWarehouse = false;
ItemBase ib = ItemBase.getItemBase(itemID); ItemBase ib = ItemBase.getItemBase(itemID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemID);
if (ib == null) if (ib == null)
return null; return null;
@ -127,19 +128,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) { if (overdraft > 0 && !useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + " " + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + " " + template.item_base_name);
return null; return null;
} }
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) { if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + template.item_base_name);
return null; return null;
} }
if (overdraft > resources.get(ItemBase.GOLD_ITEM_BASE)) { if (overdraft > resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + " " + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + " " + template.item_base_name);
return null; return null;
} }
@ -156,11 +157,11 @@ public class ItemFactory {
overdraft += buildingWithdraw; overdraft += buildingWithdraw;
if (!useWarehouse) { if (!useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
return null; return null;
} else { } else {
if (overdraft > resources.get(ItemBase.GOLD_ITEM_BASE)) { if (overdraft > resources.get(ItemBase.GOLD_ITEM_BASE)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
return null; return null;
} }
} }
@ -169,7 +170,7 @@ public class ItemFactory {
if (overdraft > 0) if (overdraft > 0)
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item"); //ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName()); Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
return null; return null;
} }
@ -257,7 +258,7 @@ public class ItemFactory {
if (galvorAmount > 0 || wormwoodAmount > 0) if (galvorAmount > 0 || wormwoodAmount > 0)
if (!useWarehouse) { if (!useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "This item requires resources to roll! Please make sure the forge is protected to access the warehouse." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "This item requires resources to roll! Please make sure the forge is protected to access the warehouse." + template.item_base_name);
return null; return null;
} }
@ -265,13 +266,13 @@ public class ItemFactory {
if (galvorAmount > 0) { if (galvorAmount > 0) {
if (Warehouse.isResourceLocked(cityWarehouse, galvor)) { if (Warehouse.isResourceLocked(cityWarehouse, galvor)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name);
return null; return null;
} }
if (cityWarehouse.resources.get(galvor) < galvorAmount) { if (cityWarehouse.resources.get(galvor) < galvorAmount) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name);
return null; return null;
} }
} }
@ -279,13 +280,13 @@ public class ItemFactory {
if (wormwoodAmount > 0) { if (wormwoodAmount > 0) {
if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) { if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + template.item_base_name);
return null; return null;
} }
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) { if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + template.item_base_name);
return null; return null;
} }
} }
@ -296,7 +297,7 @@ public class ItemFactory {
if (!useWarehouse) { if (!useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + template.item_base_name);
return null; return null;
} }
prefix = PowersManager.getEffectByToken(pToken); prefix = PowersManager.getEffectByToken(pToken);
@ -316,19 +317,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) { if (overdraft > 0 && !useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name);
return null; return null;
} }
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) { if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
return null; return null;
} }
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) { if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
return null; return null;
} }
prefixResourceCosts = prefix.getResourcesForEffect(); prefixResourceCosts = prefix.getResourcesForEffect();
@ -349,7 +350,7 @@ public class ItemFactory {
if (!useWarehouse) { if (!useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + template.item_base_name);
return null; return null;
} }
suffix = PowersManager.getEffectByToken(sToken); suffix = PowersManager.getEffectByToken(sToken);
@ -370,19 +371,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) { if (overdraft > 0 && !useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name);
return null; return null;
} }
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) { if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
return null; return null;
} }
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) { if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
return null; return null;
} }
@ -410,19 +411,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) { if (overdraft > 0 && !useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name);
return null; return null;
} }
if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) { if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
return null; return null;
} }
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) { if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
return null; return null;
} }
@ -437,11 +438,11 @@ public class ItemFactory {
overdraft += buildingWithdraw; overdraft += buildingWithdraw;
if (!useWarehouse) { if (!useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
return null; return null;
} else { } else {
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) { if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
return null; return null;
} }
} }
@ -450,7 +451,7 @@ public class ItemFactory {
if (overdraft > 0 && useWarehouse) if (overdraft > 0 && useWarehouse)
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item"); //ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName()); Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
return null; return null;
} }
@ -458,7 +459,7 @@ public class ItemFactory {
if (prefix != null) { if (prefix != null) {
if (!useWarehouse) { if (!useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Cannot Resource Roll without access to the warehouse! Make sure the forge is currently protected." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Cannot Resource Roll without access to the warehouse! Make sure the forge is currently protected." + template.item_base_name);
return null; return null;
} }
@ -478,7 +479,7 @@ public class ItemFactory {
if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item"); //ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName()); Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
return null; return null;
} }
} }
@ -490,7 +491,7 @@ public class ItemFactory {
int creationAmount = suffixResourceCosts.get(ibResources); int creationAmount = suffixResourceCosts.get(ibResources);
if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) { if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) {
ChatManager.chatSystemError(pc, ibResources.getName() + " is locked!" + ib.getName()); ChatManager.chatSystemError(pc, ibResources.getName() + " is locked!" + template.item_base_name);
return null; return null;
} }
@ -500,7 +501,7 @@ public class ItemFactory {
amount = oldAmount; amount = oldAmount;
if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item"); //ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName()); Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
return null; return null;
} }
} }
@ -518,21 +519,21 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) { if (overdraft > 0 && !useWarehouse) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name);
return null; return null;
} }
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) { if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
return null; return null;
} }
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) { if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
return null; return null;
} }
} }
@ -541,11 +542,11 @@ public class ItemFactory {
overdraft += buildingWithdraw; overdraft += buildingWithdraw;
if (!useWarehouse) { if (!useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
return null; return null;
} else { } else {
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) { if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
return null; return null;
} }
} }
@ -554,7 +555,7 @@ public class ItemFactory {
if (overdraft > 0) if (overdraft > 0)
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item"); //ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName()); Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
return null; return null;
} }
@ -562,7 +563,7 @@ public class ItemFactory {
if (galvorAmount > 0) { if (galvorAmount > 0) {
if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name);
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl "); Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null; return null;
} }
@ -570,7 +571,7 @@ public class ItemFactory {
if (wormwoodAmount > 0) { if (wormwoodAmount > 0) {
if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + template.item_base_name);
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl "); Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null; return null;
} }
@ -657,6 +658,7 @@ public class ItemFactory {
ModTableEntry suffixEntry = null; ModTableEntry suffixEntry = null;
ItemBase ib = ItemBase.getItemBase(itemBaseID); ItemBase ib = ItemBase.getItemBase(itemBaseID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
if (ib == null) if (ib == null)
return null; return null;
@ -689,7 +691,7 @@ public class ItemFactory {
} }
if (prefixMod == 0 && suffixMod == 0) { if (prefixMod == 0 && suffixMod == 0) {
Logger.info("Failed to find modTables for item " + ib.getName()); Logger.info("Failed to find modTables for item " + template.item_base_name);
return null; return null;
} }
@ -782,6 +784,7 @@ public class ItemFactory {
return null; return null;
ItemBase ib = ItemBase.getItemBase(itemID); ItemBase ib = ItemBase.getItemBase(itemID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemID);
if (ib == null) if (ib == null)
return null; return null;
@ -853,24 +856,24 @@ public class ItemFactory {
if (galvorAmount > 0) { if (galvorAmount > 0) {
if (Warehouse.isResourceLocked(cityWarehouse, galvor)) { if (Warehouse.isResourceLocked(cityWarehouse, galvor)) {
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name);
return null; return null;
} }
if (cityWarehouse.resources.get(galvor) < galvorAmount) { if (cityWarehouse.resources.get(galvor) < galvorAmount) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name);
return null; return null;
} }
} }
if (wormwoodAmount > 0) { if (wormwoodAmount > 0) {
if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) { if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) {
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name);
return null; return null;
} }
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) { if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name);
return null; return null;
} }
} }
@ -904,18 +907,18 @@ public class ItemFactory {
int overdraft = BuildingManager.GetOverdraft(forge, costToCreate); int overdraft = BuildingManager.GetOverdraft(forge, costToCreate);
if (overdraft > 0 && !useWarehouse) { if (overdraft > 0 && !useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name);
return null; return null;
} }
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) { if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
return null; return null;
} }
if (useWarehouse && overdraft > resources.get(goldIB)) { if (useWarehouse && overdraft > resources.get(goldIB)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
return null; return null;
} }
@ -923,11 +926,11 @@ public class ItemFactory {
overdraft += buildingWithdraw; overdraft += buildingWithdraw;
if (!useWarehouse) { if (!useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
return null; return null;
} else { } else {
if (overdraft > resources.get(goldIB)) { if (overdraft > resources.get(goldIB)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
return null; return null;
} }
} }
@ -955,18 +958,18 @@ public class ItemFactory {
int overdraft = BuildingManager.GetOverdraft(forge, total); int overdraft = BuildingManager.GetOverdraft(forge, total);
if (overdraft > 0 && !useWarehouse) { if (overdraft > 0 && !useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name);
return null; return null;
} }
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) { if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
return null; return null;
} }
if (useWarehouse && overdraft > resources.get(goldIB)) { if (useWarehouse && overdraft > resources.get(goldIB)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
return null; return null;
} }
@ -974,11 +977,11 @@ public class ItemFactory {
overdraft += buildingWithdraw; overdraft += buildingWithdraw;
if (!useWarehouse) { if (!useWarehouse) {
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
return null; return null;
} else { } else {
if (overdraft > resources.get(goldIB)) { if (overdraft > resources.get(goldIB)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
return null; return null;
} }
} }
@ -1003,7 +1006,7 @@ public class ItemFactory {
if (galvorAmount > 0 && useWarehouse) { if (galvorAmount > 0 && useWarehouse) {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse"); //ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name);
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl "); Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null; return null;
} }
@ -1012,7 +1015,7 @@ public class ItemFactory {
if (wormwoodAmount > 0 && useWarehouse) { if (wormwoodAmount > 0 && useWarehouse) {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse"); //ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) { if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + ib.getName()); ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + template.item_base_name);
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl "); Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null; return null;

6
src/engine/objects/MobEquipment.java

@ -215,17 +215,17 @@ public class MobEquipment extends AbstractGameObject {
if (mobEquipment.itemBase == null) if (mobEquipment.itemBase == null)
name = eb.getName(); name = eb.getName();
else else
name = eb.getName() + ' ' + mobEquipment.itemBase.getName(); name = eb.getName() + ' ' + ItemTemplate.itemTemplates.get(mobEquipment.itemBase.getUUID()).item_base_name;
} else if (eb.isSuffix()) { } else if (eb.isSuffix()) {
if (mobEquipment.itemBase == null) if (mobEquipment.itemBase == null)
name = eb.getName(); name = eb.getName();
else else
name = mobEquipment.itemBase.getName() + ' ' + eb.getName(); name = ItemTemplate.itemTemplates.get(mobEquipment.itemBase.getUUID()).item_base_name + ' ' + eb.getName();
} else { } else {
if (mobEquipment.itemBase == null) if (mobEquipment.itemBase == null)
name = ""; name = "";
else else
name = mobEquipment.itemBase.getName(); name = ItemTemplate.itemTemplates.get(mobEquipment.itemBase.getUUID()).item_base_name;
} }
writer.putInt(eb.getToken()); writer.putInt(eb.getToken());

33
src/engine/objects/Warehouse.java

@ -21,6 +21,7 @@ import engine.net.client.msg.*;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
@ -173,13 +174,15 @@ public class Warehouse extends AbstractWorldObject {
return; return;
} }
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
if (isResourceLocked(warehouse, ib)) { if (isResourceLocked(warehouse, ib)) {
ChatManager.chatSystemInfo(player, "You cannot withdrawl a locked resource."); ChatManager.chatSystemInfo(player, "You cannot withdrawl a locked resource.");
return; return;
} }
if (!withdraw(warehouse, player, ib, withdrawAmount, true, true)) { if (!withdraw(warehouse, player, ib, withdrawAmount, true, true)) {
ChatManager.chatGuildError(player, "Failed to withdrawl " + ib.getName() + '.'); ChatManager.chatGuildError(player, "Failed to withdrawl " + template.item_base_name + '.');
Logger.debug(player.getName() + " Failed to withdrawl =" + ib.getName() + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID()); Logger.debug(player.getName() + " Failed to withdrawl =" + template.item_base_name + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID());
return; return;
} }
@ -341,7 +344,7 @@ public class Warehouse extends AbstractWorldObject {
if (resource.getItemBase().getType().equals(Enum.ItemType.GOLD)) if (resource.getItemBase().getType().equals(Enum.ItemType.GOLD))
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(resource.getItemBase().getName().toUpperCase()); resourceType = Resource.valueOf(ItemTemplate.itemTemplates.get(resource.getItemBaseID()).item_base_name.toUpperCase());
if (transaction) if (transaction)
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount); AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);
@ -468,7 +471,7 @@ public class Warehouse extends AbstractWorldObject {
public static synchronized void depositRealmTaxes(PlayerCharacter taxer, ItemBase ib, int amount, Warehouse warehouse) { public static synchronized void depositRealmTaxes(PlayerCharacter taxer, ItemBase ib, int amount, Warehouse warehouse) {
if (!DepositApproved(ib,amount,warehouse)) if (!DepositApproved(ib, amount, warehouse))
return; return;
int oldAmount = warehouse.resources.get(ib); int oldAmount = warehouse.resources.get(ib);
@ -476,10 +479,12 @@ public class Warehouse extends AbstractWorldObject {
warehouse.resources.put(ib, newAmount); warehouse.resources.put(ib, newAmount);
Resource resourceType; Resource resourceType;
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID());
if (ib.getUUID() == 7) if (ib.getUUID() == 7)
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(ib.getName().toUpperCase()); resourceType = Resource.valueOf(template.item_base_name.toUpperCase());
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCEDEPOSIT, resourceType, amount); AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCEDEPOSIT, resourceType, amount);
@ -490,6 +495,8 @@ public class Warehouse extends AbstractWorldObject {
if (ib == null) if (ib == null)
return; return;
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID());
if (warehouse.resources.get(ib) == null) if (warehouse.resources.get(ib) == null)
return; return;
@ -508,7 +515,7 @@ public class Warehouse extends AbstractWorldObject {
if (ib.getUUID() == 7) if (ib.getUUID() == 7)
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(ib.getName().toUpperCase()); resourceType = Resource.valueOf(template.item_base_name.toUpperCase());
if (building != null) if (building != null)
AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount); AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);
@ -615,16 +622,18 @@ public class Warehouse extends AbstractWorldObject {
int newAmount = oldAmount - amount; int newAmount = oldAmount - amount;
if (!WithdrawApproved(ib,amount, warehouse)) if (!WithdrawApproved(ib, amount, warehouse))
return false; return false;
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID());
warehouse.resources.put(ib, newAmount); warehouse.resources.put(ib, newAmount);
Resource resourceType; Resource resourceType;
if (ib.getUUID() == 7) if (ib.getUUID() == 7)
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(ib.getName().toUpperCase()); resourceType = Resource.valueOf(template.item_base_name.toUpperCase());
if (transaction) if (transaction)
AddTransactionToWarehouse(warehouse, npc.getObjectType(), npc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount); AddTransactionToWarehouse(warehouse, npc.getObjectType(), npc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount);
@ -641,6 +650,8 @@ public class Warehouse extends AbstractWorldObject {
if (ib == null) if (ib == null)
return; return;
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID());
if (warehouse.resources.get(ib) == null) if (warehouse.resources.get(ib) == null)
return; return;
@ -675,7 +686,7 @@ public class Warehouse extends AbstractWorldObject {
if (ib.getUUID() == 7) if (ib.getUUID() == 7)
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(ib.getName().toUpperCase()); resourceType = Resource.valueOf(template.item_base_name.toUpperCase());
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCE, resourceType, amount); AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCE, resourceType, amount);
@ -690,6 +701,8 @@ public class Warehouse extends AbstractWorldObject {
if (ib == null) if (ib == null)
return false; return false;
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID());
if (warehouse.resources.get(ib) == null) if (warehouse.resources.get(ib) == null)
return false; return false;
@ -763,7 +776,7 @@ public class Warehouse extends AbstractWorldObject {
if (ib.getUUID() == 7) if (ib.getUUID() == 7)
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(ib.getName().toUpperCase()); resourceType = Resource.valueOf(template.item_base_name.toUpperCase());
if (transaction) if (transaction)
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount); AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount);

Loading…
Cancel
Save