Browse Source

Resource Auto Stacking

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
15136518a3
  1. 11
      src/engine/net/client/ClientMessagePump.java
  2. 10
      src/engine/objects/CharacterItemManager.java
  3. 2
      src/engine/objects/Warehouse.java

11
src/engine/net/client/ClientMessagePump.java

@ -445,8 +445,6 @@ public class ClientMessagePump implements NetMsgHandler {
dispatch = Dispatch.borrow(player, msg); dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
itemManager.StackResources();
} }
private static void transferItemFromVaultToInventory(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin) { private static void transferItemFromVaultToInventory(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin) {
@ -460,8 +458,6 @@ public class ClientMessagePump implements NetMsgHandler {
if (player.getAccount() == null) if (player.getAccount() == null)
return; return;
player.getAccount().transferItemFromVaultToInventory(msg, origin); 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 //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); ChatManager.chatGroupInfoCanSee(player, text);
} }
if(item.getItemBase().getType().equals(ItemType.RESOURCE)){
player.getCharItemManager().StackResources();
}
} catch (Exception e) { } catch (Exception e) {
Logger.info(e.getMessage()); Logger.info(e.getMessage());
} finally { } finally {
@ -1614,9 +1606,6 @@ public class ClientMessagePump implements NetMsgHandler {
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
itemMan.updateInventory(); itemMan.updateInventory();
} }
if(buy.getItemBase().getType().equals(ItemType.RESOURCE)){
itemMan.StackResources();
}
} finally { } finally {
origin.buyLock.unlock(); origin.buyLock.unlock();
} }

10
src/engine/objects/CharacterItemManager.java

@ -776,8 +776,6 @@ public class CharacterItemManager {
this.commitTrade(); this.commitTrade();
this.closeTradeWindow(ctwm1, false); this.closeTradeWindow(ctwm1, false);
other.getCharItemManager().closeTradeWindow(ctwm2, false); other.getCharItemManager().closeTradeWindow(ctwm2, false);
other.getCharItemManager().StackResources();
this.StackResources();
} }
return true; return true;
} }
@ -1257,9 +1255,6 @@ public class CharacterItemManager {
} }
this.inventory.add(i); this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
if(i.getItemBase().getType().equals(ItemType.RESOURCE)){
this.StackResources();
}
return true; return true;
} }
@ -2317,6 +2312,7 @@ public class CharacterItemManager {
* Update the player's inventory window by resending the entire contents. * Update the player's inventory window by resending the entire contents.
*/ */
public void updateInventory() { public void updateInventory() {
this.StackResources();
this.updateInventory(this.getInventory(), true); this.updateInventory(this.getInventory(), true);
} }
@ -2628,7 +2624,7 @@ public class CharacterItemManager {
//populate resources hashmap with items currently in inventory //populate resources hashmap with items currently in inventory
for(Item item : this.getInventory()){ for(Item item : this.getInventory()){
if(Warehouse.getMaxResources().get(item.getItemBaseID()) != null && Warehouse.getMaxResources().get(item.getItemBaseID()) != 0){ 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); resources.get(item.getItemBase()).add(item);
} else{ } else{
resources.put(item.getItemBase(),new ArrayList<>()); resources.put(item.getItemBase(),new ArrayList<>());
@ -2670,7 +2666,7 @@ public class CharacterItemManager {
this.delete(purged); this.delete(purged);
} }
this.updateInventory(); //this.updateInventory();
} }
} }

2
src/engine/objects/Warehouse.java

@ -217,8 +217,6 @@ public class Warehouse extends AbstractWorldObject {
vrm.configure(); vrm.configure();
dispatch = Dispatch.borrow(player, vrm); dispatch = Dispatch.borrow(player, vrm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
player.getCharItemManager().StackResources();
} }
public static void warehouseLock(MerchantMsg msg, PlayerCharacter player, NPC npc, ClientConnection origin) { public static void warehouseLock(MerchantMsg msg, PlayerCharacter player, NPC npc, ClientConnection origin) {

Loading…
Cancel
Save