diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 58c3a06f..fde2ca1d 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -70,7 +70,7 @@ public class Warehouse { } - public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) { + public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter playerCharacter, NPC npc) { Building warehouseBuilding; Warehouse warehouse; @@ -83,7 +83,7 @@ public class Warehouse { return; depositAmount = msg.getAmount(); - CharacterItemManager itemMan = player.charItemManager; + CharacterItemManager itemMan = playerCharacter.charItemManager; if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) return; @@ -93,25 +93,28 @@ public class Warehouse { if (warehouseBuilding == null) return; - warehouse = warehouseBuilding.getCity().warehouse; + City city = warehouseBuilding.getCity(); - if (warehouse == null) + if (city == null) return; + warehouse = city.warehouse; + + if (warehouse == null) + return; - if (!deposit(player, resource, depositAmount, true, true, warehouse)) { + if (!deposit(playerCharacter, resource, depositAmount, true, true, warehouse)) return; - } - ViewResourcesMsg vrm = new ViewResourcesMsg(player); - vrm.setGuild(player.getGuild()); + ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter); + vrm.setGuild(playerCharacter.getGuild()); vrm.setWarehouseBuilding(warehouseBuilding); vrm.configure(); - dispatch = Dispatch.borrow(player, vrm); + dispatch = Dispatch.borrow(playerCharacter, vrm); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } - public static void warehouseWithdraw(MerchantMsg msg, PlayerCharacter player, NPC npc) { + public static void warehouseWithdraw(MerchantMsg msg, PlayerCharacter playerCharacter, NPC npc) { int withdrawAmount; Building warehouseBuilding; @@ -124,7 +127,7 @@ public class Warehouse { if (warehouseBuilding == null) return; - if (player.getGuild() != warehouseBuilding.getGuild() || !GuildStatusController.isInnerCouncil(player.getGuildStatus())) + if (playerCharacter.getGuild() != warehouseBuilding.getGuild() || !GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus())) return; City city = warehouseBuilding.getCity(); @@ -140,24 +143,24 @@ public class Warehouse { mbEnums.ResourceType resourceType = mbEnums.ResourceType.hashLookup.get(msg.getHashID()); if (isResourceLocked(warehouse, resourceType)) { - ChatManager.chatSystemInfo(player, "You cannot withdrawl a locked resource."); + ChatManager.chatSystemInfo(playerCharacter, "You cannot withdrawl a locked resource."); return; } - if (!withdraw(warehouse, player, resourceType, withdrawAmount, true, true)) { - ChatManager.chatGuildError(player, "Failed to withdrawl " + resourceType.name() + '.'); - Logger.debug(player.getName() + " Failed to withdrawl =" + resourceType.name() + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID()); + if (!withdraw(warehouse, playerCharacter, resourceType, withdrawAmount, true, true)) { + ChatManager.chatGuildError(playerCharacter, "Failed to withdrawl " + resourceType.name() + '.'); + Logger.debug(playerCharacter.getName() + " Failed to withdrawl =" + resourceType.name() + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID()); return; } - ViewResourcesMsg vrm = new ViewResourcesMsg(player); - vrm.setGuild(player.getGuild()); + ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter); + vrm.setGuild(playerCharacter.getGuild()); vrm.setWarehouseBuilding(warehouseBuilding); vrm.configure(); - dispatch = Dispatch.borrow(player, vrm); + dispatch = Dispatch.borrow(playerCharacter, vrm); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } - public static void warehouseLock(MerchantMsg msg, PlayerCharacter player, NPC npc) { + public static void warehouseLock(MerchantMsg msg, PlayerCharacter playerCharacter, NPC npc) { Building warehouseBuilding; Warehouse warehouse; int hashID; @@ -169,7 +172,7 @@ public class Warehouse { if (warehouseBuilding == null) return; - if (player.getGuild() != warehouseBuilding.getGuild() || !GuildStatusController.isInnerCouncil(player.getGuildStatus())) + if (playerCharacter.getGuild() != warehouseBuilding.getGuild() || !GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus())) return; City city = warehouseBuilding.getCity(); @@ -190,11 +193,11 @@ public class Warehouse { worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); if (worked) { - ViewResourcesMsg vrm = new ViewResourcesMsg(player); - vrm.setGuild(player.getGuild()); + ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter); + vrm.setGuild(playerCharacter.getGuild()); vrm.setWarehouseBuilding(warehouseBuilding); vrm.configure(); - dispatch = Dispatch.borrow(player, vrm); + dispatch = Dispatch.borrow(playerCharacter, vrm); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } else warehouse.locked.add(resourceType); @@ -207,26 +210,26 @@ public class Warehouse { worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); if (worked) { - ViewResourcesMsg vrm = new ViewResourcesMsg(player); - vrm.setGuild(player.getGuild()); + ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter); + vrm.setGuild(playerCharacter.getGuild()); vrm.setWarehouseBuilding(warehouseBuilding); vrm.configure(); - dispatch = Dispatch.borrow(player, vrm); + dispatch = Dispatch.borrow(playerCharacter, vrm); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } else warehouse.locked.remove(resourceType); } - public static synchronized boolean deposit(PlayerCharacter pc, Item resource, int amount, boolean removeFromInventory, boolean transaction, Warehouse warehouse) { + public static synchronized boolean deposit(PlayerCharacter playerCharacter, Item resource, int amount, boolean removeFromInventory, boolean transaction, Warehouse warehouse) { - ClientConnection origin = pc.getClientConnection(); + ClientConnection origin = playerCharacter.getClientConnection(); if (origin == null) return false; if (amount < 0) { - Logger.info(pc.getFirstName() + " Attempting to Dupe!!!!!!"); + Logger.info(playerCharacter.getFirstName() + " Attempting to Dupe!!!!!!"); return false; } @@ -235,20 +238,20 @@ public class Warehouse { if (warehouse.resources.get(resourceType) == null) return false; - CharacterItemManager itemMan = pc.charItemManager; + CharacterItemManager itemMan = playerCharacter.charItemManager; if (itemMan == null) return false; if (itemMan.getGoldTrading() > 0) { - ErrorPopupMsg.sendErrorPopup(pc, 195); + ErrorPopupMsg.sendErrorPopup(playerCharacter, 195); return false; } if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) return false; - if (!resource.validForInventory(origin, pc, itemMan)) + if (!resource.validForInventory(origin, playerCharacter, itemMan)) return false; if (resource.getNumOfItems() < amount) @@ -273,9 +276,9 @@ public class Warehouse { if (!itemMan.modifyInventoryGold(-amount)) return false; - UpdateGoldMsg ugm = new UpdateGoldMsg(pc); + UpdateGoldMsg ugm = new UpdateGoldMsg(playerCharacter); ugm.configure(); - Dispatch dispatch = Dispatch.borrow(pc, ugm); + Dispatch dispatch = Dispatch.borrow(playerCharacter, ugm); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); itemMan.updateInventory(); @@ -304,7 +307,7 @@ public class Warehouse { resourceType = mbEnums.ResourceType.valueOf(ItemTemplate.templates.get(resource.templateID).item_base_name.toUpperCase()); if (transaction) - AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), mbEnums.TransactionType.DEPOSIT, resourceType, amount); + AddTransactionToWarehouse(warehouse, playerCharacter.getObjectType(), playerCharacter.getObjectUUID(), mbEnums.TransactionType.DEPOSIT, resourceType, amount); return true; } @@ -437,9 +440,9 @@ public class Warehouse { } } - public static synchronized boolean withdraw(Warehouse warehouse, PlayerCharacter pc, mbEnums.ResourceType resourceType, int amount, boolean addToInventory, boolean transaction) { + public static synchronized boolean withdraw(Warehouse warehouse, PlayerCharacter playerCharacter, mbEnums.ResourceType resourceType, int amount, boolean addToInventory, boolean transaction) { - if (pc == null) + if (playerCharacter == null) return false; ItemTemplate template = ItemTemplate.templates.get(resourceType.templateID); @@ -450,22 +453,22 @@ public class Warehouse { if (amount <= 0) return false; - CharacterItemManager itemMan = pc.charItemManager; + CharacterItemManager itemMan = playerCharacter.charItemManager; if (itemMan == null) return false; if (addToInventory) if (!itemMan.hasRoomInventory(template.item_wt * amount)) { - ChatManager.chatSystemInfo(pc, "You can not carry any more of that item."); + ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item."); return false; } if (addToInventory && resourceType.equals(mbEnums.ResourceType.GOLD)) { - if (pc.charItemManager.getGoldInventory().getNumOfItems() + amount > MBServerStatics.PLAYER_GOLD_LIMIT) + if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() + amount > MBServerStatics.PLAYER_GOLD_LIMIT) return false; - if (pc.charItemManager.getGoldInventory().getNumOfItems() + amount < 0) + if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() + amount < 0) return false; } int oldAmount = warehouse.resources.get(resourceType); @@ -486,9 +489,9 @@ public class Warehouse { if (resourceType.equals(mbEnums.ResourceType.GOLD)) { itemMan.addGoldToInventory(amount, false); - UpdateGoldMsg ugm = new UpdateGoldMsg(pc); + UpdateGoldMsg ugm = new UpdateGoldMsg(playerCharacter); ugm.configure(); - Dispatch dispatch = Dispatch.borrow(pc, ugm); + Dispatch dispatch = Dispatch.borrow(playerCharacter, ugm); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); itemMan.updateInventory(); @@ -496,7 +499,7 @@ public class Warehouse { boolean itemWorked = false; Item item = new Item(resourceType.templateID); - item.ownerID = pc.getObjectUUID(); + item.ownerID = playerCharacter.getObjectUUID(); item.ownerType = mbEnums.OwnerType.PlayerCharacter; item.containerType = mbEnums.ItemContainerType.INVENTORY; item.numberOfItems = amount; @@ -515,14 +518,14 @@ public class Warehouse { } if (transaction) - AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), mbEnums.TransactionType.WITHDRAWL, resourceType, amount); + AddTransactionToWarehouse(warehouse, playerCharacter.getObjectType(), playerCharacter.getObjectUUID(), mbEnums.TransactionType.WITHDRAWL, resourceType, amount); return true; } - public static synchronized boolean loot(Warehouse warehouse, PlayerCharacter pc, mbEnums.ResourceType resourceType, int amount, boolean addToInventory) { + public static synchronized boolean loot(Warehouse warehouse, PlayerCharacter playerCharacter, mbEnums.ResourceType resourceType, int amount, boolean addToInventory) { - if (pc == null) + if (playerCharacter == null) return false; ItemTemplate template = ItemTemplate.templates.get(resourceType); @@ -536,13 +539,13 @@ public class Warehouse { if (amount <= 0) return false; - CharacterItemManager itemMan = pc.charItemManager; + CharacterItemManager itemMan = playerCharacter.charItemManager; if (itemMan == null) return false; if (!itemMan.hasRoomInventory(template.item_wt)) { - ChatManager.chatSystemInfo(pc, "You can not carry any more of that item."); + ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item."); return false; } @@ -559,16 +562,16 @@ public class Warehouse { if (resourceType.equals(mbEnums.ResourceType.GOLD)) { itemMan.addGoldToInventory(amount, false); - UpdateGoldMsg ugm = new UpdateGoldMsg(pc); + UpdateGoldMsg ugm = new UpdateGoldMsg(playerCharacter); ugm.configure(); - Dispatch dispatch = Dispatch.borrow(pc, ugm); + Dispatch dispatch = Dispatch.borrow(playerCharacter, ugm); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); itemMan.updateInventory(); } else { boolean itemWorked = false; Item item = new Item(resourceType.templateID); - item.ownerID = pc.getObjectUUID(); + item.ownerID = playerCharacter.getObjectUUID(); item.ownerType = mbEnums.OwnerType.PlayerCharacter; item.containerType = mbEnums.ItemContainerType.INVENTORY; item.numberOfItems = amount;