Java Code Examples for org.bukkit.event.vehicle.VehicleEnterEvent#setCancelled()

The following examples show how to use org.bukkit.event.vehicle.VehicleEnterEvent#setCancelled() . 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: RegionInteractListener.java    From NovaGuilds with GNU General Public License v3.0 6 votes vote down vote up
@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 2
Source File: EntityEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityMount(VehicleEnterEvent event) {
    if (!GDFlags.ENTITY_RIDING) {
        return;
    }

    final Entity source = event.getEntered();
    final World world = source.getWorld();
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }
    if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.ENTITY_RIDING.getName(), source, world.getUID())) {
        return;
    }
    if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.ENTITY_RIDING.getName(), event.getVehicle(), world.getUID())) {
        return;
    }

    GDTimings.ENTITY_MOUNT_EVENT.startTiming();
    Player player = source instanceof Player ? (Player) source : null;
    if (player != null) {
        GDCauseStackManager.getInstance().pushCause(player);
    }
    final Location location = event.getVehicle().getLocation();
    final GDClaim targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location);

    if (GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.ENTITY_RIDING, source, event.getVehicle(), player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
        if (player != null) {
            PlayerUtil.getInstance().sendInteractEntityDenyMessage(targetClaim, player, null, event.getVehicle());
        }
        event.setCancelled(true);
    }

    GDTimings.ENTITY_MOUNT_EVENT.stopTiming();
}
 
Example 3
Source File: ExploitEvents.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void on(VehicleEnterEvent e) {
    if (mountEnabled
            || !(e.getEntered() instanceof Player)
            || !plugin.getWorldManager().isSkyAssociatedWorld(e.getVehicle().getWorld())
    ) {
        return;
    }
    Player player = (Player) e.getEntered();
    if (player.hasPermission("usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) {
        return;
    }
    e.setCancelled(true);
    player.sendMessage(tr("\u00a7eRiding is only allowed on your own island!"));
}
 
Example 4
Source File: LivingEntityShopListener.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
void onEntityEnterVehicle(VehicleEnterEvent event) {
	Entity entity = event.getEntered();
	if (plugin.isShopkeeper(entity)) {
		event.setCancelled(true);
	}
}
 
Example 5
Source File: FreezeMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleEnter(final VehicleEnterEvent event) {
  if (freeze.isFrozen(event.getEntered())) {
    event.setCancelled(true);
  }
}
 
Example 6
Source File: FreezeListener.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleEnter(final VehicleEnterEvent event) {
    if(freeze.isFrozen(event.getEntered())) {
        event.setCancelled(true);
    }
}
 
Example 7
Source File: MultiplePassengersRestrict.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onVehicleEnter(VehicleEnterEvent event) {
	if (!event.getVehicle().getPassengers().isEmpty() && needsRestrict()) {
		event.setCancelled(true);
	}
}
 
Example 8
Source File: ObserverModule.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    if (event.getEntered() instanceof Player && testObserverOrDead((Player) event.getEntered())) {
        event.setCancelled(true);
    }
}