Bukkit - Player Damage Event?

Discussion in 'Plugin Development' started by MasterDoctor, Mar 22, 2015.

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

    MasterDoctor

    I am looking for some kind of event/listener for when a player takes damage.
    I have thought about using a while(true) loop, but surely that would be laggy for the server and clients, and also surely that would mean that the rest of my code wouldn't be run because surely other events wait for the current one to be finished...
    Sorry, if I am not making much sense here.
     
  2. Offline

    Nathat23

    Listen for a EntityDamageEvent and then check if it's a player
     
  3. Offline

    MasterDoctor

    ok thanks

    Hey sorry, I've forgotten how to check if its a player...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  4. Offline

    Nathat23

    Code:
    @EventHandler
    public void onHeathChange(EntityDamageEvent e){
    if (e.getEntity() instanceof Player){
    //Do stuff
    }
    }
     
  5. Offline

    MasterDoctor

    Nvm, Found it
     
  6. Offline

    nverdier

    @MasterDoctor So this is solved? If so, please mark as solved. More info on that can be found here.
     
Thread Status:
Not open for further replies.

Share This Page