@EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (!(event.isCancelled())
       && ((event.getCause().equals(DamageCause.ENTITY_EXPLOSION))
           || (event.getCause().equals(DamageCause.BLOCK_EXPLOSION)))
       && (event.getEntity() instanceof Player)) {
     Player player = (Player) event.getEntity();
     Hero hero = plugin.getCharacterManager().getHero(player);
     if (hero.hasEffect("BlastResistance")) {
       int level = hero.getSkillLevel(this.skill);
       double amount =
           (SkillConfigManager.getUseSetting(
                   hero, this.skill, Setting.AMOUNT.node(), 0.25, false)
               + (SkillConfigManager.getUseSetting(
                       hero, this.skill, "amount-increase", 0.0, false)
                   * level));
       if (hst != null)
         amount +=
             (SkillConfigManager.getUseSetting(hero, skill, "hst-amount", 0.0, false)
                 * (hst.getSkillLevel(hero, skill) - 1));
       amount = amount > 0 ? amount : 0;
       event.setDamage((int) (event.getDamage() * (1 - amount)));
     }
   }
 }
예제 #2
0
  @EventHandler(priority = EventPriority.HIGH)
  public void onEntityDamage(EntityDamageEvent event_) {
    // If the event is cancelled, then we want to return.
    if (event_.isCancelled() == true) return;

    // Block damage in creative world.
    WorldConfig wm = new WorldConfig();

    if (!wm.getIsRpg(event_.getEntity().getWorld().getName())) return;

    // Store event.
    event = event_;

    // Set defaults.
    setGlobalDefaults();

    // Always set event damage to 0.
    event.setDamage(0);

    boolean dealEnviromentalDamage = false;

    // For entity damage events we want to handle the attck normally.
    if (event instanceof EntityDamageByEntityEvent) {
      Entity damager = ((EntityDamageByEntityEvent) event).getDamager();

      if (damager.getType() == EntityType.WITHER) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.WITHER_SKULL) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.SPLASH_POTION) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.PRIMED_TNT) dealEnviromentalDamage = true;
      else entityAttack((EntityDamageByEntityEvent) event, -1);
    } else dealEnviromentalDamage = true;

    // Else we want to deal the damage to the player/mob as though not from an entity.
    if (dealEnviromentalDamage == true) {
      // If the defender is a player, then we attacker player defender.
      if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();

        // Prevent damage done to already dead players
        if (FC_Rpg.rpgEntityManager.getRpgPlayer(player).playerConfig.getIsActive() == true) {
          if (FC_Rpg.rpgEntityManager.getRpgPlayer(player).getIsAlive() == false) return;
        }

        // Prepare the defender.
        prepareDefender(player);

        double damage = getEnviromentalDamage(player);

        if (damage == 0) return;

        // Attack the player with enviromental damage.
        edm.attackPlayerDefender(
            rpgDefender, null, null, damage, damageType, event.getCause().toString());
      } else {
        // If the event entity is a livingentity and the damage isn't fall damage, then nuke.
        if (event.getCause() != DamageCause.FALL && event.getEntity() instanceof LivingEntity)
          edm.nukeMob((LivingEntity) event.getEntity());
      }
    }
  }
예제 #3
0
 private void damageEvents(EntityDamageEvent e) {
   if (!(e.getEntity() instanceof Player)) return;
   Player p = (Player) e.getEntity();
   if (p.getGameMode() == GameMode.CREATIVE) return;
   PlayerDetails d = getPlayerDetails(p);
   if (d == null) // make way for hacky plugins!
   return;
   ClassDetails c = MQCoreRPG.classManager.getClassDetail(d.getClassID());
   int amount = c.getDamageFromCause(e.getCause()) + e.getDamage();
   long total = d.getHealth() - amount;
   if (total < 0) total = 0;
   int minecrafthealth = d.getMinecraftHealth(total);
   int minecraftcurrent = p.getHealth();
   e.setDamage(minecraftcurrent - minecrafthealth);
   switch (e.getCause()) {
     case FIRE:
     case CONTACT:
     case LAVA:
     case VOID:
       d.setHealth(total, false);
       break;
     default:
       d.setHealth(total);
       break;
   }
 }
예제 #4
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);
        }
      }
    }
  }
 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);
   }
 }
 /* (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);
           }
         }
       }
     }
   }
 }
  @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;
    }
  }
예제 #8
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onEDamaged(EntityDamageEvent event) {

    if (event.getEntity() instanceof Player) {
      DamageCause cause = event.getCause();
      if (cause != DamageCause.LAVA && cause != DamageCause.FIRE) {
        Player p = (Player) event.getEntity();
        // p.sendMessage("Au!");
        // formula daño equivalente
        int evdmg = event.getDamage();
        double resHP = event.getDamage();
        double tempop = 0;
        event.setDamage(0);
        double CH = plugin.PCH.get(p.getName().toLowerCase());
        double MH = plugin.PMH.get(p.getName().toLowerCase());
        CH = CH - evdmg;
        tempop = MH / 20;
        resHP = CH / tempop;
        p.setHealth((int) resHP);
        plugin.PCH.put(p.getName().toLowerCase(), CH);
        p.sendMessage(
            "HP: " + ChatColor.AQUA + CH + ChatColor.GRAY + "/" + ChatColor.DARK_AQUA + MH);

      } else {
        Player p = (Player) event.getEntity();
        double HP = p.getHealth();
        double CH = plugin.PCH.get(p.getName().toLowerCase());
        double MH = plugin.PMH.get(p.getName().toLowerCase());
        double tempop = 0;
        tempop = MH / 20;
        CH = HP * tempop;
        plugin.PCH.put(p.getName().toLowerCase(), CH);
      }
    }
  }
예제 #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);
    }
예제 #10
0
    // Damage Hook
    public void onEntityDamage(EntityDamageEvent event) {
      // No point in running if this has been stopped
      if (event.isCancelled()) {
        return;
      }

      // Is this a player?
      if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        PotionEntry entry = getPlugin().BuffList.get(player);

        // Elixir of Obsidian Skin
        if (entry != null && entry.HasBuff.get(Name) != null && entry.HasBuff.get(Name)) {
          // Halve all damages that have sources.
          // (Note, this means that direct damage through plugins
          // and such are left alone)
          if (event.getCause() != null) {
            int damage = event.getDamage();
            damage = (int) (damage * 0.5);
            damage = Math.max(damage, 1);
            event.setDamage(damage);
          }
        }
      }
    }
예제 #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
  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());
  }
예제 #13
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);
 }
예제 #14
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);
    }
  }
  @EventHandler(priority = EventPriority.LOWEST)
  public void onPlayerDeath(PlayerDeathEvent event) {
    EntityDamageEvent ede = event.getEntity().getLastDamageCause();

    if ((ede != null) && (ede.getCause() != null) && (ede.getCause() == DamageCause.LAVA)) {
      Player player = event.getEntity();
      Location loc = player.getLocation();
      LavaTrain lT = LavaTrain.getLavaTrain(loc.getBlock());
      if (lT != null) {
        event.setDeathMessage(
            player.getName() + " died swimming in " + lT.getPlayer().getName() + "'s lava train");
      }
    }

    if (ede instanceof BendingDamageEvent) {
      Player player = event.getEntity();
      BendingDamageEvent bede = (BendingDamageEvent) ede;
      if (bede.getAbility() == null) {
        event.setDeathMessage(player.getName() + " died from unknown bending");
      } else {
        event.setDeathMessage(
            ChatColor.DARK_RED
                + player.getName()
                + ChatColor.RESET
                + " died from "
                + ChatColor.DARK_GREEN
                + bede.getAbility().getPlayer().getName()
                + ChatColor.RESET
                + "'s "
                + PluginTools.getColor(Settings.getColor(bede.getAbility().getElement()))
                + bede.getAbility().getName());
      }
    }

    // Fireblade & Suffocate
    List<ItemStack> toRemove = new LinkedList<ItemStack>();
    for (ItemStack item : event.getDrops()) {
      if (Suffocate.isTempHelmet(item)) {
        toRemove.add(item);
      }
    }
    event.getDrops().removeAll(toRemove);

    if (EntityTools.isGrabed(event.getEntity())) {
      EntityTools.unGrab(event.getEntity());
    }
  }
예제 #16
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);
  }
예제 #17
0
 @EventHandler
 public void fall(EntityDamageEvent event) {
   if (event.getEntity().getWorld().getName().equals(name)) {
     if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
       event.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;
      }
    }
  }
예제 #19
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);
       }
     }
   }
 }
예제 #20
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);
     }
   }
 }
예제 #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);
   }
 }
예제 #22
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);
     }
   }
 }
예제 #23
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());
     }
   }
 }
예제 #25
0
  /**
   * On entity damage.
   *
   * @param event the events
   */
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onEntityDamage(EntityDamageEvent event) {

    // Check for fire cancel
    if (event.getEntity() instanceof Player
        && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) {

      Player player = (Player) event.getEntity();
      ApiPlayerConfEntry entry = playerConf.get(player);

      if (entry != null) {
        Location loc = player.getLocation();
        ApiDummyLand land = Secuboid.getThisPlugin().getLands().getLandOrOutsideArea(loc);

        // Check for fire near the player
        for (Map.Entry<Location, ApiPlayerContainerPlayer> fireEntry :
            playerFireLocation.entrySet()) {

          if (loc.getWorld() == fireEntry.getKey().getWorld()
              && loc.distanceSquared(fireEntry.getKey()) < 5) {
            Block block = loc.getBlock();
            if ((block.getType() == Material.FIRE || block.getType() == Material.AIR)
                && !isPvpValid(land, fireEntry.getValue(), entry.getPlayerContainer())) {

              // remove fire
              Secuboid.getThisPlugin()
                  .getLog()
                  .write(
                      "Anti-pvp from "
                          + entry.getPlayerContainer().getPlayer().getName()
                          + " to "
                          + player.getName());
              block.setType(Material.AIR);
              player.setFireTicks(0);
              event.setDamage(0);
              event.setCancelled(true);
            }
          }
        }
      }
    }
  }
예제 #26
0
 @EventHandler
 public void onFallDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     final Player victim = (Player) event.getEntity();
     if (TeleportationTask.getNoFallDamage().contains(victim.getName())) {
       if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
         event.setCancelled(true);
         TeleportationTask.getNoFallDamage().remove(victim.getName());
       }
     }
   }
 }
예제 #27
0
 @EventHandler
 public void onEntityDamageEvent(EntityDamageEvent event) {
   if (Lobby.get().isLobbyEnabled()) {
     if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
       Entity entity = event.getEntity();
       if (entity != null) {
         entity.teleport(Settings.get().getLobbyLocation());
       }
     }
     event.setCancelled(true);
   }
 }
예제 #28
0
  @EventHandler
  public void onDrownOrFall(EntityDamageEvent e) {
    if (e.getEntity() instanceof Player && e.getCause() == EntityDamageEvent.DamageCause.DROWNING) {
      if (!WorldCheck.isEnabled(e.getEntity().getWorld())) return;
      Player p = (Player) e.getEntity();
      if (Races.getMGPlayer(p).getAbilityLevel(AbilityType.FEESH) > 1) {
        e.setCancelled(true);
      }
    } else if (e.getEntity() instanceof Player
        && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
      Player p = (Player) e.getEntity();
      if (Races.getMGPlayer(p).getAbilityLevel(AbilityType.GLACIOUS) > 2) {
        Material mat = p.getLocation().getBlock().getRelative(BlockFace.DOWN).getType();
        Material mat2 = p.getLocation().getBlock().getType();

        if (snowBlocks.contains(mat) || snowBlocks.contains(mat2)) {
          e.setDamage(0.0);
          e.setCancelled(true);
        }
      }
    }
  }
예제 #29
0
 @EventHandler
 public void onPlayerFall(EntityDamageEvent event) {
   if (!(event.getEntity() instanceof Player)) {
     return;
   }
   if (event.getCause() != EntityDamageEvent.DamageCause.FALL) {
     return;
   }
   GamePlayer gamePlayer = PlayerManager.getPlayer(event.getEntity());
   if (gamePlayer.getGame() != null && !gamePlayer.getGame().isFallDamage()) {
     event.setCancelled(true);
   }
 }
예제 #30
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void dmg(final EntityDamageEvent event) {
   Entity e = event.getEntity();
   if (e instanceof Player) {
     if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
       Player p = (Player) e;
       if (p.hasPermission("cooljump.jump")) {
         event.setCancelled(true);
         p.setAllowFlight(true);
       }
     }
   }
 }