How to disable ALL damage done to a player ?

Discussion in 'Plugin Development' started by darker9999, Dec 17, 2011.

Thread Status:
Not open for further replies.
  1. How can i disable all damage done to player ? I found DAMAGE_EVENT, but then i can't getPlayer().
     
  2. Offline

    dbizzzle

    Depending on how you set up your event you can use event.getPlayer();
     
  3. Offline

    Patrick Wrobel

    Well, you can getEntity() and a Player is an Entity

    Code:
    Player player = null;
    if (event.getEntity() instanceof Player)
        player = (Player)event.getEntity()
    
    
    player.setHealth(20);
    EDIT: Woops, I forgot to mention that you should have an entity listener with an entity damage event registered
     
  4. Offline

    dbizzzle

    Ah yes forgot you needed to getEntity();
    Code:java
    1.  
    2. public void onEnitityDamage(EntityDamageEvent event) {
    3. Entity ent = event.getEntity();
    4. if (ent instanceof Player()) {
    5. Player pla = plugin.getServer().getPlayer(ent);
    6. }
    7. }
    8.  

    I believe the above should work.
     
Thread Status:
Not open for further replies.

Share This Page