Solved Damage Event

Discussion in 'Plugin Development' started by Phishy, Apr 2, 2015.

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

    Phishy

    Hi, when trying use an event to stop players getting hurt, nothing is happening. Here is my code:

    @EventHandler
    public void onEntityDamage(EntityDamageEvent event)
    {
    if(event.getEntity() instanceof Player){

    event.setCancelled(true);

    }
    }


    After playing around for a minute, I have got it to work, however I don't know how to call an arraylist from another Class, how do I do this?
     
    Last edited: Apr 2, 2015
  2. @Phishy You could make the ArrayList static (not recommended though, I'm sure I'm not thinking of something).
     
  3. Offline

    Phishy

    Got it to work, made it static then did class.arraylistname.
     
    Last edited: Apr 2, 2015
  4. Offline

    nverdier

    @Phishy You don't need to make it static, you can just pass the instance through a constructor.
     
Thread Status:
Not open for further replies.

Share This Page