On player damage event

Discussion in 'Plugin Development' started by xXPumperNickleXx, Dec 18, 2013.

Thread Status:
Not open for further replies.
  1. Hello =3
    For the past minutes I have been wondering:
    WHAT THE HECK IS WRONG WITH THIS CODE!!!
    Code:java
    1. @EventHandler
    2. public void EntityDamageByEntityEvent(EntityDamageByEntityEvent event){
    3. if(blueteam.contains(event.getEntity())){
    4. if(blueteam.contains(event.getDamager())){
    5. event.setCancelled(true);
    6. }
    7. }
    8.  
    9. }
    10. }
    11.  

    blueteam and redteam are array lists by the way.

    My goal in this is to make it so that people on the same team can't hurt each other, so I tried cancelling it out and when I tried it, it didn't work!!! >.>
     
  2. Offline

    rocket138

    Try casting event.getEntity() and event.getDamager() as Players.
     
  3. Offline

    Pocketkid2

    You are only checking if blueteam is the same, you should also check if redteam is the same...
     
  4. Offline

    reider45

    Chexxk if event.getEntity() and event.getDamager() are an instanceof Player, then define them as a player, also storing player names is a good idea :)


    Also maybe use event.setDamage(0.0) as well
     
Thread Status:
Not open for further replies.

Share This Page