Browse Source

stack resources command

mixbane
FatBoy-DOTC 1 month ago
parent
commit
b8f3c4b240
  1. 33
      src/engine/gameManager/ChatManager.java

33
src/engine/gameManager/ChatManager.java

@ -29,10 +29,7 @@ import engine.server.world.WorldServer;
import engine.session.Session; import engine.session.Session;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.*;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public enum ChatManager { public enum ChatManager {
@ -208,6 +205,34 @@ public enum ChatManager {
} }
pc.getCharItemManager().updateInventory(); pc.getCharItemManager().updateInventory();
} }
if(text.startsWith("./stackresources")){
HashMap<Integer,Integer> resources = new HashMap<>();
PlayerCharacter pc = (PlayerCharacter)player;
for(Item i : pc.getCharItemManager().getInventory()){
ItemBase ib = i.getItemBase();
if(ib.getType().equals(Enum.ItemType.RESOURCE)){
if(resources.containsKey(ib.getUUID())){
//already logged this resource, add to count
int count = resources.get(ib.getUUID());
count += i.getNumOfItems();
resources.put(ib.getUUID(),count);
}else{
//have not logged this resource yet
resources.put(ib.getUUID(),i.getNumOfItems());
}
pc.getCharItemManager().junk(i);
}
}
for(int id : resources.keySet()){
ItemBase ib = ItemBase.getItemBase(id);
MobLoot ml = new MobLoot(pc,ib,resources.get(id),false);
Item i = ml.promoteToItem(pc);
pc.getCharItemManager().addItemToInventory(i);
}
pc.getCharItemManager().updateInventory();
}
if (ChatManager.isDevCommand(text) == true) { if (ChatManager.isDevCommand(text) == true) {
ChatManager.processDevCommand(player, text); ChatManager.processDevCommand(player, text);
return; return;

Loading…
Cancel
Save