org.bukkit.event.vehicle.VehicleDamageEvent Java Examples
The following examples show how to use
org.bukkit.event.vehicle.VehicleDamageEvent.
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: EntityDamageByEntityListener.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { try { final Vehicle vehicle = event.getVehicle(); final Location location = vehicle.getLocation(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); final Island island = islandManager.getIslandViaLocation(location); if (island == null) return; final Entity attacker = event.getAttacker(); if (!(attacker instanceof Player)) return; final Player attackerPlayer = (Player) attacker; final User attackerUser = User.getUser(attackerPlayer); if (!island.getPermissions(attackerUser).killMobs) event.setCancelled(true); } catch (Exception ex) { IridiumSkyblock.getInstance().sendErrorMessage(ex); } }
Example #2
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 6 votes |
@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); } }
Example #3
Source File: ExprAttacker.java From Skript with GNU General Public License v3.0 | 6 votes |
@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; }
Example #4
Source File: ExprAttacked.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) { if (!ScriptLoader.isCurrentEvent(EntityDamageEvent.class, EntityDeathEvent.class, VehicleDamageEvent.class, VehicleDestroyEvent.class)) { Skript.error("The expression 'victim' can only be used in a damage or death event", ErrorQuality.SEMANTIC_ERROR); return false; } final String type = parser.regexes.size() == 0 ? null : parser.regexes.get(0).group(); if (type == null) { this.type = EntityData.fromClass(Entity.class); } else { final EntityData<?> t = EntityData.parse(type); if (t == null) { Skript.error("'" + type + "' is not an entity type", ErrorQuality.NOT_AN_EXPRESSION); return false; } this.type = t; } return true; }
Example #5
Source File: EntityEventHandler.java From GriefDefender with MIT License | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onVehicleDamage(VehicleDamageEvent event) { GDTimings.ENTITY_DAMAGE_EVENT.startTiming(); final Object source = event.getAttacker() != null ? event.getAttacker() : NMSUtil.getInstance().getBlockDamager(); if (protectEntity(event, source, (Entity) event.getVehicle())) { event.setCancelled(true); } GDTimings.ENTITY_DAMAGE_EVENT.stopTiming(); }
Example #6
Source File: SafeBoat.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * @param e - event * 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); }
Example #7
Source File: ExploitEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@EventHandler public void on(VehicleDamageEvent e) { if (breakVehicleEnabled || !(e.getAttacker() instanceof Player) || !plugin.getWorldManager().isSkyAssociatedWorld(e.getVehicle().getWorld()) ) { return; } Player player = (Player) e.getAttacker(); if (player.hasPermission("usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) { return; } e.setCancelled(true); player.sendMessage(tr("\u00a7eYou cannot break vehicles while being a visitor!")); }
Example #8
Source File: ExprDamage.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable protected Double[] get(final Event e) { if (!(e instanceof EntityDamageEvent || e instanceof VehicleDamageEvent)) return new Double[0]; if (e instanceof VehicleDamageEvent) return CollectionUtils.array(((VehicleDamageEvent) e).getDamage()); return CollectionUtils.array(HealthUtils.getDamage((EntityDamageEvent) e)); }
Example #9
Source File: ExprDamage.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(EntityDamageEvent.class, VehicleDamageEvent.class)) { Skript.error("The expression 'damage' may only be used in damage events", ErrorQuality.SEMANTIC_ERROR); return false; } delay = isDelayed; return true; }
Example #10
Source File: ExprAttacker.java From Skript with GNU General Public License v3.0 | 5 votes |
@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; }
Example #11
Source File: DamageMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@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())); }
Example #12
Source File: DamageMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onDamageVehicle(VehicleDamageEvent event) { MatchPlayer victim = getVictim(event.getVehicle()); if (victim == null) return; processDamageEvent( event, victim.getParticipantState(), tracker() .resolveDamage( EntityDamageEvent.DamageCause.CUSTOM, event.getVehicle(), event.getAttacker())); }
Example #13
Source File: FreezeListener.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDamage(final VehicleDamageEvent event) { if(freeze.isFrozen(event.getAttacker())) { event.setCancelled(true); } }
Example #14
Source File: EventFilterMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onVehicleDamage(final VehicleDamageEvent event) { cancelUnlessInteracting(event, event.getAttacker()); }
Example #15
Source File: FreezeMatchModule.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDamage(final VehicleDamageEvent event) { if (freeze.isFrozen(event.getAttacker())) { event.setCancelled(true); } }
Example #16
Source File: EventFilterMatchModule.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onVehicleDamage(final VehicleDamageEvent event) { cancelUnlessInteracting(event, event.getAttacker()); }
Example #17
Source File: ObserverModule.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onVehicleDamage(VehicleDamageEvent event) { if (event.getAttacker() instanceof Player && testObserverOrDead((Player) event.getAttacker())) { event.setCancelled(true); } }