Help with a Custom Plugin

Discussion in 'Spigot Plugin Development' started by Marcuri02, Jun 23, 2015.

  1. Hello,

    I have a problem with one plugin.

    I tip

    Code (Text):
    p1.getInventory().remove(Material.DRAGON_EGG);
    But i only want to remove 1 Dragon Egg.

    Any idea?
     
  2. Let me know if this works.
    Code (Text):
    p1.getInventory().remove(new ItemStack(Material.DRAGON_EGG, 1));
     
  3. Try this:
    Code (Text):
    p1.getInventory().removeItem(new ItemStack(Material.DRAGON_EGG, 1));
     
  4. Tux

    Tux

    The removal functions supplied by the Bukkit API aren't good (and can lead to all sorts of fun issues, like duplication). You want to iterate over all items in the inventory, check for a dragon egg, and if so, either remove it if it's a single item, or decrement the amount if there's more than one.
     
    • Agree Agree x 1
    • Useful Useful x 1
  5. It now works! Perfect!! Thanks!!