ItemStack Doesn't Get Removed

Discussion in 'Plugin Development' started by xELI7E_SNIPEZx, Oct 29, 2013.

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


    When they die there "GuardPots" doesn't get removed? Why? Here's The Code:
    1. @EventHandler
    2. public void onDeath(PlayerDeathEvent evt) {
    3. Player player = evt.getEntity();
    4. GuardPots.setDurability((short) 16421);
    5. if(player.hasPermission("guard.guard")) {
    7. if(player.hasPermission("guard.1")) {
    8. BootGuard1.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    9. ChestGuard1.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
    10. HelmGuard1.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    11. LegsGuard1.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
    12. evt.getDrops().remove(BootGuard1);
    13. evt.getDrops().remove(ChestGuard1);
    14. evt.getDrops().remove(HelmGuard1);
    15. evt.getDrops().remove(LegsGuard1);
    16. evt.getDrops().remove(GuardPots);
    17. }

    And yes, this isn't all the code, but this is the bit that is needed hence the event not being closed.
  2. Offline


    AFAIK, .getDrops() returns a clone of the list. You have to remove what you want, then set that back to it using .setDrops()
  3. Offline


    Its ok i just fixed it. It was because i forgot to make it remove all of them it was only removing one :/
  4. Offline


    RealDope There is no setDrops method, and if I remember correctly, you get the actual list, not a copy of it.
Thread Status:
Not open for further replies.

Share This Page