Can't cancel event?

Discussion in 'Plugin Help/Development/Requests' started by stenlankreijer, Dec 21, 2014.

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

    stenlankreijer

    So I have this code:
    Code:java
    1. @EventHandler(priority = EventPriority.HIGHEST)
    2. public void onDestroy(PlayerItemDamageEvent event){
    3.  
    4. }


    And I tried the following things in it already:
    Code:java
    1.  
    2. event.setCancelled(true);
    3. event.getItem().setDurability((short) 1);
    4. event.setDamage(0);
    5.  


    I know that if I cancel it the setDamage doesn't have impact anymore, but I did not do that, I tried these things seperately.

    And yes, I registered events as I am able to send a message to myself when the event is called.

    I would like to know why it's not working or if it's a glitch or something? Or am I using the wrong event?

    What I want to do is cancel damage and let the item be sort of unbreakable.

    I know I can for example delete and re-add the item or give it an enchantment but that's kinda hacky.
    I'm just interested as I'm still learning a bit and would like to know why this is acting the way it is.

    Thanks in advance! :)
     
  2. Offline

    Skionz

    @stenlankreijer The PlayerItemDamageEvent doesn't even exist. This is a Spigot question, but my guess is that it doesn't implement cancelable.
     
  3. Offline

    stenlankreijer

    Oh, I'm sorry ;)
    It exists for me, but I'm indeed using bukkit AND spigot.

    I guess I'll just go for the hacky way :)
     
Thread Status:
Not open for further replies.

Share This Page