Java Code Examples for org.bukkit.event.vehicle.VehicleDamageEvent#getAttacker()
The following examples show how to use
org.bukkit.event.vehicle.VehicleDamageEvent#getAttacker() .
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: 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 4
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 5
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 6
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); } }