org.bukkit.entity.Vehicle Java Examples
The following examples show how to use
org.bukkit.entity.Vehicle.
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: RegionInteractListener.java From NovaGuilds with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onVehicleEnter(VehicleEnterEvent event) { Vehicle vehicle = event.getVehicle(); if(!(event.getEntered() instanceof Player)) { return; } final Player player = (Player) event.getEntered(); NovaPlayer nPlayer = PlayerManager.getPlayer(player); List<String> denyRiding = Config.REGION_DENYRIDING.getStringList(); if(denyRiding.contains(vehicle.getType().name()) && RegionManager.get(vehicle) != null && (!plugin.getRegionManager().canInteract(player, vehicle) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_RIDE))) && !PlayerManager.getPlayer(event.getEntered()).isVehicleListed(vehicle)) { event.setCancelled(true); Message.CHAT_REGION_DENY_RIDEMOB.send(event.getEntered()); } }
Example #3
Source File: RegionInteractListener.java From NovaGuilds with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onPlayerUnleashEntity(PlayerUnleashEntityEvent event) { List<String> denyRiding = Config.REGION_DENYRIDING.getStringList(); Player player = event.getPlayer(); Entity entity = event.getEntity(); NovaPlayer nPlayer = PlayerManager.getPlayer(player); if(denyRiding.contains(entity.getType().name())) { if(RegionManager.get(entity) != null && (!plugin.getRegionManager().canInteract(player, entity) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_LEASH))) && !(entity instanceof Vehicle) || !PlayerManager.getPlayer(player).isVehicleListed((Vehicle) event.getEntity())) { event.setCancelled(true); Message.CHAT_REGION_DENY_UNLEASH.send(player); } } }
Example #4
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 #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: RegionInteractListener.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerLeashEntity(PlayerLeashEntityEvent event) { List<String> denyRiding = Config.REGION_DENYRIDING.getStringList(); Player player = event.getPlayer(); Entity entity = event.getEntity(); NovaPlayer nPlayer = PlayerManager.getPlayer(player); if(denyRiding.contains(entity.getType().name()) && RegionManager.get(entity) != null && (!plugin.getRegionManager().canInteract(player, entity) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_LEASH))) && (!(entity instanceof Vehicle) || !PlayerManager.getPlayer(player).isVehicleListed((Vehicle) event.getEntity()))) { event.setCancelled(true); Message.CHAT_REGION_DENY_LEASH.send(event.getPlayer()); } }
Example #7
Source File: RegionManager.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
/** * Gets executed when a player enters a region * * @param player the player * @param region region he entered */ public void playerEnteredRegion(Player player, NovaRegion region) { PlayerEnterRegionEvent regionEvent = new PlayerEnterRegionEvent(player, region); ListenerManager.getLoggedPluginManager().callEvent(regionEvent); if(regionEvent.isCancelled()) { return; } if(region == null) { return; } NovaPlayer nPlayer = PlayerManager.getPlayer(player); if(plugin.getPlayerManager().isVanished(player)) { return; } //border particles if(Config.REGION_BORDERPARTICLES.getBoolean()) { List<Block> blocks = RegionUtils.getBorderBlocks(region); for(Block block : blocks) { block.getLocation().setY(block.getLocation().getY() + 1); block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 100); } } //Chat message boolean sameGuildRegion = nPlayer.isAtRegion() && region.getGuild().ownsRegion(region); Map<VarKey, String> vars = new HashMap<>(); if(!sameGuildRegion) { vars.put(VarKey.GUILD_NAME, region.getGuild().getName()); vars.put(VarKey.PLAYER_NAME, player.getName()); Message.CHAT_REGION_ENTERED.clone().vars(vars).send(player); } //Player is at region nPlayer.setAtRegion(region); if(!region.getGuild().isMember(nPlayer)) { checkRaidInit(nPlayer); if(!sameGuildRegion) { Message.CHAT_REGION_NOTIFYGUILD_ENTERED.clone().vars(vars).broadcast(region.getGuild()); } } //Vehicle protection system Entity vehicle = player.getVehicle(); if(vehicle != null && vehicle instanceof Vehicle) { nPlayer.addVehicle((Vehicle) vehicle); } }
Example #8
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public void addCustomEntityTypeContexts(Entity targetEntity, String id, Set<Context> contexts, GDEntityType type, boolean isSource) { if (isSource) { contexts.add(ContextGroups.SOURCE_ANY); contexts.add(new Context(ContextKeys.SOURCE, "#" + type.getModId().toLowerCase() + ":any")); } else { contexts.add(ContextGroups.TARGET_ANY); contexts.add(new Context(ContextKeys.TARGET, "#" + type.getModId().toLowerCase() + ":any")); } // check vehicle if (targetEntity instanceof Vehicle) { if (isSource) { contexts.add(ContextGroups.SOURCE_VEHICLE); } else { contexts.add(ContextGroups.TARGET_VEHICLE); } } // pixelmon if (targetEntity.getType() != null && targetEntity.getType().name().equalsIgnoreCase("pixelmon_pixelmon") || targetEntity.getType().name().equalsIgnoreCase("pixelmon")) { if (isSource) { contexts.add(ContextGroups.SOURCE_PIXELMON); } else { contexts.add(ContextGroups.TARGET_PIXELMON); } } final String creatureType = type.getEnumCreatureTypeId(); if (creatureType == null) { return; } final String modId = type.getModId().toLowerCase(); if (creatureType.contains("animal")) { if (isSource) { contexts.add(ContextGroups.SOURCE_ANIMAL); contexts.add(new Context(ContextKeys.SOURCE, "#" + modId + ":animal")); } else { contexts.add(ContextGroups.TARGET_ANIMAL); contexts.add(new Context(ContextKeys.TARGET, "#" + modId + ":animal")); } this.checkPetContext(targetEntity, modId, contexts, isSource); } else if (creatureType.contains("aquatic")) { if (isSource) { contexts.add(ContextGroups.SOURCE_AQUATIC); contexts.add(new Context(ContextKeys.SOURCE, "#" + modId + ":aquatic")); } else { contexts.add(ContextGroups.TARGET_AQUATIC); contexts.add(new Context(ContextKeys.TARGET, "#" + modId + ":aquatic")); } this.checkPetContext(targetEntity, modId, contexts, isSource); } else if (creatureType.contains("monster")) { if (isSource) { contexts.add(ContextGroups.SOURCE_MONSTER); contexts.add(new Context(ContextKeys.SOURCE, "#" + modId + ":monster")); } else { contexts.add(ContextGroups.TARGET_MONSTER); contexts.add(new Context(ContextKeys.TARGET, "#" + modId + ":monster")); } } else if (creatureType.contains("ambient")) { if (isSource) { contexts.add(ContextGroups.SOURCE_AMBIENT); contexts.add(new Context(ContextKeys.SOURCE, "#" + modId + ":ambient")); } else { contexts.add(ContextGroups.TARGET_AMBIENT); contexts.add(new Context(ContextKeys.TARGET, "#" + modId + ":ambient")); } this.checkPetContext(targetEntity, modId, contexts, isSource); } else { if (isSource) { contexts.add(ContextGroups.SOURCE_MISC); contexts.add(new Context(ContextKeys.SOURCE, "#" + modId + ":misc")); } else { contexts.add(ContextGroups.TARGET_MISC); contexts.add(new Context(ContextKeys.TARGET, "#" + modId + ":misc")); } } }
Example #9
Source File: NovaPlayerImpl.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
@Override public void addVehicle(Vehicle vehicle) { if(!isVehicleListed(vehicle)) { vehicles.add(vehicle); } }
Example #10
Source File: NovaPlayerImpl.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
@Override public boolean isVehicleListed(Vehicle vehicle) { return vehicles.contains(vehicle); }
Example #11
Source File: VehicleDamageEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final double damage) { super(vehicle); this.attacker = attacker; this.damage = damage; }
Example #12
Source File: VehicleDestroyEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleDestroyEvent(final Vehicle vehicle, final Entity attacker) { super(vehicle); this.attacker = attacker; }
Example #13
Source File: VehicleExitEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleExitEvent(final Vehicle vehicle, final LivingEntity exited) { super(vehicle); this.exited = exited; }
Example #14
Source File: VehicleEntityCollisionEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleEntityCollisionEvent(final Vehicle vehicle, final Entity entity) { super(vehicle); this.entity = entity; }
Example #15
Source File: VehicleEnterEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleEnterEvent(final Vehicle vehicle, final Entity entered) { super(vehicle); this.entered = entered; }
Example #16
Source File: VehicleMoveEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleMoveEvent(final Vehicle vehicle, final Location from, final Location to) { super(vehicle); this.from = from; this.to = to; }
Example #17
Source File: VehicleCollisionEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleCollisionEvent(final Vehicle vehicle) { super(vehicle); }
Example #18
Source File: VehicleUpdateEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleUpdateEvent(final Vehicle vehicle) { super(vehicle); }
Example #19
Source File: VehicleCreateEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleCreateEvent(final Vehicle vehicle) { super(vehicle); }
Example #20
Source File: VehicleEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleEvent(final Vehicle vehicle) { this.vehicle = vehicle; }
Example #21
Source File: VehicleBlockCollisionEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public VehicleBlockCollisionEvent(final Vehicle vehicle, final Block block) { super(vehicle); this.block = block; }
Example #22
Source File: NovaPlayer.java From NovaGuilds with GNU General Public License v3.0 | 2 votes |
/** * Checks if a vehicle belongs to the player * * @param vehicle the vehicle * @return the flag */ boolean isVehicleListed(Vehicle vehicle);
Example #23
Source File: NovaPlayer.java From NovaGuilds with GNU General Public License v3.0 | 2 votes |
/** * Adds a vehicle to the owned list * * @param vehicle the Vehicle */ void addVehicle(Vehicle vehicle);
Example #24
Source File: VehicleEvent.java From Kettle with GNU General Public License v3.0 | 2 votes |
/** * Get the vehicle. * * @return the vehicle */ public final Vehicle getVehicle() { return vehicle; }