Refactor warehouse part two.

This commit is contained in:
2024-03-17 09:47:00 -04:00
parent b76a384e1f
commit f3bfdd8a36
15 changed files with 155 additions and 120 deletions
+15 -16
View File
@@ -116,7 +116,7 @@ public class ItemFactory {
city.transactionLock.writeLock().lock();
try {
Warehouse cityWarehouse = city.getWarehouse();
Warehouse cityWarehouse = city.warehouse;
if (cityWarehouse != null && forge.assetIsProtected())
useWarehouse = true;
@@ -163,7 +163,7 @@ public class ItemFactory {
if (overdraft > 0)
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name);
return null;
}
@@ -431,8 +431,7 @@ public class ItemFactory {
if (overdraft > 0 && useWarehouse)
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name);
return null;
}
@@ -460,7 +459,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." + template.item_base_name);
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name);
return null;
}
}
@@ -484,7 +483,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." + template.item_base_name);
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name);
return null;
}
}
@@ -538,7 +537,7 @@ public class ItemFactory {
if (overdraft > 0)
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name);
return null;
}
@@ -547,7 +546,7 @@ public class ItemFactory {
if (galvorAmount > 0) {
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GALVOR, galvorAmount, true)) {
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 for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}
}
@@ -555,7 +554,7 @@ public class ItemFactory {
if (wormwoodAmount > 0) {
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.WORMWOOD, wormwoodAmount, true)) {
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 for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}
}
@@ -790,7 +789,7 @@ public class ItemFactory {
try {
Warehouse cityWarehouse = city.getWarehouse();
Warehouse cityWarehouse = city.warehouse;
if (cityWarehouse != null && forge.assetIsProtected())
useWarehouse = true;
@@ -916,12 +915,12 @@ public class ItemFactory {
if (overdraft > 0) {
if (pc != null) {
if (!Warehouse.withdraw(cityWarehouse, pc, Enum.ResourceType.GOLD, overdraft, false, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}
} else {
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}
}
@@ -967,12 +966,12 @@ public class ItemFactory {
if (pc != null) {
if (!Warehouse.withdraw(cityWarehouse, pc, Enum.ResourceType.GOLD, overdraft, false, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}
} else {
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}
}
@@ -983,7 +982,7 @@ public class ItemFactory {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GALVOR, galvorAmount, true)) {
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 for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}
}
@@ -992,7 +991,7 @@ public class ItemFactory {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.WORMWOOD, wormwoodAmount, true)) {
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 for city " + cityWarehouse.city.getName() + "Failed to Withdrawl ");
return null;
}