|
|
|
@ -25,6 +25,7 @@ import org.pmw.tinylog.Logger;
@@ -25,6 +25,7 @@ import org.pmw.tinylog.Logger;
|
|
|
|
|
import java.sql.ResultSet; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.EnumSet; |
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
public class Warehouse extends AbstractWorldObject { |
|
|
|
@ -550,12 +551,9 @@ public class Warehouse extends AbstractWorldObject {
@@ -550,12 +551,9 @@ public class Warehouse extends AbstractWorldObject {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static synchronized void transferResources(Warehouse warehouse, PlayerCharacter taxer, TaxResourcesMsg msg, ArrayList<Integer> realmResources, float taxPercent) { |
|
|
|
|
public static synchronized void transferResources(Warehouse warehouse, PlayerCharacter taxer, TaxResourcesMsg msg, ArrayList<Enum.ResourceType> realmResources, float taxPercent) { |
|
|
|
|
|
|
|
|
|
for (int templateID : realmResources) { |
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID); |
|
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(templateID); |
|
|
|
|
for (Enum.ResourceType resourceType : realmResources) { |
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
|
return; |
|
|
|
@ -588,12 +586,7 @@ public class Warehouse extends AbstractWorldObject {
@@ -588,12 +586,7 @@ public class Warehouse extends AbstractWorldObject {
|
|
|
|
|
depositRealmTaxes(taxer, resourceType, amount, warehouse); |
|
|
|
|
Enum.ResourceType resource; |
|
|
|
|
|
|
|
|
|
if (resourceType.equals(Enum.ResourceType.GOLD)) |
|
|
|
|
resource = Enum.ResourceType.GOLD; |
|
|
|
|
else |
|
|
|
|
resource = Enum.ResourceType.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
|
|
|
|
|
|
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCE, resource, amount); |
|
|
|
|
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCE, resourceType, amount); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -751,10 +744,12 @@ public class Warehouse extends AbstractWorldObject {
@@ -751,10 +744,12 @@ public class Warehouse extends AbstractWorldObject {
|
|
|
|
|
|
|
|
|
|
public static boolean isEmpty(Warehouse warehouse) { |
|
|
|
|
int amount = 0; |
|
|
|
|
for (ItemBase ib : ItemBase.getResourceList()) { |
|
|
|
|
|
|
|
|
|
for (Enum.ResourceType resourceType : EnumSet.allOf(Enum.ResourceType.class)) { |
|
|
|
|
amount += warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
if (amount > 0) |
|
|
|
|
return false; |
|
|
|
|
amount += warehouse.resources.get(ib); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -773,9 +768,9 @@ public class Warehouse extends AbstractWorldObject {
@@ -773,9 +768,9 @@ public class Warehouse extends AbstractWorldObject {
|
|
|
|
|
warehouse.transactions.add(transaction); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isAboveCap(Warehouse warehouse, ItemBase ib, int deposit) { |
|
|
|
|
int newAmount = warehouse.resources.get(ib) + deposit; |
|
|
|
|
return newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit; |
|
|
|
|
public static boolean isAboveCap(Warehouse warehouse, Enum.ResourceType resourceType, int deposit) { |
|
|
|
|
int newAmount = warehouse.resources.get(resourceType) + deposit; |
|
|
|
|
return newAmount > resourceType.deposit_limit; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|