Remove Specific Items

Discussion in 'Plugin Development' started by will181, Apr 15, 2014.

Thread Status:
Not open for further replies.
  1. Offline



    How would I remove a specific set of items from a player's inventory when a command is sent? So say, when I type /remove swords, it goes through their whole inventory and removes all their swords?

    Thank you to any help given.
  2. Offline


    Make a Command Executor, get the players inventory and then remove the specific item from their inventory.
  3. Offline


    multikus How would I go about doing that?
  4. Offline


    You learn by doing, not by getting someone else to write a code for you.
    Here is a bukkit tutorial which should answer what you ask about:
    Click here
  5. Offline


    multikus , you're barely helping. He asked for more detail, not for code to be written for him. And just forwarding him to the generic wiki tutorial isn't any better.

    will181 You can loop through all the items in a player's inventory with "for (ItemStack item : player.getInventory().getContents())" You can then get each item's type enum, and check if its name ends with the string "_SWORD". If so, do player.getInventory().remove(item);.
  6. Offline


    Maurdekye Thank you, that was very helpful.
Thread Status:
Not open for further replies.

Share This Page