|
|
|
@ -371,34 +371,6 @@ public class Warehouse {
@@ -371,34 +371,6 @@ public class Warehouse {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static synchronized boolean withdraw(Warehouse warehouse, NPC npc, mbEnums.ResourceType resourceType, int amount, boolean transaction) { |
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (amount <= 0) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (oldAmount < amount) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
|
|
|
|
|
|
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) { |
|
|
|
|
warehouse.resources.put(resourceType, oldAmount); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (transaction) |
|
|
|
|
AddTransactionToWarehouse(warehouse, npc.getObjectType(), npc.getObjectUUID(), mbEnums.TransactionType.WITHDRAWL, resourceType, amount); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static synchronized void transferResources(Warehouse warehouse, PlayerCharacter taxer, TaxResourcesMsg msg, ArrayList<mbEnums.ResourceType> realmResources, float taxPercent) { |
|
|
|
|
|
|
|
|
|
for (mbEnums.ResourceType resourceType : realmResources) { |
|
|
|
|