Browse Source

resource dupe

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
2d93e408c3
  1. 24
      src/engine/net/client/ClientMessagePump.java
  2. 16
      src/engine/objects/CharacterItemManager.java

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

@ -1444,11 +1444,25 @@ public class ClientMessagePump implements NetMsgHandler {
return; return;
} }
buy = Item.createItemForPlayer(sourcePlayer, ib); if(ib.getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
if (buy != null) { int count = 1;
me.transferEnchants(buy); for(Item item : itemMan.getInventory()){
itemMan.addItemToInventory(buy); if(item.getItemBaseID() == ib.getUUID()){
//itemMan.updateInventory(); if(item.getNumOfItems() + count <= Warehouse.getMaxResources().get(ib.getUUID())){
count += item.getNumOfItems();
itemMan.delete(item);
}
}
}
Item resource = new MobLoot(sourcePlayer,ib,count,false).promoteToItem(sourcePlayer);
itemMan.addItemToInventory(resource);
}else {
buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) {
me.transferEnchants(buy);
itemMan.addItemToInventory(buy);
//itemMan.updateInventory();
}
} }
} }
} }

16
src/engine/objects/CharacterItemManager.java

@ -1255,21 +1255,7 @@ public class CharacterItemManager {
return false; return false;
} }
} }
if(ItemBase.getItemBase(i.getItemBaseID()).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
int count = i.getNumOfItems();
for(Item item : this.inventory){
if(item.getItemBaseID() == i.getItemBaseID()){
if(item.getNumOfItems() + count <= Warehouse.getMaxResources().get(i.getItemBaseID())){
count += item.getNumOfItems();
delete(item);
}
}
}
Item resource = new MobLoot(this.getOwner(),i.getItemBase(),count,false).promoteToItem((PlayerCharacter)this.getOwner());
this.inventory.add(resource);
this.itemIDtoType.put(resource.getObjectUUID(), resource.getObjectType().ordinal());
return true;
}
this.inventory.add(i); this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
return true; return true;

Loading…
Cancel
Save