From 15136518a325ed840f543c04dab13541f193d013 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 13 May 2024 18:12:30 -0500 Subject: [PATCH] Resource Auto Stacking --- src/engine/net/client/ClientMessagePump.java | 11 ----------- src/engine/objects/CharacterItemManager.java | 10 +++------- src/engine/objects/Warehouse.java | 2 -- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 35c66319..a38d7dd8 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -445,8 +445,6 @@ public class ClientMessagePump implements NetMsgHandler { dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - - itemManager.StackResources(); } private static void transferItemFromVaultToInventory(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin) { @@ -460,8 +458,6 @@ public class ClientMessagePump implements NetMsgHandler { if (player.getAccount() == null) return; player.getAccount().transferItemFromVaultToInventory(msg, origin); - - player.getCharItemManager().StackResources(); } //call this if the transfer fails server side to kick the item back to inventory from vault @@ -994,10 +990,6 @@ public class ClientMessagePump implements NetMsgHandler { ChatManager.chatGroupInfoCanSee(player, text); } - if(item.getItemBase().getType().equals(ItemType.RESOURCE)){ - player.getCharItemManager().StackResources(); - } - } catch (Exception e) { Logger.info(e.getMessage()); } finally { @@ -1614,9 +1606,6 @@ public class ClientMessagePump implements NetMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); itemMan.updateInventory(); } - if(buy.getItemBase().getType().equals(ItemType.RESOURCE)){ - itemMan.StackResources(); - } } finally { origin.buyLock.unlock(); } diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 82e92101..12e2e863 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -776,8 +776,6 @@ public class CharacterItemManager { this.commitTrade(); this.closeTradeWindow(ctwm1, false); other.getCharItemManager().closeTradeWindow(ctwm2, false); - other.getCharItemManager().StackResources(); - this.StackResources(); } return true; } @@ -1257,9 +1255,6 @@ public class CharacterItemManager { } this.inventory.add(i); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); - if(i.getItemBase().getType().equals(ItemType.RESOURCE)){ - this.StackResources(); - } return true; } @@ -2317,6 +2312,7 @@ public class CharacterItemManager { * Update the player's inventory window by resending the entire contents. */ public void updateInventory() { + this.StackResources(); this.updateInventory(this.getInventory(), true); } @@ -2628,7 +2624,7 @@ public class CharacterItemManager { //populate resources hashmap with items currently in inventory for(Item item : this.getInventory()){ if(Warehouse.getMaxResources().get(item.getItemBaseID()) != null && Warehouse.getMaxResources().get(item.getItemBaseID()) != 0){ - if(resources.containsKey(item.getItemBaseID())){ + if(resources.containsKey(item.getItemBase())){ resources.get(item.getItemBase()).add(item); } else{ resources.put(item.getItemBase(),new ArrayList<>()); @@ -2670,7 +2666,7 @@ public class CharacterItemManager { this.delete(purged); } - this.updateInventory(); + //this.updateInventory(); } } diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 7b3adebb..c24513fc 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -217,8 +217,6 @@ public class Warehouse extends AbstractWorldObject { vrm.configure(); dispatch = Dispatch.borrow(player, vrm); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - - player.getCharItemManager().StackResources(); } public static void warehouseLock(MerchantMsg msg, PlayerCharacter player, NPC npc, ClientConnection origin) {