forked from MagicBane/Server
Refactor itembase.name to template.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
return this.customName;
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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 {
|
||||
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");
|
||||
|
||||
@@ -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 {
|
||||
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
|
||||
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 {
|
||||
|
||||
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 {
|
||||
|
||||
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 {
|
||||
|
||||
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 {
|
||||
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
|
||||
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 {
|
||||
|
||||
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 {
|
||||
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 {
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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 {
|
||||
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 {
|
||||
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);
|
||||
@@ -468,7 +471,7 @@ public class Warehouse extends AbstractWorldObject {
|
||||
|
||||
public static synchronized void depositRealmTaxes(PlayerCharacter taxer, ItemBase ib, int amount, Warehouse warehouse) {
|
||||
|
||||
if (!DepositApproved(ib,amount,warehouse))
|
||||
if (!DepositApproved(ib, amount, warehouse))
|
||||
return;
|
||||
|
||||
int oldAmount = warehouse.resources.get(ib);
|
||||
@@ -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 {
|
||||
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 {
|
||||
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);
|
||||
@@ -615,16 +622,18 @@ public class Warehouse extends AbstractWorldObject {
|
||||
|
||||
int newAmount = oldAmount - amount;
|
||||
|
||||
if (!WithdrawApproved(ib,amount, warehouse))
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user