org.bukkit.event.vehicle.VehicleCreateEvent Java Examples
The following examples show how to use
org.bukkit.event.vehicle.VehicleCreateEvent.
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: EntitySpawnListener.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler public void onVehicleSpawn(VehicleCreateEvent event) { final Vehicle vehicle = event.getVehicle(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); final Location location = vehicle.getLocation(); final Island island = islandManager.getIslandViaLocation(location); if (island == null) return; if (!IridiumSkyblock.getConfiguration().blockedEntities.contains(vehicle.getType())) return; IridiumSkyblock.getInstance().entities.put(vehicle.getUniqueId(), island); monitorEntity(vehicle); }
Example #2
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static VehicleCreateEvent callVehicleCreateEvent(Entity entity) { Vehicle bukkitEntity = (Vehicle) entity.getBukkitEntity(); VehicleCreateEvent event = new VehicleCreateEvent(bukkitEntity); Bukkit.getPluginManager().callEvent(event); return event; }
Example #3
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Handles minecart placing * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onMinecart(VehicleCreateEvent e) { if (DEBUG) { plugin.getLogger().info("DEBUG: " + e.getEventName()); plugin.getLogger().info("DEBUG: Vehicle type = " + e.getVehicle().getType()); } if (!IslandGuard.inWorld(e.getVehicle())) { if (DEBUG) plugin.getLogger().info("DEBUG: Not in world"); return; } if (DEBUG) plugin.getLogger().info("DEBUG: Checking entity types"); if (Settings.entityLimits.containsKey(e.getVehicle().getType())) { // If someone in that area has the bypass permission, allow the spawning for (Entity entity : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) { if (entity instanceof Player) { Player player = (Player)entity; Boolean bypass = false; if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypass")) { if (DEBUG) plugin.getLogger().info("DEBUG: op or bypass"); bypass = true; } // Check island Island island = plugin.getGrid().getProtectedIslandAt(e.getVehicle().getLocation()); if (island == null) { // Only count island entities if (DEBUG) plugin.getLogger().info("DEBUG: island is null"); return; } // Ignore spawn if (island.isSpawn()) { if (DEBUG) plugin.getLogger().info("DEBUG: ignore spawn"); return; } if (DEBUG) plugin.getLogger().info("DEBUG: Checking entity limits"); // Check if the player is at the limit if (atLimit(island, bypass, e.getVehicle())) { e.setCancelled(true); for (Entity ent : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) { if (ent instanceof Player) { Util.sendMessage((Player)ent, ChatColor.RED + (plugin.myLocale(player.getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(e.getVehicle().getType().toString())) .replace("[number]", String.valueOf(Settings.entityLimits.get(e.getVehicle().getType()))))); } } } } } } }