Solved EntityDamageEvent Not Canceling All Damage

Discussion in 'Plugin Development' started by XDemonic25, Jan 28, 2013.

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

    XDemonic25

    I have a plugin im trying to bring back. But right now the EntityDamageEvent isnt working correctly.

    Code:
        @EventHandler
        public void onEntityDamage(EntityDamageEvent evt) {
            if(evt instanceof Player){
                Player player = (Player) evt;
                if (Players.IsGhost(player.getPlayer())){
                    evt.setCancelled(true);
                }
            }
        }
    
    This seems to not be firing at all. What seems to be the problem? The player still gets damaged from all sources.
     
  2. Offline

    Woobie

    You are checking if the event is player.. you should probably check if the entity is player.

    Also, player.getPlayer() ?
    Code:
    if (Players.IsGhost(player.getPlayer())){
     
  3. Offline

    Haribo98

    Also for code efficiency, you don't need to get the player of a player, for the player is already a player.
     
  4. Offline

    XDemonic25

    I fixed it and thanks for the tip
     
Thread Status:
Not open for further replies.

Share This Page