@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onVehicleDamageEvent(VehicleDamageEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info(e.getAttacker().getType().toString()); } if (Util.inWorld(e.getVehicle())) { if (!(e.getAttacker() instanceof Player)) { return; } Player p = (Player) e.getAttacker(); if (actionAllowed(p, e.getVehicle().getLocation(), SettingsFlag.BREAK_BLOCKS)) { return; } // Not allowed Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected")); e.setCancelled(true); } }
private static Object getAttacker(final Event e) { if (e instanceof EntityDamageByEntityEvent) { if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) { return ((Projectile) ((EntityDamageByEntityEvent) e).getDamager()).getShooter(); } return ((EntityDamageByEntityEvent) e).getDamager(); } else if (e instanceof EntityDamageByBlockEvent) { return ((EntityDamageByBlockEvent) e).getDamager(); } else if (e instanceof EntityDeathEvent) { return getAttacker(((EntityDeathEvent) e).getEntity().getLastDamageCause()); } else if (e instanceof VehicleDamageEvent) { return ((VehicleDamageEvent) e).getAttacker(); } else if (e instanceof VehicleDestroyEvent) { return ((VehicleDestroyEvent) e).getAttacker(); } return null; }
@Nullable private static Entity getAttacker(final @Nullable Event e) { if (e == null) return null; if (e instanceof EntityDamageByEntityEvent) { if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) { final Object o = ProjectileUtils.getShooter((Projectile) ((EntityDamageByEntityEvent) e).getDamager()); if (o instanceof Entity) return (Entity) o; return null; } return ((EntityDamageByEntityEvent) e).getDamager(); // } else if (e instanceof EntityDamageByBlockEvent) { // return ((EntityDamageByBlockEvent) e).getDamager(); } else if (e instanceof EntityDeathEvent) { return getAttacker(((EntityDeathEvent) e).getEntity().getLastDamageCause()); } else if (e instanceof VehicleDamageEvent) { return ((VehicleDamageEvent) e).getAttacker(); } else if (e instanceof VehicleDestroyEvent) { return ((VehicleDestroyEvent) e).getAttacker(); } return null; }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { EntityProtection entityProtection = this.module.getProtectManager().getEntityProtection(event.getVehicle().getType(), event.getVehicle().getUniqueId()); if(entityProtection.exists()) { if(event.getAttacker() instanceof Player) { Player player = (Player) event.getAttacker(); if(entityProtection.getOwner().equals(player.getUniqueId()) || player.hasPermission(ProtectPermissions.MODIFY_ALL)) { return; } sendMessage(player, "protect.entity-protected-by", getDisplayName(this.module.getManager().getUsername(entityProtection.getOwner()), event.getVehicle().getWorld().getName())); } event.setCancelled(true); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onVehicleDamageEvent(VehicleDamageEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info(e.getAttacker().getType().toString()); } if (inWorld(e.getVehicle())) { if (!(e.getAttacker() instanceof Player)) { return; } Player p = (Player) e.getAttacker(); if (actionAllowed(p, e.getVehicle().getLocation(), SettingsFlag.BREAK_BLOCKS)) { return; } // Not allowed Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected); e.setCancelled(true); } }
@EventHandler public void onVehicleDamage(final VehicleDamageEvent event) { debug("VehicleDamageEvent triggered!"); if (event.getAttacker() == null) { // If the attacker is unknown atleast check if the damaged entity is protected and cancel event Optional<EntityProtection> prot = this.module.cache.getByUniqueId(event.getVehicle().getUniqueId()); if (prot.isPresent()) { event.setCancelled(true); debug("onVehicleDamage("+event.getVehicle().getType()+")", "Cancelled event because entity is protected and damager unknown!"); } return; } final Entity damager = Utility.getRealDamager(event.getAttacker()); if (!(damager instanceof Player)) { return; } debug("Determined real damager: " + damager.getName()); if (!this.canInteract(event.getVehicle(), (Player)damager)) { event.setCancelled(true); } }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { if (event.getAttacker() != null && event.getAttacker() instanceof Player) { if (isSpectating((Player) event.getAttacker())) { event.setCancelled(true); } } }
@EventHandler(ignoreCancelled = true) public void onDamageVehicle(VehicleDamageEvent event) { MatchPlayer victim = getVictim(event.getVehicle()); if(victim == null) return; processDamageEvent(event, victim.getParticipantState(), damageResolver.resolveDamage(EntityDamageEvent.DamageCause.CUSTOM, event.getVehicle(), event.getAttacker())); }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { if (event.getAttacker() instanceof Player) { Player player = (Player) event.getAttacker(); if (isPlayerSpectator(player)) { event.setCancelled(true); } } }
@SuppressWarnings("unchecked") @Override public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) { if (!ScriptLoader.isCurrentEvent(EntityDamageByEntityEvent.class, EntityDeathEvent.class, VehicleDamageEvent.class, VehicleDestroyEvent.class)) { Skript.error("Cannot use 'attacker' outside of a damage/death/destroy event", ErrorQuality.SEMANTIC_ERROR); return false; } return true; }
/** * Prevents a player that can't interact from damaging vehicles. * * @param event The event. */ @EventHandler(ignoreCancelled = true) public void onVehicleDamage(VehicleDamageEvent event) { if (event.getActor() instanceof Player && !canInteract((Player) event.getActor())) { event.setCancelled(true); } }
/** * Prevents damaging vehicles outside of the game area * @param event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onVehicleDamage(final VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player)) { return; } Player player = (Player)event.getAttacker(); if (player.getWorld().equals(getBeaconzWorld())) { if (getGameMgr().getGame(event.getVehicle().getLocation()) == null) { event.setCancelled(true); player.sendMessage(ChatColor.RED + Lang.errorYouCannotDoThat); } } }
@EventHandler public void on(VehicleDamageEvent e) { if (breakVehicleEnabled || !(e.getAttacker() instanceof Player)) { return; } Player player = (Player) e.getAttacker(); if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) { return; } e.setCancelled(true); player.sendMessage(tr("\u00a7eYou cannot break vehicles while being a visitor!")); }
/** * @param e * This event check throws the boat at a player when they hit it * unless someone is in it */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onClick(VehicleDamageEvent e) { // plugin.getLogger().info("Damage event " + e.getDamage()); // Find out what block is being clicked Vehicle boat = e.getVehicle(); if (!(boat instanceof Boat)) { return; } if (!boat.isEmpty()) { return; } final World playerWorld = boat.getWorld(); if (!playerWorld.getName().equalsIgnoreCase(Settings.worldName)) { // Not the right world return; } // plugin.getLogger().info("Boat "); // Find out who is doing the clicking if (!(e.getAttacker() instanceof Player)) { // If a creeper blows up the boat, tough cookies! return; } Player p = (Player) e.getAttacker(); if (p == null) { return; } // Try to remove the boat and throw it at the player Location boatSpot = new Location(boat.getWorld(), boat.getLocation().getX(), boat.getLocation().getY() + 2, boat.getLocation().getZ()); Location throwTo = new Location(boat.getWorld(), p.getLocation().getX(), p.getLocation().getY() + 1, p.getLocation().getZ()); ItemStack newBoat = new ItemStack(Material.BOAT, 1); // Find the direction the boat should move in Vector dir = throwTo.toVector().subtract(boatSpot.toVector()).normalize(); dir = dir.multiply(0.5); Entity newB = boat.getWorld().dropItem(boatSpot, newBoat); newB.setVelocity(dir); boat.remove(); e.setCancelled(true); }
@EventHandler public void onVehicleDamage(VehicleDamageEvent e) { if (e.getAttacker() instanceof Player) { Player player = (Player) e.getAttacker(); User u = Necessities.getUM().getUser(player.getUniqueId()); YamlConfiguration config = Necessities.getInstance().getConfig(); if (config.contains("Necessities.Guilds") && config.getBoolean("Necessities.Guilds") && !player.hasPermission("Necessities.guilds.admin")) { Guild g = Necessities.getGM().chunkOwner(e.getVehicle().getLocation().getChunk()); if (g != null && u.getGuild() != g) e.setCancelled(true); } } }
@EventHandler public void VehicleDamage(final VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player)) return; final Player player = (Player) event.getAttacker(); if (plugin.isLoggedIn(player)) return; event.setCancelled(true); plugin.sendAuthReminderMessage(player); }
/** * Stops players trying to break entities such as Minecarts, Boats, etc. */ @EventHandler (priority = EventPriority.HIGHEST) public void onVehicleDamage(final VehicleDamageEvent e) { if (e.getAttacker() instanceof Player && p.getPlayerData((Player) e.getAttacker()).isSpectating()) { e.setCancelled(true); } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onVehicleDamage(final VehicleDamageEvent event) { cancelUnlessInteracting(event, event.getAttacker()); }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDamage(final VehicleDamageEvent event) { if(freeze.isFrozen(event.getAttacker())) { event.setCancelled(true); } }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { forbidIfInProtectedTerritory(getDamageSource(event.getAttacker()), event.getVehicle(), event, ATTACK); }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { if (event.getAttacker() instanceof Player && isObserver((Player) event.getAttacker())) { event.setCancelled(true); } }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { if (event.getAttacker() instanceof Player) { this.manager.invoke((Player) event.getAttacker(), event); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDamage(VehicleDamageEvent event) { if (this.isObserving(event.getAttacker())) { event.setCancelled(true); } }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { if (!match.isRunning() || event.getAttacker() instanceof Player && TeamUtils.getTeamByPlayer((Player) event.getAttacker()).isObserver()) { event.setCancelled(true); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onVehicleDamage (VehicleDamageEvent event) { //all of this is anti theft code if(!GriefPrevention.instance.config_claims_preventTheft) return; //don't track in worlds where claims are not enabled if(!GriefPrevention.instance.claimsEnabledForWorld(event.getVehicle().getWorld())) return; //determine which player is attacking, if any Player attacker = null; Entity damageSource = event.getAttacker(); if(damageSource.getType() == EntityType.PLAYER) { attacker = (Player)damageSource; } else if(damageSource instanceof Projectile) { Projectile arrow = (Projectile)damageSource; if(arrow.getShooter() instanceof Player) { attacker = (Player)arrow.getShooter(); } } //if not a player and not an explosion, always allow if(attacker == null && !(damageSource instanceof Explosive)) { return; } //NOTE: vehicles can be pushed around. //so unless precautions are taken by the owner, a resourceful thief might find ways to steal anyway Claim cachedClaim = null; PlayerData playerData = null; if(attacker != null) { playerData = this.dataStore.getPlayerData(attacker.getUniqueId()); cachedClaim = playerData.lastClaim; } Claim claim = this.dataStore.getClaimAt(event.getVehicle().getLocation(), false, cachedClaim); //if it's claimed if(claim != null) { //if damaged by anything other than a player, cancel the event if(attacker == null) { event.setCancelled(true); } //otherwise the player damaging the entity must have permission else { String noContainersReason = claim.allowContainers(attacker); if(noContainersReason != null) { event.setCancelled(true); String message = GriefPrevention.instance.dataStore.getMessage(Messages.NoDamageClaimedEntity, claim.getOwnerName()); if(attacker.hasPermission("griefprevention.ignoreclaims")) message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement); GriefPrevention.sendMessage(attacker, TextMode.Err, message); event.setCancelled(true); } //cache claim for later if(playerData != null) { playerData.lastClaim = claim; } } } }
public boolean damageEntity(DamageSource damagesource, float f) { if (!this.world.isStatic && !this.dead) { if (this.isInvulnerable()) { return false; } else { // CraftBukkit start - fire VehicleDamageEvent Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } f = (float) event.getDamage(); // CraftBukkit end this.j(-this.l()); this.c(10); this.Q(); this.setDamage(this.getDamage() + f * 10.0F); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { if (this.passenger != null) { this.passenger.mount(this); } // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (flag && !this.k_()) { this.die(); } else { this.a(damagesource); } } return true; } } else { return true; } }
public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable()) { return false; } else if (!this.world.isStatic && !this.dead) { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } // f = event.getDamage(); // TODO Why don't we do this? // CraftBukkit end this.c(-this.i()); this.a(10); this.setDamage(this.getDamage() + f * 10.0F); this.Q(); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (this.passenger != null) { this.passenger.mount(this); } if (!flag) { this.a(Items.BOAT, 1, 0.0F); } this.die(); } return true; } else { return true; } }
public boolean damageEntity(DamageSource damagesource, float f) { if (!this.world.isStatic && !this.dead) { if (this.isInvulnerable()) { return false; } else { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } f = (float) event.getDamage(); // CraftBukkit end this.h(-this.k()); this.c(10); this.K(); this.setDamage(this.getDamage() + f * 10.0F); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { if (this.passenger != null) { this.passenger.mount(this); } // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (flag && !this.c()) { this.die(); } else { this.a(damagesource); } } return true; } } else { return true; } }
public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable()) { return false; } else if (!this.world.isStatic && !this.dead) { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } // i = event.getDamage(); // TODO Why don't we do this? // CraftBukkit end this.c(-this.h()); this.a(10); this.setDamage(this.getDamage() + f * 10.0F); this.K(); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (this.passenger != null) { this.passenger.mount(this); } if (!flag) { this.a(Item.BOAT.id, 1, 0.0F); } this.die(); } return true; } else { return true; } }
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { if (!this.worldObj.isRemote && !this.isDead) { if (this.isEntityInvulnerable()) { return false; } else { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity passenger = (p_70097_1_.getEntity() == null) ? null : p_70097_1_.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, p_70097_2_); this.worldObj.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } p_70097_2_ = (float) event.getDamage(); // CraftBukkit end this.setRollingDirection(-this.getRollingDirection()); this.setRollingAmplitude(10); this.setBeenAttacked(); this.setDamage(this.getDamage() + p_70097_2_ * 10.0F); boolean flag = p_70097_1_.getEntity() instanceof EntityPlayer && ((EntityPlayer)p_70097_1_.getEntity()).capabilities.isCreativeMode; if (flag || this.getDamage() > 40.0F) { if (this.riddenByEntity != null) { this.riddenByEntity.mountEntity(this); } // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); this.worldObj.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (flag && !this.hasCustomInventoryName()) { this.setDead(); } else { this.killMinecart(p_70097_1_); } } return true; } } else { return true; } }
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { if (this.isEntityInvulnerable()) { return false; } else if (!this.worldObj.isRemote && !this.isDead) { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity attacker = (p_70097_1_.getEntity() == null) ? null : p_70097_1_.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) p_70097_2_); this.worldObj.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } // f = event.getDamage(); // TODO Why don't we do this? // CraftBukkit end this.setForwardDirection(-this.getForwardDirection()); this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() + p_70097_2_ * 10.0F); this.setBeenAttacked(); boolean flag = p_70097_1_.getEntity() instanceof EntityPlayer && ((EntityPlayer)p_70097_1_.getEntity()).capabilities.isCreativeMode; if (flag || this.getDamageTaken() > 40.0F) { // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); this.worldObj.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamageTaken(40F); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (this.riddenByEntity != null) { this.riddenByEntity.mountEntity(this); } if (!flag) { this.func_145778_a(Items.boat, 1, 0.0F); } this.setDead(); } return true; } else { return true; } }
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { if (event.getAttacker() instanceof Player && testObserverOrDead((Player) event.getAttacker())) { event.setCancelled(true); } }
public boolean damageEntity(DamageSource damagesource, float f) { if (!this.world.isClientSide && !this.dead) { if (this.isInvulnerable(damagesource)) { return false; } else { // CraftBukkit start - fire VehicleDamageEvent Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } f = (float) event.getDamage(); // CraftBukkit end this.e(-this.u()); this.d(10); this.ao(); this.setDamage(this.getDamage() + f * 10.0F); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end this.az(); if (flag && !this.hasCustomName()) { this.die(); } else { this.a(damagesource); } } return true; } } else { return true; } }
public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable(damagesource)) { return false; } else if (!this.world.isClientSide && !this.dead) { if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) { return false; } else { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } // f = event.getDamage(); // TODO Why don't we do this? // CraftBukkit end this.d(-this.q()); this.b(10); this.setDamage(this.n() + f * 10.0F); this.ao(); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.n() > 40.0F) { // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) { this.a(this.j(), 1, 0.0F); } this.die(); } return true; } } else { return true; } }
public boolean damageEntity(DamageSource damagesource, int i) { if (!this.world.isStatic && !this.dead) { if (this.isInvulnerable()) { return false; } else { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, i); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } i = event.getDamage(); // CraftBukkit end this.j(-this.k()); this.i(10); this.J(); this.setDamage(this.getDamage() + i * 10); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40) { if (this.passenger != null) { this.passenger.mount(this); } // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (flag && !this.c()) { this.die(); } else { this.a(damagesource); } } return true; } } else { return true; } }
public boolean damageEntity(DamageSource damagesource, int i) { if (this.isInvulnerable()) { return false; } else if (!this.world.isStatic && !this.dead) { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, i); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } // i = event.getDamage(); // TODO Why don't we do this? // CraftBukkit end this.h(-this.h()); this.b(10); this.setDamage(this.getDamage() + i * 10); this.J(); boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40) { // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end if (this.passenger != null) { this.passenger.mount(this); } if (!flag) { this.a(Item.BOAT.id, 1, 0.0F); } this.die(); } return true; } else { return true; } }