Solved Problem I can't Overcome

Discussion in 'Plugin Development' started by Bobfan, Nov 24, 2012.

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

    Bobfan

    This is just a simple problem I couldn't overcome.
    Code:
    @EventHandler
        public void onAttack(EntityDamageByEntityEvent event) {//Attack Event
            FileConfiguration c = pp.getConfig();
           
            Entity pR = (Entity) event.getEntity();
            Player pA = (Player) ((EntityDamageByPlayerEvent) pR).getDamager();
    pA comes up error.
    When attacking a sheep. How would I fix this? pR is the thing being attacked, and pA is the attacker that's a person.
     
  2. Offline

    Tirelessly

    Check if the damager is an instanceof a Player, then do Player pA = (player)e.getDamager();
     
  3. Offline

    Bobfan

    Fixed. ty
     
Thread Status:
Not open for further replies.

Share This Page