Exemplo n.º 1
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);
    }
  }
Exemplo n.º 2
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);
   }
 }
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.getCause() != EntityDamageEvent.DamageCause.ENTITY_ATTACK) return;

    if (!(event instanceof EntityDamageByEntityEvent)) return;

    final Entity damagedEntity = event.getEntity();
    if (damagedEntity instanceof Player) return;

    if (!(damagedEntity instanceof LivingEntity)) return;

    final int entityId = damagedEntity.getEntityId();
    if (choppedEntities.contains(entityId)) return;

    final Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
    if (!(damager instanceof Player)) return;

    final Material materialInHand = ((Player) damager).getItemInHand().getType();

    switch (materialInHand) {
      case DIAMOND_SPADE:
      case GOLD_SPADE:
      case IRON_SPADE:
      case WOOD_SPADE:
      case STONE_SPADE:
        addChoppedEntity(entityId);
        break;
    }
  }
Exemplo n.º 4
0
 @EventHandler(priority = EventPriority.LOWEST)
 public void onEntityDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof SpoutPlayer) {
     event.setCancelled(
         event.isCancelled() || !((SpoutPlayer) event.getEntity()).isPreCachingComplete());
   }
 }
Exemplo n.º 5
0
  public static EventData getEventData(EntityDamageEvent event) {
    if (event == null) return null;

    DamageType damageElement = DamageType.get(event.getCause());

    Entity attacker = null;
    Projectile projectile = null;
    Entity target = event.getEntity();
    World world = target.getWorld();

    if (event instanceof EntityDamageByEntityEvent) {
      EntityDamageByEntityEvent event_EE = (EntityDamageByEntityEvent) event;
      Entity damager = event_EE.getDamager();

      if (damager instanceof Projectile) {
        projectile = (Projectile) damager;

        attacker = projectile.getShooter();
      } else {
        attacker = damager;
      }
    }

    return myInfo.makeData(
        attacker, projectile, target, world, damageElement, event.getDamage(), event.isCancelled());
  }
 @Override
 public void onEntityDamage(EntityDamageEvent event) {
   if (Player.class.isInstance(event.getEntity())) {
     Player player = (Player) event.getEntity();
     master.onPlayerDamage(player, event);
   }
 }
  @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);
  }
Exemplo n.º 8
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onEntityDamageEvent(EntityDamageEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getEntity() instanceof Player)) {
     return;
   }
   Player p = (Player) event.getEntity();
   ItemStack iimh = p.getEquipment().getItemInMainHand();
   Tier t = iimh != null ? TierUtil.getTierFromItemStack(iimh) : null;
   if (t != null && t.isInfiniteDurability()) {
     p.getEquipment().getItemInMainHand().setDurability((short) 0);
   }
   for (ItemStack is : p.getEquipment().getArmorContents()) {
     if (is == null || is.getType() == Material.AIR) {
       continue;
     }
     t = TierUtil.getTierFromItemStack(is);
     if (t == null) {
       continue;
     }
     if (t.isInfiniteDurability()) {
       is.setDurability((short) 0);
     }
   }
 }
Exemplo n.º 9
0
    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);
    }
  @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);
  }
Exemplo n.º 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;
    }
  }
Exemplo n.º 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);
 }
Exemplo n.º 13
0
 @EventHandler
 public void onDamage(EntityDamageEvent ev) {
   Entity ent = ev.getEntity();
   if (ent instanceof LivingEntity && unholyFlame.contains(ent)) {
     ev.setDamage(ev.getDamage() * 2.0);
   }
 }
Exemplo n.º 14
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);
    }
  }
Exemplo n.º 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);
  }
Exemplo n.º 16
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);
     }
   }
 }
Exemplo n.º 17
0
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     if (GameState.getState() == GameState.ENDING || GameState.getState() == GameState.LOBBY) {
       e.setCancelled(true);
     }
   }
 }
Exemplo n.º 18
0
 @EventHandler
 public void fall(EntityDamageEvent event) {
   if (event.getEntity().getWorld().getName().equals(name)) {
     if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
       event.setCancelled(true);
     }
   }
 }
Exemplo n.º 19
0
  // register that we just received this damage
  public void registerDamage(EntityDamageEvent e) {
    // sanity check...
    if (e.getEntity() != getPlayer()) return;

    // get the last damage cause, and mark that as the cause of the damage
    AutoRefPlayer.DamageCause dc = AutoRefPlayer.DamageCause.fromDamageEvent(e);
    damage.put(dc, e.getDamage() + damage.get(dc));
  }
Exemplo n.º 20
0
 // Non-Living Entities such as EntityEnderCrystal need to call this
 public static boolean handleNonLivingEntityDamageEvent(
     Entity entity, DamageSource source, int damage) {
   if (!(source instanceof EntityDamageSource)) {
     return false;
   }
   EntityDamageEvent event = handleEntityDamageEvent(entity, source, damage);
   return event.isCancelled() || event.getDamage() == 0;
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player) {

      Player p = (Player) event.getEntity();
      Hero hero = plugin.getHeroManager().getHero(p);
      HeroClass primclass = hero.getHeroClass();
      HeroClass secclass = hero.getSecondClass();
      SpoutPlayer sp = SpoutManager.getPlayer(p);

      int xpprim = (int) Math.round(hero.currentXPToNextLevel(primclass));
      int xpsec = (int) Math.round(hero.currentXPToNextLevel(secclass));

      if (hero != null) {

        String text =
            primclass
                + ": "
                + ChatColor.RED
                + hero.getHealth()
                + " / "
                + hero.getMaxHealth()
                + "\n"
                + ChatColor.DARK_RED
                + "Lvl/Exp: "
                + ChatColor.RED
                + hero.getLevel(primclass)
                + " / "
                + xpprim;

        if (secclass != null) {

          text +=
              "\n"
                  + ChatColor.DARK_GREEN
                  + "Prof: "
                  + ChatColor.GREEN
                  + secclass
                  + "\n"
                  + ChatColor.DARK_GREEN
                  + "LvL/Exp: "
                  + ChatColor.GREEN
                  + hero.getLevel(secclass)
                  + " / "
                  + xpsec;
        } else {
          text +=
              "\n"
                  + ChatColor.DARK_GREEN
                  + "You Dont have a"
                  + "\n"
                  + ChatColor.DARK_GREEN
                  + "Secondary Class!";
        }
        plugin.getGUI().updateLabel(sp, text);
      }
    }
  }
 @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);
     }
   }
 }
Exemplo n.º 23
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);
   }
 }
Exemplo n.º 24
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);
     }
   }
 }
Exemplo n.º 25
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);
     }
   }
 }
  private void handleNpeDeath(Entity subject) {
    EntityDamageEvent cause = subject.getLastDamageCause();

    // Increment the NPE's total death stat
    NpeData npeData = this.plugin.getNpeDataByClass(subject.getClass());
    npeData.incTotalDeaths();

    // Increment the ServerData statistics
    plugin.serverData.incNpesKilled();

    if (cause instanceof EntityDamageByEntityEvent) {
      Entity predicate = ((EntityDamageByEntityEvent) cause).getDamager();
      if (predicate instanceof Player) {
        // The NPE was killed by a player, reward them for their accomplishments
        PlayerData killerData = this.plugin.getPlayerData(((Player) predicate).getName(), "");
        String mobName = this.plugin.getSimpleClassName(subject.getClass()).toLowerCase();

        if (mobName.startsWith("craft")) {
          // it looks like a lot of the class names follow the format "CraftX", such as "CraftWolf"
          // or "CraftCreeper"
          mobName = mobName.substring(5);
        }

        if (killerData.getMobsKilled().containsKey(mobName)) {
          killerData.incMobsKilled(mobName);
        } else {
          plugin.log.info("MineJMX: A player killed an unknown mob type (\"" + mobName + "\")");
        }

        // and increment the NPE's specific death stat
        npeData.incDeathsByPlayer();
      } else {
        // The NPE was killed by another mob, increment NpeData statistics again
        NpeData killerData = this.plugin.getNpeDataByClass(predicate.getClass());
        killerData.incNpesKilled();

        // and increment the original NPE's specific death stat
        npeData.incDeathsByNpe();
      }
    } else if (cause instanceof EntityDamageByBlockEvent) {
      // killed by environment, increment the specific death counter
      npeData.incDeathsByEnvironment();
    } else {
      // drowned, burned, fell, etc...increment the environmental death counter
      switch (cause.getCause()) {
        case CONTACT:
        case DROWNING:
        case FALL:
        case FIRE:
        case FIRE_TICK:
        case LAVA:
        case LIGHTNING:
          npeData.incDeathsByEnvironment();
          break;
      }
    }
  }
Exemplo n.º 27
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);
   }
 }
Exemplo n.º 28
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);
     }
   }
 }
Exemplo n.º 29
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);
     }
   }
 }
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player && e.getCause() == DamageCause.FALL) {
     Player p = (Player) e.getEntity();
     if (spongify.contains(p.getName())) {
       e.setDamage(0);
       spongify.remove(p.getName());
     }
   }
 }