Code: public void clearInv(Player p) { for(int j=0; j<38; j++) { p.getInventory().setItem(j, null); } p.getInventory().setHelmet(null); p.getInventory().setChestplate(null); p.getInventory().setLeggings(null); p.getInventory().setBoots(null); } This clear's both the inventory and the armour. To use this simply use it like this: If its within a command: Code: Player p = (Player)sender; if(a ==b) { clearInv(p); } Without a command Code: Player p; if(a ==b) { clearInv(p); } If you think you can simplify or think somethign is wrong feel free to post . P.S if you'd like me to explain how the code works feel free to ask
This may help you a little bit... Code: /**To clear items only*/ p.getInventory().setContents(null); /**To clear armor only*/ p.getInventory().setArmorContents(null); /**To clear items and armor*/ ((CraftPlayer)p).getHandle().inventory.b(new NBTTagList()); There may be different code that clears the items and armor in a single statement, but I couldn't find it.
I'm new to custom codes, I'm trying to reset all my players items in their inventoried but leave their armor intact as well as their enderchest. This can be done by deleting the players .dat file in essentials But I want to keep all their other data intact. How would I go about implementing this code above to make this happen?
Inventory.clear(); Inventory.setArmorContents(null); Simple. one4me Why use NMS to do something simple like clear an inventory and armor. EDIT: Why are you specifying the type of excrement in your signature stoneminer02?
He gave your example as well as the nms example. Your example uses two lines, and he provided that, along with a possible one line example. He didn't necessarily say to use the nms one over the other ones.
OP has not been seen since last year. Last reply has not been seen for 7 months. Please make a new thread.
What do you mean? If you mean that the signature code is awful, thank you It wasn't meant to be taken serious or to be good.
stoneminer02 your signature provides inefficient code. With no break from that loop youll crash rather quickly.
It wasn't meant to be taken serious. My old signature was Code:java public void brainFart(){ Thread.sleep(∞)}
d3v1n302418 You are contradicting yourself - Besides It could be a small part of code without the closing loops!
d3v1n302418 This code is actually really efficient in that it doesn't compile and therefore never runs at all.