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. 8
      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. 29
      src/engine/objects/Warehouse.java

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

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

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

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

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

@ -51,7 +51,8 @@ public class PrintBankCmd extends AbstractDevCmd { @@ -51,7 +51,8 @@ public class PrintBankCmd extends AbstractDevCmd {
ArrayList<Item> list = cim.getBank();
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
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();
if (gold != null)

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

@ -33,7 +33,8 @@ public class PrintBonusesCmd extends AbstractDevCmd { @@ -33,7 +33,8 @@ public class PrintBonusesCmd extends AbstractDevCmd {
if (target instanceof Item) {
type = "Item";
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) {
tar = (AbstractCharacter) target;
name = ((AbstractCharacter) tar).getFirstName();

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

@ -65,7 +65,8 @@ public class PrintEquipCmd extends AbstractDevCmd { @@ -65,7 +65,8 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot : tarMob.getEquip().keySet()) {
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;
}
@ -75,7 +76,8 @@ public class PrintEquipCmd extends AbstractDevCmd { @@ -75,7 +76,8 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot : tarMob.getEquip().keySet()) {
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;
}
@ -85,7 +87,8 @@ public class PrintEquipCmd extends AbstractDevCmd { @@ -85,7 +87,8 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Integer slot : list.keySet()) {
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 { @@ -82,7 +82,8 @@ public class PrintInventoryCmd extends AbstractDevCmd {
byte charges = item.getChargesRemaining();
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
goldCount += item.getNumOfItems();
}

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

@ -50,7 +50,8 @@ public class PrintVaultCmd extends AbstractDevCmd { @@ -50,7 +50,8 @@ public class PrintVaultCmd extends AbstractDevCmd {
ArrayList<Item> list = cim.getVault();
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
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();
if (gold != null)

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

@ -35,7 +35,8 @@ public class SimulateBootyCmd extends AbstractDevCmd { @@ -35,7 +35,8 @@ public class SimulateBootyCmd extends AbstractDevCmd {
for (BootySetEntry entry : LootManager._bootySetMap.get(mob.bootySet)) {
ItemBase item = ItemBase.getItemBase(entry.itemBase);
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 { @@ -242,8 +242,11 @@ public enum BuildingManager {
if (resourceAmount <= 0)
continue;
if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true))
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + resourceBase.getName());
if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true)) {
ItemTemplate template = ItemTemplate.itemTemplates.get(resourceBase.getUUID());
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + template.item_base_name);
}
}
break;

3
src/engine/gameManager/ChatManager.java

@ -612,7 +612,8 @@ public enum ChatManager { @@ -612,7 +612,8 @@ public enum ChatManager {
name = amount + " gold ";
else {
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 (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
name = "an " + iName + ' ';

8
src/engine/gameManager/LootManager.java

@ -83,10 +83,14 @@ public enum LootManager { @@ -83,10 +83,14 @@ public enum LootManager {
for (Item it : mob.getInventory()) {
ItemBase ib = it.getItemBase();
if (ib == null)
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.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
DispatchMessage.dispatchMsgToAll(chatMsg);

6
src/engine/objects/City.java

@ -1381,10 +1381,14 @@ public class City extends AbstractWorldObject { @@ -1381,10 +1381,14 @@ public class City extends AbstractWorldObject {
for (Integer itemBaseID : resources) {
ItemBase ib = ItemBase.getItemBase(itemBaseID);
if (ib == null)
continue;
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
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;
}

9
src/engine/objects/Item.java

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

4
src/engine/objects/ItemBase.java

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

111
src/engine/objects/ItemFactory.java

@ -83,6 +83,7 @@ public class ItemFactory { @@ -83,6 +83,7 @@ public class ItemFactory {
boolean useWarehouse = false;
ItemBase ib = ItemBase.getItemBase(itemID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemID);
if (ib == null)
return null;
@ -127,19 +128,19 @@ public class ItemFactory { @@ -127,19 +128,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) {
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;
}
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
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;
}
if (overdraft > resources.get(ItemBase.GOLD_ITEM_BASE)) {
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;
}
@ -156,11 +157,11 @@ public class ItemFactory { @@ -156,11 +157,11 @@ public class ItemFactory {
overdraft += buildingWithdraw;
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;
} else {
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;
}
}
@ -169,7 +170,7 @@ public class ItemFactory { @@ -169,7 +170,7 @@ public class ItemFactory {
if (overdraft > 0)
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//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;
}
@ -257,7 +258,7 @@ public class ItemFactory { @@ -257,7 +258,7 @@ public class ItemFactory {
if (galvorAmount > 0 || wormwoodAmount > 0)
if (!useWarehouse) {
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;
}
@ -265,13 +266,13 @@ public class ItemFactory { @@ -265,13 +266,13 @@ public class ItemFactory {
if (galvorAmount > 0) {
if (Warehouse.isResourceLocked(cityWarehouse, galvor)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name);
return null;
}
if (cityWarehouse.resources.get(galvor) < galvorAmount) {
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;
}
}
@ -279,13 +280,13 @@ public class ItemFactory { @@ -279,13 +280,13 @@ public class ItemFactory {
if (wormwoodAmount > 0) {
if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + ib.getName());
ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + template.item_base_name);
return null;
}
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
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;
}
}
@ -296,7 +297,7 @@ public class ItemFactory { @@ -296,7 +297,7 @@ public class ItemFactory {
if (!useWarehouse) {
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;
}
prefix = PowersManager.getEffectByToken(pToken);
@ -316,19 +317,19 @@ public class ItemFactory { @@ -316,19 +317,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) {
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;
}
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
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;
}
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
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;
}
prefixResourceCosts = prefix.getResourcesForEffect();
@ -349,7 +350,7 @@ public class ItemFactory { @@ -349,7 +350,7 @@ public class ItemFactory {
if (!useWarehouse) {
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;
}
suffix = PowersManager.getEffectByToken(sToken);
@ -370,19 +371,19 @@ public class ItemFactory { @@ -370,19 +371,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) {
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;
}
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
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;
}
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
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;
}
@ -410,19 +411,19 @@ public class ItemFactory { @@ -410,19 +411,19 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) {
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;
}
if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
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;
}
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
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;
}
@ -437,11 +438,11 @@ public class ItemFactory { @@ -437,11 +438,11 @@ public class ItemFactory {
overdraft += buildingWithdraw;
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;
} else {
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;
}
}
@ -450,7 +451,7 @@ public class ItemFactory { @@ -450,7 +451,7 @@ public class ItemFactory {
if (overdraft > 0 && useWarehouse)
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//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;
}
@ -458,7 +459,7 @@ public class ItemFactory { @@ -458,7 +459,7 @@ public class ItemFactory {
if (prefix != null) {
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;
}
@ -478,7 +479,7 @@ public class ItemFactory { @@ -478,7 +479,7 @@ public class ItemFactory {
if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
//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;
}
}
@ -490,7 +491,7 @@ public class ItemFactory { @@ -490,7 +491,7 @@ public class ItemFactory {
int creationAmount = suffixResourceCosts.get(ibResources);
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;
}
@ -500,7 +501,7 @@ public class ItemFactory { @@ -500,7 +501,7 @@ public class ItemFactory {
amount = oldAmount;
if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
//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;
}
}
@ -518,21 +519,21 @@ public class ItemFactory { @@ -518,21 +519,21 @@ public class ItemFactory {
if (overdraft > 0 && !useWarehouse) {
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;
}
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
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;
}
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
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;
}
}
@ -541,11 +542,11 @@ public class ItemFactory { @@ -541,11 +542,11 @@ public class ItemFactory {
overdraft += buildingWithdraw;
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;
} else {
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;
}
}
@ -554,7 +555,7 @@ public class ItemFactory { @@ -554,7 +555,7 @@ public class ItemFactory {
if (overdraft > 0)
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//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;
}
@ -562,7 +563,7 @@ public class ItemFactory { @@ -562,7 +563,7 @@ public class ItemFactory {
if (galvorAmount > 0) {
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 ");
return null;
}
@ -570,7 +571,7 @@ public class ItemFactory { @@ -570,7 +571,7 @@ public class ItemFactory {
if (wormwoodAmount > 0) {
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 ");
return null;
}
@ -657,6 +658,7 @@ public class ItemFactory { @@ -657,6 +658,7 @@ public class ItemFactory {
ModTableEntry suffixEntry = null;
ItemBase ib = ItemBase.getItemBase(itemBaseID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
if (ib == null)
return null;
@ -689,7 +691,7 @@ public class ItemFactory { @@ -689,7 +691,7 @@ public class ItemFactory {
}
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;
}
@ -782,6 +784,7 @@ public class ItemFactory { @@ -782,6 +784,7 @@ public class ItemFactory {
return null;
ItemBase ib = ItemBase.getItemBase(itemID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemID);
if (ib == null)
return null;
@ -853,24 +856,24 @@ public class ItemFactory { @@ -853,24 +856,24 @@ public class ItemFactory {
if (galvorAmount > 0) {
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;
}
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;
}
}
if (wormwoodAmount > 0) {
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;
}
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;
}
}
@ -904,18 +907,18 @@ public class ItemFactory { @@ -904,18 +907,18 @@ public class ItemFactory {
int overdraft = BuildingManager.GetOverdraft(forge, costToCreate);
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;
}
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
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;
}
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;
}
@ -923,11 +926,11 @@ public class ItemFactory { @@ -923,11 +926,11 @@ public class ItemFactory {
overdraft += buildingWithdraw;
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;
} else {
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;
}
}
@ -955,18 +958,18 @@ public class ItemFactory { @@ -955,18 +958,18 @@ public class ItemFactory {
int overdraft = BuildingManager.GetOverdraft(forge, total);
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;
}
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
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;
}
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;
}
@ -974,11 +977,11 @@ public class ItemFactory { @@ -974,11 +977,11 @@ public class ItemFactory {
overdraft += buildingWithdraw;
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;
} else {
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;
}
}
@ -1003,7 +1006,7 @@ public class ItemFactory { @@ -1003,7 +1006,7 @@ public class ItemFactory {
if (galvorAmount > 0 && useWarehouse) {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
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 ");
return null;
}
@ -1012,7 +1015,7 @@ public class ItemFactory { @@ -1012,7 +1015,7 @@ public class ItemFactory {
if (wormwoodAmount > 0 && useWarehouse) {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
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 ");
return null;

6
src/engine/objects/MobEquipment.java

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

29
src/engine/objects/Warehouse.java

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

Loading…
Cancel
Save