Ejemplo n.º 1
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onEntityDamage(EntityDamageEvent event) {
   // Cancels all forms of damage in the lobby
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     ArenaPlayer ap = plugin.getArenaPlayer(player);
     if (ap != null) {
       Arena arena = ap.getArena();
       if (arena.isInLobby()) {
         event.setCancelled(true);
       }
     }
   }
 }
Ejemplo n.º 2
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onEntityCombust(EntityCombustEvent event) {
   Entity entity = event.getEntity();
   if (entity instanceof Player) {
     Player player = (Player) entity;
     ArenaPlayer ap = plugin.getArenaPlayer(player);
     if (ap != null) {
       Arena arena = ap.getArena();
       if (arena.isInLobby()) {
         player.setFireTicks(0);
         event.setCancelled(true);
       }
     }
   }
 }
Ejemplo n.º 3
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onFoodLevelChange(FoodLevelChangeEvent event) {
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     ArenaPlayer ap = plugin.getArenaPlayer(player);
     if (ap != null) {
       Arena a = ap.getArena();
       if (a.isInLobby()) {
         // Prevent food level change
         player.setFoodLevel(20);
         event.setCancelled(true);
       }
     }
   }
 }
Ejemplo n.º 4
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onEntityDamageByEntityHighest(EntityDamageByEntityEvent event) {
    Player attacker = getPlayer(event.getDamager());
    if (attacker == null) return;

    Player defender = getPlayer(event.getEntity());
    if (defender == null) return;

    ArenaPlayer ap = plugin.getArenaPlayer(attacker);
    if (ap != null) {
      ArenaPlayer dp = plugin.getArenaPlayer(defender);
      if (dp != null) {
        Arena arena = ap.getArena();
        if (arena.isInLobby()) {
          // Prevent lobby PvP
          ap.sendMessage("&cYou cannot PvP in the lobby!");
          event.setCancelled(true);
          return;
        }

        // Prevent team killing
        if (!arena.isAllowTeamKilling()) {
          if (dp.getTeam() == ap.getTeam()) {
            ap.sendMessage("&cYou cannot hurt your team mate!");
            event.setCancelled(true);
            return;
          }
        }
      } else {
        ap.sendMessage("&cYou cannot hurt players not in the arena!");
        event.setCancelled(true);
        return;
      }
    } else {
      if (plugin.isInArena(defender)) {
        attacker.sendMessage(
            plugin.getPrefix()
                + FormatUtil.format("&cYou cannot hurt players while they are in an arena!"));
        event.setCancelled(true);
        return;
      }
    }
  }