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 { @@ -1444,11 +1444,25 @@ public class ClientMessagePump implements NetMsgHandler {
return;
}
buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) {
me.transferEnchants(buy);
itemMan.addItemToInventory(buy);
//itemMan.updateInventory();
if(ib.getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
int count = 1;
for(Item item : itemMan.getInventory()){
if(item.getItemBaseID() == ib.getUUID()){
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 { @@ -1255,21 +1255,7 @@ public class CharacterItemManager {
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.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
return true;

Loading…
Cancel
Save