Пример #1
0
  public void onEntityDamage(EntityDamageEvent event) {
    if (event instanceof EntityDamageByEntityEvent
        || event instanceof EntityDamageByProjectileEvent) {
      handlerAttackDefend((EntityDamageByEntityEvent) event);
    } else if (event.getCause() == DamageCause.FIRE_TICK) {
      Entity entity = event.getEntity();
      if (entity instanceof Player) {
        Player player = (Player) entity;
        Team team = war.getPlayerTeam(player.getName());
        if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
          // smother out the fire that didn't burn out when you respawned
          // Stop fire (upcast, watch out!)
          if (player instanceof CraftPlayer) {
            net.minecraft.server.Entity playerEntity = ((CraftPlayer) player).getHandle();
            playerEntity.fireTicks = 0;
          }
          event.setCancelled(true);
        }
      }

    } else if (event.getCause() == DamageCause.DROWNING) {
      Entity entity = event.getEntity();
      if (entity instanceof Player) {
        Player player = (Player) entity;
        Team team = war.getPlayerTeam(player.getName());
        if (team != null && player.getHealth() <= 0) {
          // don't keep killing drowing player: trying to stop "Player moved wrongly!" error at
          // respawn.
          event.setCancelled(true);
        }
      }
    }
  }
 /* (non-Javadoc)
  * @see org.bukkit.event.entity.EntityListener#onEntityDamage(org.bukkit.event.entity.EntityDamageEvent)
  */
 @Override
 public void onEntityDamage(EntityDamageEvent event) {
   if (!event.isCancelled()
       && (event.getCause().equals(DamageCause.FIRE)
           || event.getCause().equals(DamageCause.FIRE_TICK)
           || event.getCause().equals(DamageCause.LAVA))) {
     if (event.getEntity() instanceof Player) {
       Player p = (Player) event.getEntity();
       if (ConfigManager.getPortalMaterial().equals(Material.STATIONARY_LAVA)) {
         Location current = p.getLocation();
         Stargate closest = Stargate.FindClosestStargate(current);
         if (closest != null) {
           double blockDistanceSquared =
               Stargate.distanceSquaredToClosestGateBlock(current, closest);
           if (closest.Active
               && ((blockDistanceSquared <= closest.GateShape.woosh_depth_squared
                       && closest.GateShape.woosh_depth != 0)
                   || blockDistanceSquared <= 16)) {
             WormholeXTreme.thisPlugin.prettyLog(
                 Level.FINE,
                 false,
                 "Blocked Gate: \""
                     + closest.Name
                     + "\" Proximity Event: \""
                     + event.getCause().toString()
                     + "\" On: \""
                     + p.getName()
                     + "\" Distance Squared: \""
                     + blockDistanceSquared
                     + "\"");
             event.setCancelled(true);
             p.setFireTicks(0);
           } else if (!closest.Active && blockDistanceSquared <= 4) {
             WormholeXTreme.thisPlugin.prettyLog(
                 Level.FINE,
                 false,
                 "Blocked Gate: \""
                     + closest.Name
                     + "\" Proximity Event: \""
                     + event.getCause().toString()
                     + "\" On: \""
                     + p.getName()
                     + "\" Distance Squared: \""
                     + blockDistanceSquared
                     + "\"");
             event.setCancelled(true);
             p.setFireTicks(0);
           }
         }
       }
     }
   }
 }
Пример #3
0
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Horse) {
     Horse h = (Horse) e.getEntity();
     if (h.hasMetadata("FrozenHorse")) {
       e.setCancelled(true);
     }
     if (h.hasMetadata("InfernalHorse")) {
       e.setCancelled(true);
     }
   }
 }
Пример #4
0
  @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;
    }
  }
Пример #5
0
  @ArenaEventHandler(suppressCastWarnings = true, priority = EventPriority.LOW)
  public void onEntityDamageEvent(EntityDamageEvent event) {
    if (!(event.getEntity() instanceof Player)) return;
    final TransitionOptions to = transitionOptions.getOptions(match.getMatchState());
    if (to == null) return;
    final PVPState pvp = to.getPVP();
    if (pvp == null) return;
    final ArenaPlayer target = BattleArena.toArenaPlayer((Player) event.getEntity());
    if (pvp == PVPState.INVINCIBLE) {
      /// all damage is cancelled
      target.setFireTicks(0);
      handler.setDamage(event, 0);
      event.setCancelled(true);
      return;
    }
    if (!(event instanceof EntityDamageByEntityEvent)) {
      return;
    }

    final Entity damagerEntity = ((EntityDamageByEntityEvent) event).getDamager();
    ArenaPlayer damager;
    switch (pvp) {
      case ON:
        ArenaTeam targetTeam = match.getTeam(target);
        if (targetTeam == null
            || !targetTeam.hasAliveMember(target)) // / We dont care about dead players
        return;
        damager = DmgDeathUtil.getPlayerCause(damagerEntity);
        if (damager == null) { // / damage from some source, its not pvp though. so we dont care
          return;
        }
        ArenaTeam t = match.getTeam(damager);
        if (t != null && t.hasMember(target)) { // / attacker is on the same team
          event.setCancelled(true);
        } else { /// different teams... lets make sure they can actually hit
          event.setCancelled(false);
        }
        break;
      case OFF:
        damager = DmgDeathUtil.getPlayerCause(damagerEntity);
        if (damager != null) { // / damage done from a player
          handler.setDamage(event, 0);
          event.setCancelled(true);
        }
        break;
      default:
        break;
    }
  }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamage(EntityDamageEvent ede) {
    List<EntityType> canDamageTypes = new ArrayList<EntityType>();
    canDamageTypes.add(EntityType.PLAYER);

    if (Main.getInstance().getServer().getPluginManager().isPluginEnabled("AntiAura")) {
      canDamageTypes.add(EntityType.SQUID);
    }

    if (canDamageTypes.contains(ede.getEntityType())) {
      return;
    }

    Game game =
        Main.getInstance().getGameManager().getGameByLocation(ede.getEntity().getLocation());
    if (game == null) {
      return;
    }

    if (game.getState() == GameState.STOPPED) {
      return;
    }

    ede.setCancelled(true);
  }
Пример #7
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player p = (Player) event.getEntity();
     if (um.isSpectator(p.getName())) event.setCancelled(true);
   }
 }
Пример #8
0
  @EventHandler(priority = EventPriority.HIGHEST)
  private void onEntityDamage(EntityDamageEvent evt) {
    if (!(evt.getEntity() instanceof Player)) {
      return;
    }
    Player p = (Player) evt.getEntity();
    PlayerDataClass pData = plugin.getPlayerHandler().findPlayer(p.getDisplayName());
    if (pData != null) {
      if (evt.getCause() == DamageCause.FALL) {
        Player player = (Player) evt.getEntity();
        if (plugin.getPlayerHandler().findPlayer(player.getDisplayName()) != null) {

          PlayerDataClass playerData =
              plugin.getPlayerHandler().findPlayer(player.getDisplayName());

          if (playerData.getType().equalsIgnoreCase("soldier")) {
            if (evt.getDamage() > 4) {
              evt.setDamage(4);
            }
          }
        }
      }
    } else {
      evt.setCancelled(true);
    }
  }
Пример #9
0
 @EventHandler(priority = EventPriority.LOWEST)
 public void onEntityDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof SpoutPlayer) {
     event.setCancelled(
         event.isCancelled() || !((SpoutPlayer) event.getEntity()).isPreCachingComplete());
   }
 }
Пример #10
0
  public void setGlobalDefaults() {
    // Cancel the event.
    event.setCancelled(true);

    playerDefender = null;
    playerAttacker = null;
    party = null;

    defendChance = new Random();
    counterattackChance = new Random();

    mac = null;
    edm = new EntityDamageManager();

    rpgDefender = null;
    rpgAttacker = null;
    rpgMobAttacker = null;
    rpgMobDefender = null;

    preventInfiniteSpecial = false;
    cancelRpgDamage = false;

    memberCount = 0;
    posX = 0;
    posZ = 0;
    damageType = 0;

    creatureAttacker = null;
    mobDefender = null;
  }
Пример #11
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void onEntityDamage(EntityDamageEvent event) {

    if (event.isCancelled()) {
      return;
    }

    Entity p2 = event.getEntity();

    db.i(
        "onEntityDamage: cause: " + event.getCause().name() + " : " + event.getEntity().toString());

    if ((p2 == null) || (!(p2 instanceof Player))) {
      return;
    }

    Arena arena = Arenas.getArenaByPlayer((Player) p2);
    if (arena == null) {
      // defender no arena player => out
      return;
    }

    Player defender = (Player) p2;

    ArenaPlayer apDefender = ArenaPlayer.parsePlayer(defender);

    if (arena.REALEND_ID != -1
        || (!apDefender.getStatus().equals(Status.EMPTY)
            && !apDefender.getStatus().equals(Status.FIGHT))) {
      event.setCancelled(true);
      return;
    }
  }
Пример #12
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (!(event.getEntity() instanceof Player)) return;
   Player player = (Player) event.getEntity();
   if (!player.hasPermission("breathe.use")) return;
   if (event.getCause() == EntityDamageEvent.DamageCause.DROWNING) event.setCancelled(true);
 }
  @EventHandler
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.isCancelled()) {
      return;
    }
    Entity entity = event.getEntity();

    if (!(entity instanceof Player)) {
      return;
    }

    if (instance.getCitizensCommunicator().isNPC(entity, instance)
        || Utils.getInstance().isUnrestricted((Player) entity)
        || CombatTagComunicator.isNPC(entity)) {
      return;
    }

    Player player = (Player) entity;
    String name = player.getName().toLowerCase();

    if (PlayerCache.getInstance().isAuthenticated(name)) {
      return;
    }

    if (!data.isAuthAvailable(name)) {
      if (!Settings.isForcedRegistrationEnabled) {
        return;
      }
    }
    player.setFireTicks(0);
    event.setCancelled(true);
  }
Пример #14
0
  // @EventHandler(priority = EventPriority.MONITOR)
  public void onDamage(EntityDamageEvent event) {
    Player p;
    if (event.getEntity() instanceof Player) {
      p = (Player) event.getEntity();
    } else {
      return;
    }

    if (!ArenaPlayerManager.isPlayerInArena(p)) return;

    String arenaName = ArenaPlayerManager.getArenaNameFromPlayer(p);

    if (!ArenaManager.isArenaRunning(arenaName)) return;

    Arena arena = ArenaManager.getArena(arenaName);

    if (event.getDamage() > p.getHealth()) {
      ArenaPlayerManager.getArenaFromPlayer(p).onDeath(p, event.getEntity());
      if (ArenaManager.getArenaSettings(arena).isShowRespawnScreen()) {
        return;
      }

      p.setHealth(20D);
      p.teleport(arena.getSpawnLocation(p));
      event.setCancelled(true);
    }
  }
Пример #15
0
  @EventHandler
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.getCause() != DamageCause.STARVATION || !(event.getEntity() instanceof Player))
      return;

    Player p = (Player) event.getEntity();
    if (p.hasPermission("fastfood.nostarve")) event.setCancelled(true);
  }
Пример #16
0
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.isCancelled()) return;

    if (event.getEntity() instanceof Player) {
      String playerName = ((Player) event.getEntity()).getName();
      if (AdminHandler.isGod(playerName)) event.setCancelled(true);
    }
  }
Пример #17
0
 @EventHandler
 public void fall(EntityDamageEvent event) {
   if (event.getEntity().getWorld().getName().equals(name)) {
     if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
       event.setCancelled(true);
     }
   }
 }
Пример #18
0
 public void onEntityDamage(EntityDamageEvent e) {
   if ((e.getEntity() instanceof Player)) {
     Player p = (Player) e.getEntity();
     if (MainCmd.plugin.getConfig().getBoolean("Players." + p.getName() + ".god")) {
       e.setCancelled(true);
     }
   }
 }
Пример #19
0
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     if (GameState.getState() == GameState.ENDING || GameState.getState() == GameState.LOBBY) {
       e.setCancelled(true);
     }
   }
 }
Пример #20
0
 @EventHandler(ignoreCancelled = true)
 public void onEntityDamage(EntityDamageEvent e) {
   if (e.getEntity().getLocation().getWorld().getName().equalsIgnoreCase(pl.worldName)) {
     if (e.getCause().equals(DamageCause.FIRE_TICK) || e.getCause().equals(DamageCause.FIRE)) {
       e.getEntity().setFireTicks(0);
       pl.getServer()
           .getScheduler()
           .scheduleSyncDelayedTask(pl, new StopFireRunnable(e.getEntity()), 1);
       e.setCancelled(true);
       return;
     }
     if (e.getEntity() instanceof Player) {
       if (pl.spectators.containsKey((Player) e.getEntity())) {
         e.setCancelled(true);
       }
     }
   }
 }
Пример #21
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player
       && e.getCause().equals(DamageCause.VOID)
       && Config.getConfig().getBoolean("teleport-to-spawn-on.void-fall")) {
     Utils.teleportToSpawn((Player) e.getEntity());
     e.setCancelled(true);
   }
 }
 @EventHandler
 public void onPlayerHurt(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     if (FOPM_TFM_Util.inGod(player)) {
       event.setCancelled(true);
     }
   }
 }
Пример #23
0
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     if (ArenaManager.getInstance().getArena(p) != null) {
       if (e.getCause() != DamageCause.ENTITY_ATTACK) e.setCancelled(true);
     }
   }
 }
Пример #24
0
 @EventHandler
 public void fall(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     if (Util.getKit(p) instanceof Poseidon) {
       if (e.getCause() == DamageCause.FALL) e.setCancelled(true);
     }
   }
 }
Пример #25
0
 public void onEntityDamage(EntityDamageEvent event) {
   // check if the entity is a player
   if ((event.getEntity() instanceof Player)
       && ((event.getCause() != DamageCause.LIGHTNING)
           || (event.getCause() != DamageCause.SUICIDE))) {
     // if so, cancel the damage
     event.setCancelled(true);
   }
 }
Пример #26
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void onDamage(EntityDamageEvent event) {
   Entity entity = event.getEntity();
   if (entity instanceof Player && plugin.noInteract((Player) entity)) {
     event.setCancelled(true);
     return;
   }
   if (!(event instanceof EntityDamageByEntityEvent)) {
     return;
   }
   entity = ((EntityDamageByEntityEvent) event).getDamager();
   if (entity instanceof Projectile) {
     entity = ((Projectile) entity).getShooter();
   }
   if (entity instanceof Player && plugin.noInteract((Player) entity)) {
     event.setCancelled(true);
   }
 }
Пример #27
0
 // Invincibility
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     if (Utilities.getUtilities().invincible.contains(player.getName())) {
       event.setCancelled(true);
     }
   }
 }
Пример #28
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void damageHandler(EntityDamageEvent event) {
   if (event.getEntityType() == EntityType.PLAYER) {
     AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId());
     if (p != null && p.getKit().equals(this) && p.getData("Cur") != null) {
       if (event.getCause() == DamageCause.FALL) event.setCancelled(true);
       else endLeap((Player) event.getEntity(), p);
     }
   }
 }
Пример #29
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     if (helpDeskInstance.doesHaveTicketAssigned(player)) {
       if (player.getFireTicks() > 0) player.setFireTicks(0);
       event.setCancelled(true);
     }
   }
 }
Пример #30
0
  @Override
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.isCancelled()) {
      return;
    }

    // Check if the event is about a player that is drowning
    if (event.getCause() == EntityDamageEvent.DamageCause.DROWNING
        && event.getEntity() instanceof CraftPlayer) {
      final CraftPlayer player = (CraftPlayer) event.getEntity();

      // Check if user got unlimited air node
      if (PermissionsHandler.hasPermission(player, Gills.getConfig().unlimitedAirNode)) {
        updatePlayerAirBubbles(player);
        event.setCancelled(true);
        return;
      }

      // Check if user access to gills
      if (!PermissionsHandler.hasPermission(player, Gills.getConfig().userNode)) {
        return;
      }

      int depth = getDepth(player);
      // Check itemsets
      for (GillsItemSet itemSet : Gills.getConfig().itemSets) {
        if (PermissionsHandler.hasPermission(player, itemSet.getNode())
            && itemSet.isTargetDepth(depth)
            && itemSet.isTargetAltitude(player.getLocation().getBlockY())
            && itemSet.isWorldAllowed(player.getLocation().getWorld().getName())
            && itemSet.gotRequiredItems(player)) {

          // Check is inside itemSet
          itemSet.consumeRequiredItems(player);

          updatePlayerAirBubbles(player);
          event.setCancelled(true);
          return;
        }
      }
    }
  }