org.bukkit.event.entity.EntityDamageByEntityEvent Java Examples
The following examples show how to use
org.bukkit.event.entity.EntityDamageByEntityEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 7 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onItemFrameDamage(final EntityDamageByEntityEvent e) { // Check world if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) { return; } if (e.getDamager() instanceof Projectile) { if (DEBUG) plugin.getLogger().info("DEBUG: Projectile damage to itemframe"); // Find out who fired the arrow Projectile p = (Projectile) e.getDamager(); if (DEBUG) plugin.getLogger().info("DEBUG: Shooter is " + p.getShooter().toString()); if (p.getShooter() instanceof Skeleton || p.getShooter() instanceof Golem) { if (DEBUG) plugin.getLogger().info("DEBUG: Shooter is mob"); if (!Settings.allowMobDamageToItemFrames) { if (DEBUG) plugin.getLogger().info("DEBUG: Damage not allowed, cancelling"); e.setCancelled(true); } } } }
Example #2
Source File: BountyHunter.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void effect(Event e, ItemStack item, final int level) { if(e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; Entity target = event.getEntity(); if(!(target instanceof Player)) return; Player p = (Player) ((Projectile) event.getDamager()).getShooter(); Material bountyDrop = getBounty(); for(int i = 10; i>0; i--) { p.getWorld().playEffect(p.getLocation(), Effect.COLOURED_DUST, 10); p.getWorld().playEffect(target.getLocation(), Effect.COLOURED_DUST, 10); } p.getInventory().addItem(new ItemStack(bountyDrop, Tools.random.nextInt(MaximumBounty+level)+1)); p.sendMessage(ChatColor.GOLD + "You have collected a bounty on " + target.getName() + "!"); this.generateCooldown(p, Cooldown); } }
Example #3
Source File: Attack.java From civcraft with GNU General Public License v2.0 | 6 votes |
@Override public void onAttack(EntityDamageByEntityEvent event, ItemStack inHand) { AttributeUtil attrs = new AttributeUtil(inHand); double dmg = this.getDouble("value"); double extraAtt = 0.0; for (LoreEnhancement enh : attrs.getEnhancements()) { if (enh instanceof LoreEnhancementAttack) { extraAtt += ((LoreEnhancementAttack)enh).getExtraAttack(attrs); } } dmg += extraAtt; if (event.getDamager() instanceof Player) { Resident resident = CivGlobal.getResident(((Player)event.getDamager())); if (!resident.hasTechForItem(inHand)) { dmg = dmg / 2; } } if (dmg < 0.5) { dmg = 0.5; } event.setDamage(dmg); }
Example #4
Source File: Areas.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST,ignoreCancelled = true) public void checkBreaks(EntityDamageByEntityEvent e) { if(e.getDamager().getType() == EntityType.PLAYER && e.getEntity().getType() == EntityType.PLAYER) { Area a = this.getArea(new Loc(e.getDamager().getLocation(),false)); if(a != null && !a.getAllowPVP()) { e.setCancelled(true); return; } a = this.getArea(new Loc(e.getEntity().getLocation(),false)); if(a != null && !a.getAllowPVP()) { e.setCancelled(true); return; } } }
Example #5
Source File: EntityListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamageByEntity(EntityDamageByEntityEvent ede) { List<EntityType> canDamageTypes = new ArrayList<EntityType>(); canDamageTypes.add(EntityType.PLAYER); if (BedwarsRel.getInstance().getServer().getPluginManager().isPluginEnabled("AntiAura") || BedwarsRel.getInstance().getServer().getPluginManager().isPluginEnabled("AAC")) { canDamageTypes.add(EntityType.SQUID); } if (canDamageTypes.contains(ede.getEntityType())) { return; } Game game = BedwarsRel.getInstance().getGameManager().getGameByLocation(ede.getEntity().getLocation()); if (game == null) { return; } if (game.getState() == GameState.STOPPED) { return; } ede.setCancelled(true); }
Example #6
Source File: CEventHandler.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
public static void handleBows(Player toCheck, EntityDamageByEntityEvent e) { if (e.getDamager().hasMetadata("ce.bow.item")) { Tools.getItemByOriginalname(e.getDamager().getMetadata("ce.bow.item").get(0).asString()).effect(e, toCheck); e.getDamager().removeMetadata("ce.bow.item", Main.plugin); } if (e.getDamager().hasMetadata("ce.bow.enchantment")) { String[] enchantments = e.getDamager().getMetadata("ce.bow.enchantment").get(0).asString().split(" ; "); for (String ench : enchantments) { String[] enchantment = ench.split(" : "); CEnchantment ce = EnchantManager.getInternalEnchantment(enchantment[0]); ce.effect(e, toCheck.getItemInHand(), Integer.parseInt(enchantment[1])); } e.getDamager().removeMetadata("ce.bow.enchantment", Main.plugin); } }
Example #7
Source File: ProjectileMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler public void onProjectileHurtEvent(EntityDamageByEntityEvent event) { if (!(event.getEntity() instanceof LivingEntity)) return; LivingEntity damagedEntity = (LivingEntity) event.getEntity(); ProjectileDefinition projectileDefinition = ProjectileMatchModule.getProjectileDefinition(event.getDamager()); if (projectileDefinition != null) { if (!projectileDefinition.potion.isEmpty()) { damagedEntity.addPotionEffects(projectileDefinition.potion); } if (projectileDefinition.damage != null) { event.setDamage(projectileDefinition.damage); } } }
Example #8
Source File: NoEntryListener.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority=EventPriority.HIGHEST) public void onCancelPVP(EntityDamageByEntityEvent e) { if(!e.isCancelled()) return; if(this.expansion.getNoEntryHandler().getNoEntryMode() != NoEntryMode.VULNERABLE) return; Entity entity = e.getEntity(); if(!(entity instanceof Player)) return; ICombatLogX plugin = this.expansion.getPlugin(); ICombatManager manager = plugin.getCombatManager(); Player player = (Player) entity; if(!manager.isInCombat(player)) return; LivingEntity enemy = manager.getEnemy(player); if(enemy == null) return; e.setCancelled(false); this.expansion.sendNoEntryMessage(player, enemy); }
Example #9
Source File: EventFilterMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDamage(final EntityDamageEvent event) { cancelUnlessInteracting(event, event.getEntity()); if (event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event; if (cancelUnlessInteracting(event, entityEvent.getDamager())) { MatchPlayer player = match.getPlayer(entityEvent.getDamager()); if (player == null) return; match.callEvent( new ObserverInteractEvent( player, ClickType.LEFT, null, event.getEntity(), player.getInventory().getItemInHand())); } } }
Example #10
Source File: PreventEndermanHeightExploit.java From EliteMobs with GNU General Public License v3.0 | 6 votes |
@EventHandler (priority = EventPriority.HIGHEST) public void onDamage(EntityDamageByEntityEvent event){ if (event.isCancelled()) return; if (!event.getEntity().getType().equals(EntityType.ENDERMAN)) return; EntityType entityType = EntityFinder.getRealDamager(event).getType(); if (entityType == null) return; if (!entityType.equals(EntityType.PLAYER)) return; EliteMobEntity eliteMobEntity = EntityTracker.getEliteMobEntity(event.getEntity()); if (eliteMobEntity == null) return; Block block = EntityFinder.getRealDamager(event).getLocation().getBlock().getLocation().add(new Vector(0, 2, 0)).getBlock(); if (block.getType().equals(Material.AIR) || block.getType().equals(Material.WATER)) return; eliteMobEntity.setHasSpecialLoot(false); AntiExploitMessage.sendWarning((LivingEntity) event.getEntity()); }
Example #11
Source File: HealingShovel.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean effect(Event event, Player player) { EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; if (e.getDamager() == player && e.getEntity() instanceof Player) { Player damaged = (Player) e.getEntity(); e.setDamage(0); EffectManager.playSound(damaged.getLocation(), "ENTITY_GENERIC_DRINK", 0.5f, 1f); EffectManager.playSound(damaged.getLocation(), "BLOCK_ANVIL_LAND", 0.5f, 2f); short currentDur = player.getItemInHand().getDurability(); if (((Damageable) damaged).getHealth() + Heal <= ((Damageable) damaged).getMaxHealth()) { damaged.setHealth(((Damageable) damaged).getHealth() + Heal); } else { damaged.setHealth(((Damageable) damaged).getMaxHealth()); } if (currentDur + Heal < player.getItemInHand().getType().getMaxDurability()) { player.getItemInHand().setDurability((short) (currentDur + Heal)); } else { player.setItemInHand(new ItemStack(Material.AIR, 1)); EffectManager.playSound(player.getLocation(), "ENTITY_ITEM_BREAK", 0.1f, 0.3f); } return true; } return false; }
Example #12
Source File: ObserverModule.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onEntityAttack(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player) { if (testObserverOrDead((Player) event.getDamager())) { event.setCancelled(true); } } }
Example #13
Source File: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
private void cancelMobDamage(EntityDamageByEntityEvent event) { if (killAnimalsEnabled && event.getEntity() instanceof Animals) { event.setCancelled(true); } else if (killMonstersEnabled && event.getEntity() instanceof Monster) { event.setCancelled(true); } }
Example #14
Source File: EntityListener.java From Guilds with MIT License | 5 votes |
/** * Guild / Ally damage handlers * * @param event handles when damage is done between two players that might be in the same guild or are allies */ @EventHandler public void onEntityDamage(EntityDamageByEntityEvent event) { if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player)) return; Player player = (Player) event.getEntity(); Player damager = (Player) event.getDamager(); // Make sure that they aren't in a claim that turns off pvpv if (settingsManager.getProperty(GuildSettings.RESPECT_WG_PVP_FLAG)) { event.setCancelled(ClaimUtils.checkPvpDisabled(player)); return; } // Check if they are the same guild if (guildHandler.isSameGuild(player, damager)) { event.setCancelled(!settingsManager.getProperty(GuildSettings.GUILD_DAMAGE)); return; } // Get the challenge object GuildChallenge challenge = challengeHandler.getChallenge(player); // Check if they are in a challenge if (challenge != null) { // Check if the challenge has started if (challenge.isStarted()) { // Cancel the rest of the checks in case they are battling allies return; } } if (guildHandler.isAlly(player, damager)) { event.setCancelled(!settingsManager.getProperty(GuildSettings.ALLY_DAMAGE)); } }
Example #15
Source File: AttackBlinding.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void attackBlinding(EntityDamageByEntityEvent event) { EliteMobEntity eliteMobEntity = EventValidator.getEventEliteMob(this, event); if (eliteMobEntity == null) return; Player player = EntityFinder.findPlayer(event); if (PowerCooldown.isInCooldown(eliteMobEntity, cooldownList)) return; player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 5, 3)); PowerCooldown.startCooldownTimer(eliteMobEntity, cooldownList, 10 * 20); }
Example #16
Source File: LobbyListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = false) public void onEntityDamage(final EntityDamageByEntityEvent e) { if (SkyWarsReloaded.getCfg().protectLobby() && Util.get().isSpawnWorld(e.getEntity().getWorld())) { e.setCancelled(true); if (e.getEntity() instanceof Player || e.getDamager() instanceof Player) { if (((Player)e.getDamager()).hasPermission("sw.alterlobby")) { e.setCancelled(false); } } } }
Example #17
Source File: FireworksListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onResearchFireworkDamage(EntityDamageByEntityEvent e) { if (e.getDamager().getType() == EntityType.FIREWORK) { Firework firework = (Firework) e.getDamager(); FireworkMeta meta = firework.getFireworkMeta(); if (meta.hasDisplayName() && meta.getDisplayName().equals(ChatColor.GREEN + "Slimefun Research")) { e.setCancelled(true); } } }
Example #18
Source File: Defense.java From civcraft with GNU General Public License v2.0 | 5 votes |
@Override public void onDefense(EntityDamageByEntityEvent event, ItemStack stack) { double defValue = this.getDouble("value"); /* Try to get any extra defense enhancements from this item. */ LoreCraftableMaterial craftMat = LoreCraftableMaterial.getCraftMaterial(stack); if (craftMat == null) { return; } double extraDef = 0; AttributeUtil attrs = new AttributeUtil(stack); for (LoreEnhancement enh : attrs.getEnhancements()) { if (enh instanceof LoreEnhancementDefense) { extraDef += ((LoreEnhancementDefense)enh).getExtraDefense(attrs); } } defValue += extraDef; double damage = event.getDamage(); if (event.getEntity() instanceof Player) { Resident resident = CivGlobal.getResident(((Player)event.getEntity())); if (!resident.hasTechForItem(stack)) { defValue = defValue / 2; } } damage -= defValue; if (damage < 0.5) { /* Always do at least 0.5 damage. */ damage = 0.5; } event.setDamage(damage); }
Example #19
Source File: Revulsion.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getDamager(); target.addPotionEffect( new PotionEffect( PotionEffectType.CONFUSION, duration * level, //This value is counted in ticks, 1/20 of a second 0)); }
Example #20
Source File: AttackConfusing.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void attackConfusing(EntityDamageByEntityEvent event) { EliteMobEntity eliteMobEntity = EventValidator.getEventEliteMob(this, event); if (eliteMobEntity == null) return; Player player = EntityFinder.findPlayer(event); if (PowerCooldown.isInCooldown(eliteMobEntity, cooldowns)) return; player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 3)); PowerCooldown.startCooldownTimer(eliteMobEntity, cooldowns, 10 * 20); }
Example #21
Source File: SpellListener.java From Civs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onListenerProjectile(EntityDamageByEntityEvent event) { AbilityListen abilityListener; if (projectileListeners.containsKey(event.getDamager())) { abilityListener = projectileListeners.get(event.getDamager()); } else { return; } if (abilityListener.spell.useAbilityFromListener(abilityListener.getCaster(), abilityListener.getLevel(), abilityListener.getConfig(), event.getEntity())) { event.setCancelled(true); } }
Example #22
Source File: IslandGuard1_8.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void ArmorStandDestroy(EntityDamageByEntityEvent e) { if (DEBUG) { plugin.getLogger().info("1.8 " + "IslandGuard New " + e.getEventName()); } if (!(e.getEntity() instanceof LivingEntity)) { return; } if (!IslandGuard.inWorld(e.getEntity())) { return; } final LivingEntity livingEntity = (LivingEntity) e.getEntity(); if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) { return; } if (e.getDamager() instanceof Player) { Player p = (Player) e.getDamager(); if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { return; } // Check if on island if (plugin.getGrid().playerIsOnIsland(p)) { return; } // Check island Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation()); if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) { return; } if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) { return; } Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected); e.setCancelled(true); } }
Example #23
Source File: DealtDamageEvent.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onDamageDealt(EntityDamageByEntityEvent event) { if(event.getEntity() instanceof Player){ if(StackTools.hasSizeMoreThanOne(event.getDamager())){ int stackSize = StackTools.getSize(event.getDamager()); double extraDamage = event.getDamage() + ((event.getDamage() * (stackSize - 1)) * 0.2); event.setDamage(extraDamage); } } }
Example #24
Source File: ChickenGizmo.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void entityDamage(final EntityDamageEvent event) { if(!(event instanceof EntityDamageByEntityEvent)) return; EntityDamageByEntityEvent realEvent = (EntityDamageByEntityEvent) event; if(!(realEvent.getDamager() instanceof Player) || !(realEvent.getEntity() instanceof Player)) return; final Player damager = (Player) realEvent.getDamager(); final Player victim = (Player) realEvent.getEntity(); if(victim.hasPermission(GizmoConfig.EXEMPT_PERMISSION)) return; if(!(Gizmos.gizmoMap.get(damager) instanceof ChickenGizmo)) return; if(damager.getItemInHand().getType() != this.getIcon()) return; final Chicken chicken = chickens.computeIfAbsent(victim, Chicken::new); if(!chicken.add(damager)) return; chickendCount.compute(victim, (player, count) -> { count = count == null ? 0 : count + 1; if(count > 0 && count % 10 == 0) { RaindropUtil.giveRaindrops( Users.playerId(damager), 1, null, new TranslatableComponent("gizmo.chicken.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD)) ); } return count; }); event.setCancelled(true); }
Example #25
Source File: KnockbackPlayerFacet.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@TargetedEventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMelee(EntityDamageByEntityEvent event) { if(knockback.isPresent() && victim.equals(event.getEntity()) && event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK && event.getDamager() instanceof LivingEntity && victim.getNoDamageTicks() <= 0) { applyImpulses((LivingEntity) event.getDamager()); } }
Example #26
Source File: Cripple.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; LivingEntity target = (LivingEntity) event.getEntity(); if(!target.hasPotionEffect(PotionEffectType.CONFUSION)) { EffectManager.playSound(target.getLocation(), "ENTITY_PLAYER_HURT", 1f, 0.4f); EffectManager.playSound(target.getLocation(), "BLOCK_ANVIL_LAND", 0.1f, 2f); target.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration * level, 0)); target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration * level, strength + level)); } }
Example #27
Source File: Assassin.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageByEntityEvent event) { if(event.getDamager().getType() == EntityType.PLAYER) { Player player = (Player)event.getDamager(); AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null && p.getKit().equals(this) && p.getData("Cur") != null) endLeap(player,p); } }
Example #28
Source File: EventResolver.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
default DamageInfo resolveDamage(EntityDamageEvent damageEvent) { if(damageEvent instanceof EntityDamageByEntityEvent) { return resolveDamage((EntityDamageByEntityEvent) damageEvent); } else if(damageEvent instanceof EntityDamageByBlockEvent) { return resolveDamage((EntityDamageByBlockEvent) damageEvent); } else { return resolveDamage(damageEvent.getCause(), damageEvent.getEntity()); } }
Example #29
Source File: VisualEffectObfuscator.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onDamageByPlayer(EntityDamageByEntityEvent event) { if (!(EntityFinder.getRealDamager(event) instanceof Player)) return; EliteMobEntity eliteMobEntity = EntityTracker.getEliteMobEntity(event.getEntity()); if (eliteMobEntity == null) return; eliteMobEntity.setHasVisualEffectObfuscated(false); eliteMobEntity.getLivingEntity().setCustomNameVisible(true); }
Example #30
Source File: Aerial.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; Player player = (Player) event.getDamager(); if(player.getVelocity().getY() == -0.0784000015258789) //Constant velocity for not moving in y direction (Gravity) return; event.setDamage(event.getDamage() * (1 + DamageIncreasePercentage * level)); EffectManager.playSound(player.getLocation(), "ENTITY_BAT_TAKEOFF", 0.1f, 0.1f); }