public void onEntityDamage(EntityDamageEvent event) {
    DamageCause cause = event.getCause();

    ArrayList<Integer> ids = iCoLand.landMgr.getLandIds(event.getEntity().getLocation());

    if (cause.equals(DamageCause.FIRE) || cause.equals(DamageCause.FIRE_TICK)) {
      for (Integer id : ids) {
        Land land = iCoLand.landMgr.getLandById(id);
        if (land.hasAddon("nofire")) {
          event.setCancelled(true);
        }
      }

      if (ids.size() == 0 && !Config.unclaimedLandCanBurn) {
        event.setCancelled(true);
      }
    } else if (cause.equals(DamageCause.BLOCK_EXPLOSION)
        || cause.equals(DamageCause.ENTITY_EXPLOSION)) {
      for (Integer id : ids) {
        Land land = iCoLand.landMgr.getLandById(id);
        if (land.hasAddon("noboom")) {
          event.setCancelled(true);
        }
      }

      if (ids.size() == 0 && !Config.unclaimedLandCanBoom) {
        event.setCancelled(true);
      }

    } else if (event instanceof EntityDamageByEntityEvent) {
      EntityDamageByEntityEvent castEvent = (EntityDamageByEntityEvent) event;
      if ((castEvent.getDamager() instanceof Player) && (castEvent.getEntity() instanceof Player)) {
        for (Integer id : ids) {
          if (iCoLand.landMgr.getLandById(id).hasAddon("nopvp")) event.setCancelled(true);
        }
      }
    }
  }
 @EventHandler(priority = EventPriority.HIGH)
 public void hurtVoid(EntityDamageEvent e) {
   DamageCause cause = e.getCause();
   Entity entity = e.getEntity();
   if (cause.equals(EntityDamageEvent.DamageCause.VOID)) {
     if (entity instanceof Player) {
       Player player = (Player) entity;
       if (player.hasPermission("kitpvp.coal")) {
         player.setHealth(20.0);
         player.setFallDistance(0.0F);
         player.teleport(Bukkit.getServer().getWorld("world").getSpawnLocation());
         Main.getKSC().put(player.getName(), 0);
         Util.msg(player, "You have fell off the map!");
         Util.ksm(player, "Your KillStreak was reset!");
         return;
       }
     }
   } else if (entity instanceof Player && cause == DamageCause.FALL) e.setCancelled(true);
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDeath(EntityDeathEvent event) {
    Entity died = event.getEntity();
    if (died instanceof Player) {
      Player pdied = (Player) died;
      if (plugin.isInArena(pdied)) {
        event.getDrops().clear();
        plugin.getArena(pdied).onPlayerDeath(plugin.getArenaPlayer(pdied));
      }
    }

    EntityDamageEvent dev = event.getEntity().getLastDamageCause();
    if (dev != null) {
      if (dev.getEntity() != null) {
        if (dev.getEntity() instanceof Player) {
          Player dead = (Player) event.getEntity();
          if (dev.getCause() != null) {
            DamageCause dc = dev.getCause();
            if (dc.equals(DamageCause.ENTITY_ATTACK)) {
              Entity damager = ((EntityDamageByEntityEvent) dev).getDamager();
              if (plugin.isInArena(dead)) {
                String attackerName = damager.getType().getName();
                if (damager instanceof Player) {
                  attackerName = ((Player) damager).getName();
                }
                event.getDrops().clear();

                ArenaPlayer dp = plugin.getArenaPlayer(dead);
                dp.killstreak = 0;
                dp.deaths++;

                String line1 =
                    ChatColor.GREEN
                        + attackerName
                        + ChatColor.WHITE
                        + " 杀死了 "
                        + ChatColor.RED
                        + dead.getName();
                String line2 = ChatColor.RED + dead.getName() + " 你已被 " + attackerName + " 击杀";
                String line3 = ChatColor.RED + "----------------------------";
                String line4 = ChatColor.RED + "杀敌: " + dp.kills;
                String line5 = ChatColor.RED + "死亡: " + dp.deaths;
                String line6 = ChatColor.RED + "----------------------------";

                dead.sendMessage(line1);
                dead.sendMessage(line2);
                dead.sendMessage(line3);
                dead.sendMessage(line4);
                dead.sendMessage(line5);
                dead.sendMessage(line6);

                if (damager instanceof Player) {
                  Player attacker = (Player) ((EntityDamageByEntityEvent) dev).getDamager();
                  if (plugin.isInArena(attacker)) {
                    ArenaPlayer ap = plugin.getArenaPlayer(attacker);
                    ap.kills++;
                    ap.killstreak++;
                    ap.XP += 100;

                    line2 = ChatColor.RED + "杀死了 " + dead.getName() + " +100 XP";
                    line4 = ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(attacker).kills;
                    line5 = ChatColor.RED + "死亡: " + plugin.getArenaPlayer(attacker).deaths;

                    attacker.sendMessage(line1);
                    attacker.sendMessage(line2);
                    attacker.sendMessage(line3);
                    attacker.sendMessage(line4);
                    attacker.sendMessage(line5);
                    attacker.sendMessage(line6);
                    Arena ar = plugin.getArena(attacker);
                    ar.doKillStreak(plugin.getArenaPlayer(attacker));

                    // Call kill event
                    UltimateArenaKillEvent killEvent = new UltimateArenaKillEvent(dp, ap, ar);
                    plugin.getServer().getPluginManager().callEvent(killEvent);
                  }
                }
              }

              return;
            } else if (dc.equals(DamageCause.PROJECTILE)) {
              if (((EntityDamageByEntityEvent) dev)
                  .getDamager()
                  .getType()
                  .toString()
                  .toLowerCase()
                  .equals("snowball")) {
                Entity bullet = ((EntityDamageByEntityEvent) dev).getDamager();
                if (bullet instanceof Snowball) {
                  if (((Snowball) ((EntityDamageByEntityEvent) dev).getDamager()).getShooter()
                      instanceof Player) {
                    Player gunner =
                        (Player)
                            ((Snowball) ((EntityDamageByEntityEvent) dev).getDamager())
                                .getShooter();
                    if (gunner != null && plugin.isInArena(gunner)) {
                      String gunnerp = gunner.getName();
                      event.getDrops().clear();

                      // Dead player
                      if (dead instanceof Player) {
                        if (plugin.isInArena(dead.getLocation())) {
                          Player deadplayer = (Player) dead;
                          ArenaPlayer dp = plugin.getArenaPlayer(deadplayer);

                          dp.killstreak = 0;
                          dp.deaths++;

                          String line1 =
                              ChatColor.GREEN
                                  + deadplayer.getName()
                                  + ChatColor.WHITE
                                  + " 已被 "
                                  + ChatColor.RED
                                  + gunnerp
                                  + ChatColor.WHITE
                                  + " 杀死";
                          String line2 = ChatColor.RED + "----------------------------";
                          String line3 =
                              ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(deadplayer).kills;
                          String line4 =
                              ChatColor.RED + "死亡: " + plugin.getArenaPlayer(deadplayer).deaths;
                          String line5 = ChatColor.RED + "----------------------------";

                          deadplayer.sendMessage(line1);
                          deadplayer.sendMessage(line2);
                          deadplayer.sendMessage(line3);
                          deadplayer.sendMessage(line4);
                          deadplayer.sendMessage(line5);
                        }
                      }

                      // Killer
                      if (gunner instanceof Player) {
                        if (plugin.isInArena(gunner)) {
                          plugin.getArenaPlayer(gunner).killstreak++;
                          plugin.getArenaPlayer(gunner).kills++;
                          plugin.getArenaPlayer(gunner).XP += 25;

                          String line1 =
                              ChatColor.GREEN
                                  + gunnerp
                                  + ChatColor.WHITE
                                  + " 杀死了 "
                                  + ChatColor.RED
                                  + dead.getType().getName();
                          String line2 = ChatColor.RED + "----------------------------";
                          String line3 =
                              ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(gunner).kills;
                          String line4 =
                              ChatColor.RED + "死亡: " + plugin.getArenaPlayer(gunner).deaths;
                          String line5 = ChatColor.RED + "----------------------------";

                          gunner.sendMessage(line1);
                          gunner.sendMessage(line2);
                          gunner.sendMessage(line3);
                          gunner.sendMessage(line4);
                          gunner.sendMessage(line5);
                        }
                      }
                    }
                  }
                }
              }

              return;
            } else {
              if (plugin.isInArena(dead)) {
                event.getDrops().clear();
                plugin.getArenaPlayer(dead).killstreak = 0;

                plugin.getArenaPlayer(dead).deaths++;
                String line2 = ChatColor.RED + dead.getName() + " 你已被 " + dc.toString() + " 杀死";
                String line3 = ChatColor.RED + "----------------------------";
                String line4 = ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(dead).kills;
                String line5 = ChatColor.RED + "死亡: " + plugin.getArenaPlayer(dead).deaths;
                String line6 = ChatColor.RED + "----------------------------";

                dead.sendMessage(line2);
                dead.sendMessage(line3);
                dead.sendMessage(line4);
                dead.sendMessage(line5);
                dead.sendMessage(line6);
              }

              return;
            }
          }
        } else {
          LivingEntity dead = (LivingEntity) event.getEntity();
          if (dev.getCause() != null) {
            DamageCause dc = dev.getCause();
            if (dc.equals(DamageCause.PROJECTILE)) {
              if (((EntityDamageByEntityEvent) dev)
                  .getDamager()
                  .getType()
                  .toString()
                  .equalsIgnoreCase("snowball")) {
                Entity bullet = ((EntityDamageByEntityEvent) dev).getDamager();
                if (bullet instanceof Snowball) {
                  if (((Snowball) ((EntityDamageByEntityEvent) dev).getDamager()).getShooter()
                      instanceof Player) {
                    Player gunner =
                        (Player)
                            ((Snowball) ((EntityDamageByEntityEvent) dev).getDamager())
                                .getShooter();
                    if (gunner != null) {
                      String gunnerp = gunner.getName();
                      event.getDrops().clear();

                      // Dead player
                      if (dead instanceof Player) {
                        if (plugin.isInArena(dead.getLocation())) {
                          Player deadplayer = (Player) dead;
                          plugin.getArenaPlayer(deadplayer).killstreak = 0;
                          plugin.getArenaPlayer(deadplayer).deaths++;
                          String line1 =
                              ChatColor.GREEN
                                  + deadplayer.getName()
                                  + ChatColor.WHITE
                                  + " 已被 "
                                  + ChatColor.RED
                                  + gunnerp
                                  + ChatColor.WHITE
                                  + " 杀死";
                          String line2 = ChatColor.RED + "----------------------------";
                          String line3 =
                              ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(deadplayer).kills;
                          String line4 =
                              ChatColor.RED + "死亡: " + plugin.getArenaPlayer(deadplayer).deaths;
                          String line5 = ChatColor.RED + "----------------------------";

                          deadplayer.sendMessage(line1);
                          deadplayer.sendMessage(line2);
                          deadplayer.sendMessage(line3);
                          deadplayer.sendMessage(line4);
                          deadplayer.sendMessage(line5);
                        }
                      }

                      // Killer
                      if (gunner instanceof Player) {
                        if (plugin.isInArena(gunner)) {
                          plugin.getArenaPlayer(gunner).killstreak++;
                          plugin.getArenaPlayer(gunner).kills++;
                          plugin.getArenaPlayer(gunner).XP += 25;

                          String line1 =
                              ChatColor.GREEN
                                  + gunnerp
                                  + ChatColor.WHITE
                                  + " 杀死了 "
                                  + ChatColor.RED
                                  + dead.getType().getName();
                          String line2 = ChatColor.RED + "----------------------------";
                          String line3 =
                              ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(gunner).kills;
                          String line4 =
                              ChatColor.RED + "死亡: " + plugin.getArenaPlayer(gunner).deaths;
                          String line5 = ChatColor.RED + "----------------------------";

                          gunner.sendMessage(line1);
                          gunner.sendMessage(line2);
                          gunner.sendMessage(line3);
                          gunner.sendMessage(line4);
                          gunner.sendMessage(line5);
                        }
                      }

                      if ((gunner instanceof Player) && (dead instanceof Player)) {
                        if ((gunner != null) && (dead != null)) {
                          ArenaPlayer ag = plugin.getArenaPlayer(gunner);
                          ArenaPlayer ad = plugin.getArenaPlayer((Player) dead);
                          Arena ar = plugin.getArena(gunner);

                          UltimateArenaKillEvent killEvent = new UltimateArenaKillEvent(ad, ag, ar);
                          plugin.getServer().getPluginManager().callEvent(killEvent);
                        }
                      }
                    }
                  }
                }
              }

              return;
            } else if (dc.equals(DamageCause.ENTITY_ATTACK)) {
              Entity damager = ((EntityDamageByEntityEvent) dev).getDamager();
              if (damager instanceof Player) {
                Player attacker = (Player) ((EntityDamageByEntityEvent) dev).getDamager();
                if (plugin.isInArena(attacker)) {
                  event.getDrops().clear();
                  if (plugin.isInArena(attacker.getLocation())) {
                    plugin.getArenaPlayer(attacker).kills++;
                    plugin.getArenaPlayer(attacker).killstreak++;
                    plugin.getArenaPlayer(attacker).XP += 25;

                    String attstr = dead.getType().getName();

                    String line1 =
                        ChatColor.GREEN
                            + attacker.getName()
                            + ChatColor.WHITE
                            + " 杀死了 "
                            + ChatColor.RED
                            + attstr;
                    String line2 = ChatColor.RED + "杀死了 " + attstr + " +25 XP";
                    String line3 = ChatColor.RED + "----------------------------";
                    String line4 = ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(attacker).kills;
                    String line5 = ChatColor.RED + "死亡: " + plugin.getArenaPlayer(attacker).deaths;
                    String line6 = ChatColor.RED + "----------------------------";

                    attacker.sendMessage(line1);
                    attacker.sendMessage(line2);
                    attacker.sendMessage(line3);
                    attacker.sendMessage(line4);
                    attacker.sendMessage(line5);
                    attacker.sendMessage(line6);

                    Arena ar = plugin.getArena(attacker);
                    ar.doKillStreak(plugin.getArenaPlayer(attacker));
                  }
                }
              }

              return;
            } else if (dc.equals(DamageCause.PROJECTILE)) {
              Entity damager = ((EntityDamageByEntityEvent) dev).getDamager();
              if (damager instanceof Arrow) {
                if (((Arrow) ((EntityDamageByEntityEvent) dev).getDamager()).getShooter()
                    instanceof Player) {
                  Player attacker =
                      (Player)
                          ((Arrow) ((EntityDamageByEntityEvent) dev).getDamager()).getShooter();
                  if (plugin.isInArena(attacker)) {
                    event.getDrops().clear();
                    if (plugin.isInArena(attacker.getLocation())) {
                      plugin.getArenaPlayer(attacker).kills++;
                      plugin.getArenaPlayer(attacker).killstreak++;
                      plugin.getArenaPlayer(attacker).XP += 25;

                      String attstr = dead.getType().getName();

                      String line1 =
                          ChatColor.GREEN
                              + attacker.getName()
                              + ChatColor.WHITE
                              + " 杀死了 "
                              + ChatColor.RED
                              + attstr;
                      String line2 = ChatColor.RED + "杀死了 " + attstr + " +25 XP";
                      String line3 = ChatColor.RED + "----------------------------";
                      String line4 = ChatColor.RED + "杀敌: " + plugin.getArenaPlayer(attacker).kills;
                      String line5 =
                          ChatColor.RED + "死亡: " + plugin.getArenaPlayer(attacker).deaths;
                      String line6 = ChatColor.RED + "----------------------------";

                      attacker.sendMessage(line1);
                      attacker.sendMessage(line2);
                      attacker.sendMessage(line3);
                      attacker.sendMessage(line4);
                      attacker.sendMessage(line5);
                      attacker.sendMessage(line6);

                      Arena ar = plugin.getArena(attacker);
                      ar.doKillStreak(plugin.getArenaPlayer(attacker));
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }