@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; } }
public void onEntityDamage(EntityDamageEvent event) { if (event.isCancelled()) return; if (!Whitelist.worldCheck(event.getEntity().getWorld())) return; if (!(event.getEntity() instanceof Player)) return; if (!Whitelist.hasLevel((Player) event.getEntity(), plugin.thisPlug)) return; if (event.getCause() != DamageCause.FALL) return; Player p = (Player) event.getEntity(); int lvl = LevelFunctions.getLevel(p, plugin.thisPlug); int damageReduction = (int) ((lvl / 10) * plugin.LCConfiguration.fdMultiplier); if (event.getDamage() <= damageReduction) { event.setDamage(0); } else { event.setDamage(event.getDamage() - damageReduction); } }
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; } }
// 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); } } } }
@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 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))); } } }
@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); } } }
@EventHandler public void onDamage(EntityDamageEvent ev) { Entity ent = ev.getEntity(); if (ent instanceof LivingEntity && unholyFlame.contains(ent)) { ev.setDamage(ev.getDamage() * 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()); } } }
@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()); } } }
public boolean onEntityDamage_proceedDamage(ArenaPlayer arenaPlayer, EntityDamageEvent event) { boolean willDie = false; int damage = event.getDamage(); int oldHealth = arenaPlayer.getPlayer().getHealth(); int newHealth = oldHealth - damage; if (newHealth < 0) { event.setDamage(999); willDie = true; } return willDie; }
@EventHandler(ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { if (normalDamageTypes != null && normalDamageTypes.contains(event.getCause()) && event.getEntity() instanceof Player && isActive((Player) event.getEntity())) { Player player = (Player) event.getEntity(); float mult = multiplier; if (multiplier < 1) { mult *= (1 / buffed.get(player.getName())); } else if (multiplier > 1) { mult *= buffed.get(player.getName()); } event.setDamage(event.getDamage() * mult); addUseAndChargeCost(player); } }
/** * 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); } } } } } }
@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); } } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamage(EntityDamageEvent event) { if (!ModDamage.isEnabled || event.isCancelled()) return; if (!event.isCancelled() && (event.getEntity() instanceof LivingEntity)) { EventData data = getEventData(event); if (data != null) { runRoutines(data); int newDamage = data.get(Integer.class, data.start + 5); event.setCancelled(data.get(Boolean.class, data.start + data.objects.length - 1)); if (event.getDamage() != newDamage && newDamage <= 0) event.setCancelled(true); event.setDamage(newDamage); } else PluginConfiguration.log.severe( "[" + Bukkit.getPluginManager().getPlugin("ModDamage").getDescription().getName() + "] Error! Unhandled damage event. Is Bukkit and ModDamage up-to-date?"); } }
/** * Decreases damage dealt by the explosion. * * @param player Player triggering the explosion * @param event Event whose explosion damage is being reduced */ public static void demolitionsExpertise(Player player, EntityDamageEvent event) { final int RANK_1_LEVEL = 500; final int RANK_2_LEVEL = 750; final int RANK_3_LEVEL = 1000; int skill = Users.getProfile(player).getSkillLevel(SkillType.MINING); int damage = event.getDamage(); if (skill < RANK_1_LEVEL) { return; } if (skill >= RANK_3_LEVEL) { damage = 0; } else if (skill >= RANK_2_LEVEL) { damage = damage / 2; } else if (skill >= RANK_1_LEVEL) { damage = damage / 4; } event.setDamage(damage); }
@Override public void onEntityDamage(EntityDamageEvent event) { if (event instanceof EntityDamageByProjectileEvent) { EntityDamageByProjectileEvent edpe = (EntityDamageByProjectileEvent) event; if (edpe.getProjectile() instanceof Snowball) { Entity tgt = event.getEntity(); if (tgt instanceof LivingEntity) { Player pl = edpe.getDamager() instanceof Player ? (Player) edpe.getDamager() : null; if (SnowballzUtil.hasPermission(_plugin, pl, SnowballzConstants.PERMISSION_SNOWDAMAGE)) { event.setDamage(_plugin.getConfiguration().getInt(Snowballz.SNOW_DAMAGE, 1)); } if (tgt.getFireTicks() > 0 && _plugin.getConfiguration().getBoolean(Snowballz.SNOW_FIRE, true) && SnowballzUtil.hasPermission( _plugin, pl, SnowballzConstants.PERMISSION_PUTOUTFIRE)) { tgt.setFireTicks(0); } } } } }
@EventHandler public void onEntityDamage(EntityDamageEvent event) { if (event.getEntity() instanceof Zombie || event.getEntity() instanceof PigZombie) { if (event.getCause().equals(DamageCause.ENTITY_EXPLOSION) || event.getCause().equals(DamageCause.BLOCK_EXPLOSION)) { event.setDamage(event.getDamage() * 10); } if ((event.getCause().equals(DamageCause.FIRE_TICK) || event.getCause().equals(DamageCause.FIRE) || event.getCause().equals(DamageCause.LIGHTNING))) { event.setCancelled(true); event.getEntity().setFireTicks(0); } } if (event.getEntity() instanceof Giant) { if ((event.getCause().equals(DamageCause.FIRE_TICK) || event.getCause().equals(DamageCause.FIRE) || event.getCause().equals(DamageCause.LIGHTNING))) { event.setCancelled(true); event.getEntity().setFireTicks(0); } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamage(EntityDamageEvent evt) { if (!(evt.getEntity() instanceof Player)) { return; } Location l = evt.getEntity().getLocation(); World w = l.getWorld(); Chunk c = w.getChunkAt(l); Player p = (Player) evt.getEntity(); GlobalWorldSetting gws = GlobalRegionManager.getGlobalWorldSetting(w); Region r; ArrayList<Region> regionSet = new ArrayList<Region>(); for (Region region : GlobalRegionManager.getRegions()) { for (Chunk chunk : region.getChunkGrid().getChunks()) { if (chunk.getWorld() == w) { if (areChunksEqual(chunk, c)) { if (!regionSet.contains(region)) { regionSet.add(region); } } } } } if (regionSet.isEmpty()) { return; } ArrayList<Region> currentRegionSet = new ArrayList<Region>(); for (Region reg : regionSet) { Location rl1 = reg.getL1().toBukkitLocation(), rl2 = reg.getL2().toBukkitLocation(); if (extReg.isInsideCuboid(l, rl1, rl2)) { currentRegionSet.add(reg); } } if (currentRegionSet.isEmpty()) { // If player is in chunk range but not // inside region then cancel the // check. if (gws != null) { if (!gws.invert_pvp && gws.overridingPvp) { evt.setCancelled(true); return; } } return; } if (currentRegionSet.size() > 1) { r = srm.getCurrentRegion(p, currentRegionSet); } else { r = currentRegionSet.get(0); } if (!r.isHealthEnabled()) { evt.setCancelled(true); evt.setDamage(0); return; } if (!r.isPvpEnabled()) { if (evt instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent edevt = (EntityDamageByEntityEvent) evt; if (edevt.getDamager() instanceof Player && edevt.getEntity() instanceof Player) { Player damager = (Player) edevt.getDamager(); LogRunner.addLogMessage( r, LogRunner.getPrefix(r) + (" Player '" + damager.getName() + "' tried to attack '" + ((Player) evt.getEntity()).getName() + " but was prevented.")); damager.sendMessage( ChatColor.RED + "[Regios] You cannot fight within regions in this world!"); evt.setCancelled(true); evt.setDamage(0); return; } } } }
/** * Handle EntityDamage events that involve modifying the event. * * @param event The event to modify */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { if (event instanceof FakeEntityDamageEvent) { return; } double damage = event.getDamage(); if (damage <= 0) { return; } Entity entity = event.getEntity(); if (entity.hasMetadata(mcMMO.customDamageKey)) { entity.removeMetadata(mcMMO.customDamageKey, plugin); return; } if (Misc.isNPCEntity(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) { return; } LivingEntity livingEntity = (LivingEntity) entity; if (CombatUtils.isInvincible(livingEntity, damage)) { return; } DamageCause cause = event.getCause(); if (livingEntity instanceof Player) { Player player = (Player) entity; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); /* Check for invincibility */ if (mcMMOPlayer.getGodMode()) { event.setCancelled(true); return; } switch (cause) { case FALL: if (Config.getInstance().getPreventXPAfterTeleport() && SkillUtils.calculateTimeLeft( (long) mcMMOPlayer.getTeleportATS() * Misc.TIME_CONVERSION_FACTOR, 5, player) > 0) { return; } AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); if (acrobaticsManager.canRoll()) { event.setDamage(acrobaticsManager.rollCheck(event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); return; } } break; case BLOCK_EXPLOSION: MiningManager miningManager = mcMMOPlayer.getMiningManager(); if (miningManager.canUseDemolitionsExpertise()) { event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); return; } } break; default: break; } if (event.getDamage() >= 1) { mcMMOPlayer.actualizeRecentlyHurt(); } } else if (livingEntity instanceof Tameable) { Tameable pet = (Tameable) livingEntity; AnimalTamer owner = pet.getOwner(); if (Taming.canPreventDamage(pet, owner)) { Player player = (Player) owner; Wolf wolf = (Wolf) pet; TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager(); switch (cause) { case CONTACT: case FIRE: case LAVA: if (tamingManager.canUseEnvironmentallyAware()) { tamingManager.processEnvironmentallyAware(wolf, event.getDamage()); } return; case FALL: if (tamingManager.canUseEnvironmentallyAware()) { event.setCancelled(true); } return; case ENTITY_ATTACK: case PROJECTILE: if (tamingManager.canUseThickFur()) { event.setDamage(Taming.processThickFur(wolf, event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); } } return; case FIRE_TICK: if (tamingManager.canUseThickFur()) { Taming.processThickFurFire(wolf); } return; case MAGIC: case POISON: case WITHER: if (tamingManager.canUseHolyHound()) { Taming.processHolyHound(wolf, event.getDamage()); } return; case BLOCK_EXPLOSION: case ENTITY_EXPLOSION: case LIGHTNING: if (tamingManager.canUseShockProof()) { event.setDamage(Taming.processShockProof(wolf, event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); } } return; default: return; } } } }
@EventHandler public void onEntityDamage(EntityDamageEvent paramEntityDamageEvent) { Heroes.debug.startTask("HeroesSkillListener"); if ((!paramEntityDamageEvent.getCause().equals(EntityDamageEvent.DamageCause.FALL)) || (!(paramEntityDamageEvent.getEntity() instanceof Player)) || (!chargingPlayers.containsKey((Player) paramEntityDamageEvent.getEntity()))) { Heroes.debug.stopTask("HeroesSkillListener"); return; } Player localPlayer1 = (Player) paramEntityDamageEvent.getEntity(); Hero localHero1 = plugin.getCharacterManager().getHero(localPlayer1); double distance = localPlayer1.getLocation().distance(chargingPlayers.get(localPlayer1)); double damageMod = SkillConfigManager.getUseSetting( localHero1, skill, "damage-per-block-traveled", 0.1, false); double manaMod = SkillConfigManager.getUseSetting( localHero1, skill, "mana-per-block-traveled", 0.5, false); int currentMana = localHero1.getMana(); if (currentMana < distance * manaMod) { localHero1.setMana(0); } else { localHero1.setMana(currentMana - (int) (distance * manaMod)); } chargingPlayers.remove(localPlayer1); paramEntityDamageEvent.setDamage(0); paramEntityDamageEvent.setCancelled(true); int i = (int) (SkillConfigManager.getUseSetting( localHero1, this.skill, SkillSetting.RADIUS.node(), 2, false) + (SkillConfigManager.getUseSetting( localHero1, this.skill, SkillSetting.RADIUS_INCREASE.node(), 0.0, false) * localHero1.getSkillLevel(skill))); i = i > 0 ? i : 0; long l1 = (long) SkillConfigManager.getUseSetting( localHero1, this.skill, "stun-duration", 10000, false); if (l1 > 0) { l1 = (long) (l1 + (SkillConfigManager.getUseSetting( localHero1, this.skill, "duration-increase", 0.0, false) * localHero1.getSkillLevel(skill))); l1 = l1 > 0 ? l1 : 0; } long l2 = (long) SkillConfigManager.getUseSetting(localHero1, this.skill, "slow-duration", 0, false); if (l2 > 0) { l2 = (long) (l2 + (SkillConfigManager.getUseSetting( localHero1, this.skill, "duration-increase", 0.0, false) * localHero1.getSkillLevel(skill))); l2 = l2 > 0 ? l2 : 0; } long l3 = (long) SkillConfigManager.getUseSetting(localHero1, this.skill, "root-duration", 0, false); if (l3 > 0) { l3 = (long) (l3 + (SkillConfigManager.getUseSetting( localHero1, this.skill, "duration-increase", 0.0, false) * localHero1.getSkillLevel(skill))); l3 = l3 > 0 ? l3 : 0; } long l4 = (long) SkillConfigManager.getUseSetting( localHero1, this.skill, "silence-duration", 0, false); if (l4 > 0) { l4 = (long) (l4 + (SkillConfigManager.getUseSetting( localHero1, this.skill, "duration-increase", 0.0, false) * localHero1.getSkillLevel(skill))); l4 = l4 > 0 ? l4 : 0; } int j = (int) (SkillConfigManager.getUseSetting( localHero1, this.skill, SkillSetting.DAMAGE.node(), 0, false) + (SkillConfigManager.getUseSetting( localHero1, this.skill, "damage-increase", 0.0, false) * localHero1.getSkillLevel(skill))); j += damageMod * distance; j = j > 0 ? j : 0; long l5 = (long) SkillConfigManager.getUseSetting(localHero1, this.skill, "invuln-duration", 0, false); if (l5 > 0) { l5 = (long) (l5 + (SkillConfigManager.getUseSetting( localHero1, this.skill, "duration-increase", 0.0, false) * localHero1.getSkillLevel(skill))); l5 = l5 > 0 ? l5 : 0; if (l5 > 0) { localHero1.addEffect(new InvulnerabilityEffect(this.skill, l5)); } } Iterator localIterator = localPlayer1.getNearbyEntities(i, i, i).iterator(); while (localIterator.hasNext()) { Entity localEntity = (Entity) localIterator.next(); if (!(localEntity instanceof LivingEntity)) continue; LivingEntity localLivingEntity = (LivingEntity) localEntity; if (!damageCheck(localPlayer1, localLivingEntity)) continue; if ((localEntity instanceof Player)) { Player localPlayer2 = (Player) localEntity; Hero localHero2 = plugin.getCharacterManager().getHero(localPlayer2); if (l1 > 0L) localHero2.addEffect(new StunEffect(this.skill, l1)); if (l2 > 0L) localHero2.addEffect( new SlowEffect( this.skill, l2, 2, true, localPlayer2.getDisplayName() + " has been slowed by " + localPlayer1.getDisplayName(), localPlayer2.getDisplayName() + " is no longer slowed by " + localPlayer1.getDisplayName(), localHero1)); if (l3 > 0L) localHero2.addEffect(new RootEffect(this.skill, l3)); if (l4 > 0L) localHero2.addEffect(new SilenceEffect(this.skill, l4)); if (j > 0) this.skill.damageEntity( localLivingEntity, localPlayer1, j, EntityDamageEvent.DamageCause.MAGIC); } if (j > 0) this.skill.damageEntity( localLivingEntity, localPlayer1, j, EntityDamageEvent.DamageCause.MAGIC); } Heroes.debug.stopTask("HeroesSkillListener"); }
/** * In this entity-damage-listener we will cancel fall damage and suffocation damage for vampires. * We will also modify the damage dealt. */ @EventHandler(priority = EventPriority.HIGH) public void onEntityDamageHigh(EntityDamageEvent event) { if (event.isCancelled()) return; // Define local fields Entity damagee; Player pDamagee; VPlayer vpDamagee; EntityDamageByEntityEvent edbeEvent; Entity damager; Player pDamager; VPlayer vpDamager; damagee = event.getEntity(); // If the damagee is a player if (damagee instanceof Player) { pDamagee = (Player) damagee; vpDamagee = VPlayers.i.get(pDamagee); // Vampires can not drown or take fall damage or starve if (vpDamagee.isVampire() && Conf.vampiresCantTakeDamageFrom.contains(event.getCause())) { event.setCancelled(true); return; } } // For further interest this must be a close combat attack by another entity if (event.getCause() != DamageCause.ENTITY_ATTACK) return; if (!(event instanceof EntityDamageByEntityEvent)) return; edbeEvent = (EntityDamageByEntityEvent) event; damager = edbeEvent.getDamager(); // For further interest that attacker must be a player. if (!(damager instanceof Player)) return; pDamager = (Player) damager; vpDamager = VPlayers.i.get(pDamager); // The damage will be modified under certain circumstances. float damage = event.getDamage(); // Modify damage if damager is a vampire if (vpDamager.isVampire()) { damage *= vpDamager.getDamageDealtFactor(); } // Modify damage if damagee is a vampire if (damagee instanceof Player) { pDamagee = (Player) damagee; vpDamagee = VPlayers.i.get(pDamagee); if (vpDamagee.isVampire()) { Material itemMaterial = pDamager.getItemInHand().getType(); if (Conf.woodMaterials.contains(itemMaterial)) { damage = Conf.damageReceivedWood; // Just as much as a diamond sword. vpDamagee.msg(Lang.messageWoodCombatWarning, Txt.getMaterialName(itemMaterial)); } else { damage *= vpDamagee.getDamageReceivedFactor(); } } } event.setDamage(Math.round(damage)); }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerDamage(EntityDamageEvent event) { if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); BendingPlayer bender = BendingPlayer.getBendingPlayer(player); String ability = bender.getAbility(); if (event.getCause() == DamageCause.FALL) { BendingPassiveAbility ab = null; if (bender != null && bender.isBender(BendingElement.EARTH)) { ab = new EarthPassive( AbilityManager.getManager().getRegisteredAbility(EarthPassive.NAME), player); if (ab.start()) { AbilityManager.getManager().addInstance(ab); player.setFallDistance(0); event.setDamage(0); event.setCancelled(true); return; } if (MetalWire.hasNoFallDamage(player)) { player.setFallDistance(0); event.setDamage(0); event.setCancelled(true); return; } } if (bender != null && bender.isBender(BendingElement.AIR) && EntityTools.canBendPassive(player, BendingElement.AIR)) { if (AirBurst.NAME.equals(ability)) { BendingActiveAbility burst = AbilityManager.getManager().buildAbility(AirBurst.NAME, player); if (burst.canBeInitialized()) { burst.fall(); if (burst.getState() != BendingAbilityState.START && burst.getState() != BendingAbilityState.ENDED) { AbilityManager.getManager().addInstance(burst); } } } player.setFallDistance(0); event.setDamage(0); event.setCancelled(true); return; } if (!event.isCancelled() && EntityTools.isBender(player, BendingElement.WATER)) { ab = new WaterPassive( AbilityManager.getManager().getRegisteredAbility(WaterPassive.NAME), player); AbilityManager.getManager().addInstance(ab); if (ab.start()) { player.setFallDistance(0); event.setDamage(0); event.setCancelled(true); return; } } if (!event.isCancelled() && bender.isBender(BendingElement.MASTER) && EntityTools.canBendPassive(player, BendingElement.MASTER)) { event.setDamage((int) (event.getDamage() * (Settings.MASTER_FALL_REDUCTION / 100.))); if (event.getEntity().getFallDistance() < 10) { event.setCancelled(true); return; } } if (!event.isCancelled() && EntityTools.isFallImmune(player)) { event.setCancelled(true); return; } } if (EntityTools.canBendPassive(player, BendingElement.FIRE) && EntityTools.isBender(player, BendingElement.FIRE) && ((event.getCause() == DamageCause.FIRE) || (event.getCause() == DamageCause.FIRE_TICK))) { event.setCancelled(!Enflamed.canBurn(player)); } if (EntityTools.isBender(player, BendingElement.EARTH) && ((event.getCause() == DamageCause.SUFFOCATION) && TempBlock.isTempBlock(player.getEyeLocation().getBlock()))) { event.setDamage(0); event.setCancelled(true); } if (bender != null) { Map<Object, BendingAbility> instances = AbilityManager.getManager().getInstances(AvatarShield.NAME); if (instances.containsKey(player)) { AvatarShield ab = (AvatarShield) instances.get(player); if (ab.hit()) { event.setCancelled(true); } } } } }
/** Damage * */ @EventHandler public void onDamage(EntityDamageEvent e) { if (e.getEntity() instanceof Player) e.setCancelled(true); e.setDamage(0D); }