Clear Inventory (AND ARMOR)

Discussion in 'Archived: Plugin Requests' started by Cjbolt, Sep 21, 2012.

  1. Offline


    Not possible, it would be p.getInventory().setHelmet(new ItemStack(Material.AIR));
    however, I already tried that and it didn't work.
  2. Offline


    I was going to say that you're missing something on your code, but wasnt sure what.
    Material.AIR works for me atleast.
  3. Offline


    Nope, Material.AIR will have some sort of issues. null is best for empty slots.

    I think we did the same thing; I'm not sure what was wrong with yours (although I only quickly glanced over the source):

    1. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    2. if (commandLabel.equalsIgnoreCase("cleareverything")) {
    3. if (!(sender instanceof Player)) {
    4. sender.sendMessage(ChatColor.RED + "[ClearEverything] Only players can clear everything!");
    5. return true;
    6. } else {
    7. Player p = (Player)sender;
    8. p.getInventory().clear();
    9. p.getInventory().setHelmet(null);
    10. p.getInventory().setChestplate(null);
    11. p.getInventory().setLeggings(null);
    12. p.getInventory().setBoots(null);
    13. }
    14. }
    15. return true;
    16. }
  4. Offline


    We do have the game things. I don't know what I did wrong, but it doesn't matter, as this request has been fulfilled.

Share This Page