Java Code Examples for org.bukkit.event.entity.EntityDamageByEntityEvent#getCause()
The following examples show how to use
org.bukkit.event.entity.EntityDamageByEntityEvent#getCause() .
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: QAListener.java From QualityArmory with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") @EventHandler public void onHit(EntityDamageByEntityEvent e) { if (e.isCancelled()) return; if (e.getDamager() instanceof Player) { Player d = (Player) e.getDamager(); if ((e.getCause() == DamageCause.ENTITY_ATTACK || e.getCause() == DamageCause.ENTITY_SWEEP_ATTACK)) { if (QualityArmory.isMisc(d.getItemInHand())) { CustomBaseObject aa = QualityArmory.getMisc(d.getItemInHand()); if (aa instanceof MeleeItems) { DEBUG("Setting damage for " + aa.getName() + " to be equal to " + ((MeleeItems) aa).getDamage() + ". was " + e.getDamage()); e.setDamage(((MeleeItems) aa).getDamage()); } if (aa.getSoundOnHit() != null) { e.getEntity().getWorld().playSound(e.getEntity().getLocation(), aa.getSoundOnHit(), 1, 1); } } } if (QualityArmory.isGun(d.getItemInHand()) || QualityArmory.isIronSights(d.getItemInHand())) DEBUG("The player " + e.getEntity().getName() + " was Hit with a gun! Damage=" + e.getDamage()); } }
Example 2
Source File: FriendlyFireRefundMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.NORMAL) public void onHit(EntityDamageByEntityEvent event) { final Entity damager = event.getDamager(); if (!event.isCancelled() || event.getCause() != EntityDamageEvent.DamageCause.PROJECTILE || !(damager instanceof Projectile) || !damager.hasMetadata(METADATA_KEY)) return; final Player shooter = (Player) ((Projectile) damager).getShooter(); if (match.getParticipant(shooter) == null) return; damager.remove(); shooter.getInventory().addItem(new ItemStack(Material.ARROW)); }
Example 3
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 4
Source File: HitPattern.java From AACAdditionPro with GNU General Public License v3.0 | 5 votes |
@Override protected int process(User user, EntityDamageByEntityEvent event) { // Is in Inventory (Detection) if (user.hasOpenInventory() && // Have the inventory opened for some time user.notRecentlyOpenedInventory(1000) && // Is a hit-attack event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) { message = "Inventory-Verbose | Player: " + user.getPlayer().getName() + " hit an entity while having an open inventory."; return 10; } return 0; }
Example 5
Source File: SlimefunBowListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onArrowSuccessfulHit(EntityDamageByEntityEvent e) { if (e.getDamager() instanceof Arrow && e.getEntity() instanceof LivingEntity && e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) { SlimefunBow bow = projectiles.get(e.getDamager().getUniqueId()); if (bow != null) { bow.callItemHandler(BowShootHandler.class, handler -> handler.onHit(e, (LivingEntity) e.getEntity())); } projectiles.remove(e.getDamager().getUniqueId()); } }
Example 6
Source File: FireworkListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onDamage(final EntityDamageByEntityEvent e) { if (e.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION && e.getDamager().getType() == EntityType.FIREWORK) { e.setCancelled(true); } }