/** * Runs an EntityDamageEvent and updates {@link org.bukkit.entity.Entity#setLastDamageCause} and * (for a {@link LivingEntity} only) {@link LivingEntity#setLastDamage(double)}. * * @param event the event to run * @param <T> the event's type * @return the completed event */ public <T extends EntityDamageEvent> T onEntityDamage(T event) { T result = callEvent(event); if (!result.isCancelled()) { result.getEntity().setLastDamageCause(result); if (result.getEntity() instanceof LivingEntity) { ((LivingEntity) result.getEntity()).setLastDamage(result.getDamage()); } } return result; }
@Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; if (sender instanceof Player) { Player player = (Player) sender; EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000); Bukkit.getPluginManager().callEvent(ede); if (ede.isCancelled()) return true; ede.getEntity().setLastDamageCause(ede); player.setHealth(0); sender.sendMessage("Ouch. That look like it hurt."); } else { sender.sendMessage("You can only perform this command as a player"); } return true; }
@Override public void setLastDamageCause(EntityDamageEvent arg0) { base.setLastDamageCause(arg0); }
public void setLastDamageCause(EntityDamageEvent arg0) { entity.setLastDamageCause(arg0); }
@Override public void setLastDamageCause(MCEntityDamageEvent event) { e.setLastDamageCause((EntityDamageEvent) event._GetObject()); }
@Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; if (sender instanceof Player) { Player player = (Player) sender; EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000); Bukkit.getPluginManager().callEvent(ede); if (ede.isCancelled()) return true; ede.getEntity().setLastDamageCause(ede); player.setHealth(0); sender.sendMessage("Ouch. That look like it hurt."); } else { sender.sendMessage("You can only perform this command as a player"); } return true; }
((LivingEntity) entity).damage(damage, source); final double nextHealth = ((LivingEntity) entity).getHealth(); entity.setLastDamageCause(finalEvent); if (ignoreArmor) { if (finalEvent.isApplicable(DamageModifier.ARMOR)) {