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