How to check if a player regenerated health

Discussion in 'Plugin Development' started by Flenix, May 22, 2012.

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

    Flenix

    Hey guys,

    I'm making a health bar plugin using spout and need to get when a player has regenerated health. How would I specifically check for a player?

    I'm using the EntityRegenerateHealthEvent. Next thing I'd check is if they have the permission to see their health bar... so need the getPlayer() thingy.

    As you can probably guess I'm a bit of a java noob, so pointing me in the right direction would be great (Ie, tell me what to do but please don't just do it for me or I'll never learn D: )
     
  2. Offline

    Kanlaki101

    EDIT: Oops re-read your last paragraph.

    You need to pass the event's Entity as a player variable if the Entity is a player.
     
  3. Offline

    SirTyler

    Code:java
    1. If(event.getEntity() instance of Player) {
    2. //Do stuff here
    3. }

    Thats how you check for JUST the player in an event
     
  4. Offline

    Kanlaki101

    SirTyler

     
  5. Offline

    SirTyler

    I know, but just explaing that part of code wouldn't make sense. And I belive he means do not do his entire code for him, that little bit isn't bad.
     
  6. Offline

    Flenix

    On phone but roughly have:

    Code:
        if(event.getEntity() instanceof Player) {
                if(event.getPlayer()
    At that point getPlayer throws an error saying "the method getPlayer is undefined for the type EntityRegainHealthEvent.

    Any ideas
     
  7. Offline

    Kanlaki101

    Pass event.getEntity() as a player variable.
     
  8. Offline

    SirTyler

    getPlayer() is not part of Entity events, only Player specific events, follow what Kanlaki101 said and cast Player to the entity.
     
Thread Status:
Not open for further replies.

Share This Page