Exemple #1
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDamageByPlayer(final EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof Player == false || e.getDamager() instanceof Player == false)
      return;

    Player player = (Player) e.getEntity();
    Player target = (Player) e.getDamager();
    SCPlayer scp = getSCPlayer(player.getUniqueId());
    SCPlayer sct = getSCPlayer(target.getUniqueId());
    Faction faction = BoardColl.get().getFactionAt(PS.valueOf(target.getLocation().getChunk()));

    if (faction.getName().equalsIgnoreCase("Safezone")) {
      return;
    }

    final Faction pFaction = MPlayerColl.get().get(player).getFaction();
    final Faction tFaction = MPlayerColl.get().get(target).getFaction();

    if (pFaction.getRelationTo(tFaction) == Rel.MEMBER && !pFaction.isNone()) {
      return;
    }

    if (pFaction.getRelationTo(tFaction) == Rel.ALLY) {
      return;
    }

    scp.combatTag();
    sct.combatTag();
  }
  /**
   * Tag creepers hurt by players.
   *
   * <p>Only those creepers hurt recently by players will have special drops.
   */
  @EventHandler(ignoreCancelled = true)
  public void onCreeperDamage(EntityDamageByEntityEvent event) {
    if (!CONFIG.isAffectedWorld(event)) {
      return;
    }

    if (event.getEntityType() == EntityType.CREEPER) {
      boolean isPlayerAttack = false;
      if (event.getDamager() instanceof Player) {
        isPlayerAttack = true;
      } else if (event.getDamager() instanceof Projectile) {
        Projectile projectile = (Projectile) event.getDamager();
        if (projectile.getShooter() instanceof Player) {
          isPlayerAttack = true;
        }
      }

      // Tag creepers hurt by players with the damage time stamp.
      if (isPlayerAttack) {
        Entity creeper = event.getEntity();
        creeper.setMetadata(
            PLAYER_DAMAGE_TIME_KEY,
            new FixedMetadataValue(this, new Long(creeper.getWorld().getFullTime())));
      }
    }
  }
 @EventHandler
 private void entityDamageByEntityEvent(EntityDamageByEntityEvent event) {
   if (event.isCancelled()
       || !(event.getDamager() instanceof Player)
       || !(event.getEntity() instanceof Player)
       || !(RandomPackage.getEnabledEnchantsConfig()
           .getString("Unique.Curse")
           .equalsIgnoreCase("true"))) {
     return;
   } else {
     Player damager = (Player) event.getDamager();
     Player victim = (Player) event.getEntity();
     if (victim.getInventory().getChestplate() == null
         || !(victim.getInventory().getChestplate().hasItemMeta())
         || !(victim.getInventory().getChestplate().getItemMeta().hasLore())) {
       return;
     } else {
       Bukkit.getScheduler()
           .scheduleSyncDelayedTask(
               RandomPackage.getPlugin(),
               new Runnable() {
                 public void run() {
                   if (event.isCancelled()) {
                     return;
                   } else {
                     Random random = new Random();
                     int chance = 8;
                     int duration = 60;
                     for (int i = 1; i <= 3; i++) {
                       chance = chance + 2;
                       duration = duration + 40;
                       if (victim
                               .getInventory()
                               .getChestplate()
                               .getItemMeta()
                               .getLore()
                               .contains(
                                   ChatColor.translateAlternateColorCodes(
                                       '&',
                                       RandomPackage.getPlugin()
                                           .getConfig()
                                           .getString(
                                               "Enchantments.Unique.Curse.Curse"
                                                   + i
                                                   + ".ItemLore")))
                           && random.nextInt(100) <= chance) {
                         damager.addPotionEffect(
                             new PotionEffect(PotionEffectType.SLOW, duration, 4));
                         return;
                       }
                     }
                     return;
                   }
                 }
               },
               1);
       return;
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGH)
  public void onEDamageByE(EntityDamageByEntityEvent event) {
    // if (event.getEntity() instanceof Player) {
    /*	Player Damagee = (Player) event.getEntity();
    String damager = event.getDamager().toString();
    Damagee.
    Bukkit.broadcastMessage("entity "+ Damagee);
    Bukkit.broadcastMessage("damager "+ damager);*/

    if (event.getDamager() instanceof Player) {
      Player p = (Player) event.getDamager();
      // int dmg = event.getDamage();
      double cRate = plugin.critRate.get(p.getName().toLowerCase());
      double random = ((double) Math.random() * 100);

      if (cRate > 0) {
        if (random <= cRate) {
          int oldmg = event.getDamage();
          int newdmg = oldmg * 2;
          event.setDamage(newdmg);
          p.sendMessage(ChatColor.AQUA + "Critical!");
          Location loc = p.getLocation();
          p.playEffect(loc, Effect.BLAZE_SHOOT, 0);
        }
      }
    }

    /*
    Player p = (Player) event.getDamager();
    String player = p.getName();
    Bukkit.broadcastMessage("name "+ player);*/

    // }

  }
Exemple #5
0
 @EventHandler
 public void onPlayerAttack(EntityDamageByEntityEvent e) {
   if (e.getDamager() instanceof Player) {
     Player p = (Player) e.getDamager();
     if (ArenaManager.getInstance().getArena(p) != null) e.setCancelled(true);
   }
 }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerDamage(EntityDamageByEntityEvent evt) {
    if (evt.getDamager() instanceof Player) {
      Player p = (Player) evt.getDamager();

      if (p.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
        for (PotionEffect eff : p.getActivePotionEffects()) {
          if (eff.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
            double div = (eff.getAmplifier() + 1) * 1.3D + 1.0D;
            int dmg;

            if (evt.getDamage() / div <= 1.0D) {
              dmg = (eff.getAmplifier() + 1) * 3 + 1;
            } else {
              double flatdmg = 2.0;
              dmg = (int) (evt.getDamage() / div) + (int) ((eff.getAmplifier() + 1) * flatdmg);
            }

            evt.setDamage(dmg);
            break;
          }
        }
      }
    }
  }
Exemple #7
0
 @EventHandler
 public void onHit(EntityDamageByEntityEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     if (e.getDamager() instanceof Snowball) {
       Snowball s = (Snowball) e.getDamager();
       Player shooter = (Player) s.getShooter();
       if (teamManager.getTeam(p) != teamManager.getTeam((Player) s.getShooter())) {
         if (s.getCustomName() != null) {
           if (s.getCustomName().equalsIgnoreCase("stun")) {
             if (!stunned.contains(p.getName())) {
               stunned.add(p.getName());
               p.playSound(p.getLocation(), Sound.FIREWORK_TWINKLE2, 3F, 1F);
               shooter.playSound(shooter.getLocation(), Sound.SUCCESSFUL_HIT, 3F, 1F);
               p.sendMessage(Color.np("&cYou got hit by a stun! You cannot move for 2 seconds!"));
               new BukkitRunnable() {
                 @Override
                 public void run() {
                   stunned.remove(p.getName());
                 }
               }.runTaskLater(Main.getInstance(), 40);
             } else {
               shooter.sendMessage(Color.np("&cThat player is already stunned!"));
             }
           }
         }
       } else {
         shooter.sendMessage(Color.np("&cYou cannot stun team members!"));
       }
     }
   }
 }
 @EventHandler
 public void onDamageFisherman(EntityDamageByEntityEvent e) {
   if (this.pl.comecou)
     if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Player))) {
       Entity ent = e.getEntity();
       Player player = (Player) e.getEntity();
       Player damager = (Player) e.getDamager();
       Player p = (Player) ent;
       if ((this.pl.km.temKit(player))
           && (this.pl.km.getPlayerKit(player, this.pl.km.getKitByName("Fisherman")))
           && (damager.getItemInHand() != null)
           && (damager.getItemInHand().getType() != null)) {
         if (damager.hasPermission("planeta.vip") && (damager.hasPermission("hg.youtuber"))) {
           BossBar.setMessage(
               damager,
               p.getName()
                   + " - Fisherman (§bSopas "
                   + AmountAPI.getAmount(p, Material.MUSHROOM_SOUP)
                   + " §f)",
               1);
         } else {
           BossBar.setMessage(damager, p.getName() + " - Fisherman", 1);
         }
       }
     }
 }
    public static DamageCause fromDamageEvent(EntityDamageEvent e) {
      EntityDamageEvent.DamageCause c = e.getCause();
      Object p = null, x = null;

      EntityDamageByEntityEvent edEvent = null;
      if ((e instanceof EntityDamageByEntityEvent)) edEvent = (EntityDamageByEntityEvent) e;

      switch (c) {
        case ENTITY_ATTACK:
        case ENTITY_EXPLOSION:
          // get the entity that did the killing
          if (edEvent != null) {
            p = edEvent.getDamager();
            if (p instanceof Player) x = ((Player) p).getItemInHand().getType();
          }
          break;

        case PROJECTILE:
        case MAGIC:
          // get the shooter from the projectile
          if (edEvent != null && edEvent.getDamager() != null) {
            p = ((Projectile) edEvent.getDamager()).getShooter();
            x = edEvent.getDamager().getType();
          }

          // change damage cause to ENTITY_ATTACK
          // c = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
          break;
      }

      if ((p instanceof Player))
        p = AutoReferee.getInstance().getMatch(e.getEntity().getWorld()).getPlayer((Player) p);
      else if ((p instanceof Entity)) p = ((Entity) p).getType();
      return new DamageCause(c, p, x);
    }
Exemple #10
0
  // ================================================================================================
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (Arctica.debug) {
      if (event.getDamager() instanceof Player) {
        if (event.getEntityType() == EntityType.HORSE) {
          Horse horse = (Horse) event.getEntity();
          Player damager = (Player) event.getDamager();

          Arctica.log.info(
              Arctica.logPrefix
                  + "Health: "
                  + String.format("%1$.2f", horse.getHealth())
                  + " HP of "
                  + String.format("%1$.2f", horse.getMaxHealth())
                  + " HP");
          damager.sendMessage(
              "Health: "
                  + String.format("%1$.2f", horse.getHealth())
                  + " HP of "
                  + String.format("%1$.2f", horse.getMaxHealth())
                  + " HP");
        }
      }
    }
  }
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (!(event.getEntity() instanceof Player && event.getDamager() instanceof Player))
     return; // We only want to check this if players hit each other
   final Player attacker = (Player) event.getDamager();
   if (attacker.getInventory().getHeldItemSlot() != 8) return;
   final Player victim = (Player) event.getEntity();
   if (AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHealing) {
     event.setCancelled(true);
     victim.setHealth(victim.getMaxHealth());
     ParticleEffect.HEART.display(
         Vector.getRandom(), 1, victim.getEyeLocation().add(0, 0, .25), Bukkit.getOnlinePlayers());
   }
   if (!(AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHeartripping))
     return; // Make sure the person punching has heartripping active
   if (!AbilityManager.getInstance().getCurrentSpell(attacker).canUse(attacker)) return;
   if (victim.hasPermission("heart.block")) {
     ChatManager.messageBad(attacker, "That player is too powerful!");
     ChatManager.messageGood(
         victim, attacker.getName() + " attempted to rip out your heart but was too weak!");
     return;
   }
   if (!spellSelection.containsKey(attacker) || !spellSelection.get(attacker).equals(victim)) {
     ChatManager.messageGood(
         attacker, "You ripped " + victim.getName() + "'s heart out of their body!");
     ChatManager.messageBad(
         victim, attacker.getName() + " has ripped your heart out of your body!");
     spellSelection.put(attacker, victim);
   }
   attacker.getInventory().setItemInMainHand(getValidBook(attacker));
 }
Exemple #12
0
  @EventHandler
  public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof org.bukkit.entity.Player) {
      Player entity = Arcade.getServer().getPlayer(e.getEntity().getUniqueId());
      if (!entity.getTeam().isFrendlyFire()) {
        return;
      }
      Player damager = null;
      Projectile projectile = null;

      if (e.getDamager() instanceof org.bukkit.entity.Player) { // Player vs player direct
        damager = Arcade.getServer().getPlayer(e.getDamager().getUniqueId());
      } else if (e.getDamager() instanceof Projectile
          && ((Projectile) e.getDamager()).getShooter()
              instanceof org.bukkit.entity.Player) { // Arrows, snowballs, etc...
        projectile = (Projectile) e.getDamager();
        damager =
            Arcade.getServer()
                .getPlayer(((org.bukkit.entity.Player) projectile.getShooter()).getUniqueId());
      }

      if (damager != null && entity.getTeam().equals(damager.getTeam())) {
        e.setCancelled(true);
      }
      if (projectile != null) {
        projectile.setBounce(true);
      }
    }
  }
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void damageHandler(EntityDamageByEntityEvent event) {
   if (event.getDamager().getType() == EntityType.PLAYER) {
     Player player = (Player) event.getDamager();
     AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId());
     if (p != null && p.getKit().equals(this) && p.getData("Cur") != null) endLeap(player, p);
   }
 }
Exemple #14
0
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Player && hasAbility((Player) event.getDamager())) {
     Player p = (Player) event.getDamager();
     if (p.isSneaking() && (!needToBlock || p.isBlocking())) {
       event.setCancelled(true);
     }
   }
 }
Exemple #15
0
 @EventHandler
 public void onDamageByEntity(EntityDamageByEntityEvent event) {
   if (dmgBuff.containsKey(event.getDamager())) {
     DmgBoost boost = dmgBuff.get(event.getDamager());
     if (boost.expires < HungergamesApi.getHungergames().currentTime)
       dmgBuff.remove(event.getDamager());
     else event.setDamage(event.getDamage() + boost.extraDamage);
   }
 }
 @Override
 public void onEntityDamage(EntityDamageEvent ev) {
   if (ev instanceof EntityDamageByEntityEvent) {
     EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) ev;
     if (event.getDamager() instanceof Player) {
       QuestManager.incrementQuest((Player) event.getDamager(), event);
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onEntityDamage2(EntityDamageByEntityEvent event) {
    if (slowAmount <= 0 || slowDuration <= 0) return;

    if (!(event.getDamager() instanceof Snowball)
        || event.getDamager().getFallDistance() != identifier) return;

    ((LivingEntity) event.getEntity())
        .addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slowDuration, slowAmount), true);
  }
Exemple #18
0
 @EventHandler
 public void onArrowDamage(EntityDamageByEntityEvent e) {
   if (!Api.allowsPVP(e.getEntity())) return;
   if (!Api.allowsPVP(e.getDamager())) return;
   if (e.getDamager() instanceof Arrow) {
     if (e.getEntity() instanceof LivingEntity) {
       LivingEntity en = (LivingEntity) e.getEntity();
       Projectile arrow = (Projectile) e.getDamager();
       if (Arrow.containsKey(arrow)) {
         if (Api.isFriendly(P.get(e.getDamager()), e.getEntity())) {
           if (Enchant.get(arrow).equalsIgnoreCase("Doctor")) {
             if (Api.isEnchantmentEnabled("Doctor")) {
               int heal = 2 + Api.getPower(Arrow.get(arrow) + "", Api.getEnchName("Doctor"));
               if (en.getHealth() + heal < en.getMaxHealth()) {
                 en.setHealth(en.getHealth() + heal);
               }
               if (en.getHealth() + heal >= en.getMaxHealth()) {
                 en.setHealth(en.getMaxHealth());
               }
             }
           }
         }
         if (!Api.isFriendly(P.get(arrow), e.getEntity())) {
           if (Enchant.get(arrow).equalsIgnoreCase("IceFreeze")) {
             if (Api.isEnchantmentEnabled("IceFreeze")) {
               if (Api.randomPicker(5)) {
                 en.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 1));
               }
             }
           }
           if (Enchant.get(arrow).equalsIgnoreCase("Piercing")) {
             if (Api.isEnchantmentEnabled("Piercing")) {
               if (Api.randomPicker(
                   20 - Api.getPower(Arrow.get(arrow) + "", Api.getEnchName("Piercing")))) {
                 e.setDamage(e.getDamage() * 2);
               }
             }
           }
           if (Enchant.get(arrow).equalsIgnoreCase("Venom")) {
             if (Api.isEnchantmentEnabled("Venom")) {
               if (Api.randomPicker(10)) {
                 en.addPotionEffect(
                     new PotionEffect(
                         PotionEffectType.POISON,
                         2 * 20,
                         Api.getPower(Arrow.get(arrow) + "", Api.getEnchName("Venom")) - 1));
               }
             }
           }
         }
       }
     }
   }
   return;
 }
  /**
   * Target embedded effects
   *
   * @param event event details
   */
  @EventHandler
  public void onProjectileHit(EntityDamageByEntityEvent event) {

    if (projectiles.containsKey(event.getDamager().getEntityId())
        && event.getEntity() instanceof LivingEntity) {
      EmbedData data = projectiles.get(event.getDamager().getEntityId());
      data.getSkill().beginUsage();
      data.resolveTarget((LivingEntity) event.getEntity());
      data.getSkill().stopUsage();
    }
  }
 @EventHandler
 public void onArrowSuccessfulHit(EntityDamageByEntityEvent e) {
   if (!(e.getDamager() instanceof Arrow)) return;
   if (Variables.arrows.containsKey(e.getDamager().getUniqueId())
       && e.getEntity() instanceof LivingEntity) {
     for (ItemHandler handler : SlimefunItem.getHandlers("BowShootHandler")) {
       if (((BowShootHandler) handler).onHit(e, (LivingEntity) e.getEntity())) break;
     }
     Variables.arrows.remove(e.getDamager().getUniqueId());
   }
 }
Exemple #21
0
  @EventHandler
  public void onDamage(EntityDamageByEntityEvent event) {

    if (event.getDamager() instanceof Snowball) {

      if (projectiles.contains(event.getDamager())) {

        event.setCancelled(true);
      }
    }
  }
 @EventHandler
 public void onPlayerShotEvent(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Arrow) {
     Arrow arrow = (Arrow) event.getDamager();
     if (arrow.getShooter() instanceof Player) {
       Player player = (Player) arrow.getShooter();
       if (event.getEntity().equals(player)) {
         event.setCancelled(true);
       }
     }
   }
 }
Exemple #23
0
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onDamage(EntityDamageByEntityEvent e) {
   double damage = e.getDamage();
   if (e.getDamager() instanceof Player) {
     damage = playerDamager(e, damage);
   } else if (e.getDamager() instanceof Projectile) {
     damage = projectileDamager(e, damage);
   }
   if (e.getEntity() instanceof Player) {
     damage = playerHit(e, damage);
   }
   e.setDamage(damage);
 }
  @SuppressWarnings("deprecation")
  @EventHandler()
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.isCancelled()) return;
    Entity victim = event.getEntity();
    // Apply Wolf Armor or Invincibiliy
    JailPrisoner prisoner = Jail.guards.get(victim);
    JailZone jail = prisoner != null ? prisoner.getJail() : null;
    if (prisoner != null) {
      if (jail.getSettings().getBoolean(Setting.GuardInvincibility)) {
        event.setCancelled(true);
        return;
      }
      int newArmor =
          (int)
              (event.getDamage()
                  - (event.getDamage() * jail.getSettings().getInt(Setting.GuardArmor) / 100));
      if (newArmor <= 0) newArmor = 1;
      event.setDamage(newArmor);

      if (event instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent eventD = (EntityDamageByEntityEvent) event;

        if (eventD.getDamager() instanceof LivingEntity)
          prisoner.getPossibleGuardTargets().add((LivingEntity) eventD.getDamager());
      }
    }
    if (!(event instanceof EntityDamageByEntityEvent)) return;
    EntityDamageByEntityEvent newevent = (EntityDamageByEntityEvent) event;
    Entity damager = newevent.getDamager();

    prisoner = Jail.guards.get(damager);
    jail = prisoner != null ? prisoner.getJail() : null;

    // Apply Wolf damage and damage speed change
    if (prisoner != null) {
      if (new Random().nextInt(100) > jail.getSettings().getInt(Setting.GuardAttackSpeedPercent)) {
        event.setCancelled(true);
        return;
      }
      event.setDamage(jail.getSettings().getInt(Setting.GuardDamage));
    }
    jail = JailZoneManager.getJail(victim.getLocation());
    if (jail != null
        && jail.getSettings().getBoolean(Setting.EnablePVPProtection)
        && victim instanceof Player
        && damager instanceof Player) {
      event.setCancelled(true);
      return;
    }
  }
Exemple #25
0
 private boolean playerDamage(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Player) {
     Player player = (Player) event.getDamager();
     return !player.isOp();
   }
   if (event.getDamager() instanceof Projectile) {
     Projectile projectile = (Projectile) event.getDamager();
     if (projectile.getShooter() instanceof Player) {
       Player player = (Player) projectile.getShooter();
       return !player.isOp();
     }
   }
   return false;
 }
Exemple #26
0
  /**
   * Apply combat modifiers
   *
   * @param event The event to run the combat checks on.
   */
  void combatChecks(EntityDamageByEntityEvent event) {
    Entity damager = event.getDamager();
    EntityType damagerType = damager.getType();

    switch (damagerType) {
      case PLAYER:
        Player attacker = (Player) event.getDamager();
        ItemStack itemInHand = attacker.getItemInHand();

        DurabilityUtils.handleInfiniteDurability(itemInHand);
      default:
        return;
    }
  }
Exemple #27
0
  @EventHandler
  public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
    if (!((e.getEntity() instanceof Player)
        && Config.getConfig().getBoolean("disable-spawn-command-in-pvp.enabled"))) return;

    final Player p = (Player) e.getEntity();

    if (e.getDamager() instanceof Player) {
      pvp(p, (Player) e.getDamager());
    } else if ((e.getDamager() instanceof Arrow)
        && (((Arrow) e.getDamager()).getShooter() instanceof Player)) {
      pvp(p, (Player) ((Arrow) e.getDamager()).getShooter());
    }
  }
 // Battle Arena Anti-Cheat
 @EventHandler(priority = EventPriority.MONITOR)
 public void stopOutsideDamage(EntityDamageByEntityEvent e) {
   if (e.getEntity() instanceof Player) {
     Player damaged = (Player) e.getEntity();
     if (e.getDamager() instanceof Player) {
       Player damager = (Player) e.getDamager();
       if (!BattleArena.inArena(damager)) {
         if (BattleArena.inArena(damaged)) {
           e.setCancelled(true);
           Bukkit.broadcastMessage("CANCELLED!");
         }
       }
     }
   }
 }
 @EventHandler
 public void SpectatorPvP(EntityDamageByEntityEvent event) {
   Entity offense = event.getDamager();
   if (offense instanceof Player) {
     Player Attacker = (Player) event.getDamager();
     String attackerName = Attacker.getName();
     for (i = 0; i < plugin.Watching.size(); i++) {
       if (plugin.Watching.get(i) != null) {
         if (plugin.Watching.get(i).contains(attackerName)) {
           event.setCancelled(true);
           Attacker.sendMessage(
               ChatColor.RED + "You are spectating, you can't interfere with the game!");
           return;
         }
       }
     }
     for (i = 0; i < plugin.Playing.size(); i++) {
       if (plugin.Playing.get(i) != null) {
         if (plugin.Playing.get(i).contains(attackerName)) {
           event.setCancelled(true);
         }
       }
     }
   } else if (event.getDamager() instanceof Projectile) {
     Projectile arrow = (Projectile) offense;
     if (arrow.getShooter() instanceof Player) {
       Player BowMan = (Player) arrow.getShooter();
       String bowManName = BowMan.getName();
       for (i = 0; i < plugin.Watching.size(); i++) {
         if (plugin.Watching.get(i) != null) {
           if (plugin.Watching.get(i).contains(bowManName)) {
             event.setCancelled(true);
             BowMan.sendMessage(
                 ChatColor.RED + "You are spectating, you can't interfere with the game!");
             return;
           }
         }
       }
       for (i = 0; i < plugin.Playing.size(); i++) {
         if (plugin.Playing.get(i) != null) {
           if (plugin.Playing.get(i).contains(bowManName)) {
             event.setCancelled(true);
           }
         }
       }
     }
   }
 }
 @EventHandler(priority = EventPriority.NORMAL)
 public void onEntityDamageByEntity(final EntityDamageByEntityEvent e) {
   Entity ent = e.getEntity();
   Entity entDamager = e.getDamager();
   if ((ent instanceof Player) && (entDamager instanceof Player)) {
     GamePlayer rmp = GamePlayer.getPlayerByName(((Player) ent).getName());
     GamePlayer rmpDamager = GamePlayer.getPlayerByName(((Player) entDamager).getName());
     if ((rmp != null) && (rmpDamager != null)) {
       if ((rmp.isIngame()) && (rmpDamager.isIngame())) {
         GameConfig config = rmp.getGame().getGameConfig();
         Timer pvpTimer = config.getPvpTimer();
         if (!config.getSettingBool(Setting.allowpvp)) {
           e.setCancelled(true);
         } else if (rmp.getTeam() == rmpDamager.getTeam()) {
           if (!config.getSettingBool(Setting.friendlyfire)) {
             e.setCancelled(true);
           }
         } else if ((rmp.isSafe()) || (rmpDamager.isSafe())) {
           e.setCancelled(true);
           rmpDamager.sendMessage(Text.getLabel("game.safezone.pvp"));
         } else if ((pvpTimer.isSet()) && (pvpTimer.isTicking())) {
           e.setCancelled(true);
           // rmpDamager.sendMessage(RMText.getLabelArgs("game.pvp.delay",
           // pvpTimer.getTextTimeRemaining()));
           rmpDamager.sendMessage(Text.getLabelArgs("game.pvp.disabled"));
         }
       }
     }
   }
 }