Help With Event

Discussion in 'Plugin Development' started by VinexAx789, Jun 23, 2015.

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

    VinexAx789

    When the kit sniper shoots an arrow from 45 blocks away and it hits a player they die instantly.

    Code:
        @EventHandler
         private void damage(EntityDamageByEntityEvent e) {
          if (e.getDamager() instanceof Player) {
           if(e.getEntity() instanceof Player) {
            if (e.getCause() == DamageCause.PROJECTILE) {
             Player playerWhoShot = (Player) e.getDamager();
             Player playerWhoWasHit = (Player) e.getEntity();
             if(kitselected.get((playerWhoShot)).equals("sniper")){
             if (playerWhoShot.getItemInHand().getType() == Material.BOW) {
              if (playerWhoShot.getLocation().distance(playerWhoWasHit.getLocation()) > 45) {
                  playerWhoWasHit.damage(20.0);
               }
              }
             }
            }
           }
          }
         }
     
  2. Offline

    xTrollxDudex

    Well if the damage cause was projectile, you can't cast the damager to Player...
     
Thread Status:
Not open for further replies.

Share This Page