Java Code Examples for org.bukkit.event.player.PlayerPortalEvent#setCancelled()
The following examples show how to use
org.bukkit.event.player.PlayerPortalEvent#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: PortalEvent.java From WildernessTp with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPortalEnter(PlayerPortalEvent e){ for (String name : plugin.portals.keySet()) { String portal = plugin.portals.get(name); String[] info = portal.split(":"); if (e.getTo().getWorld().getName().equals(info[0])) { if (Wild.cancel.contains(e.getPlayer().getUniqueId())) { return; } else { String[] max = info[1].split(","); String[] min = info[2].split(","); Vector maxVec = new Vector(Integer.parseInt(max[0]), Integer.parseInt(max[1]), Integer.parseInt(max[2])); Vector minVec = new Vector(Integer.parseInt(min[0]), Integer.parseInt(min[1]), Integer.parseInt(min[2])); Region region = new Region(maxVec, minVec); Vector vec = new Vector(e.getTo().getBlockX(), e.getTo().getBlockY(), e.getTo().getBlockZ()); if (region.contains(vec)) { e.setCancelled(true); } } } } }
Example 2
Source File: KitLoading.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void ClassChanger(final PlayerPortalEvent event) { if(Game.isGameRunning() && event.getPlayer().getGameMode() != GameMode.CREATIVE) { AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId()); if(p != null) { event.setCancelled(true); if(p.getTeam() != null) { final Player pl = event.getPlayer(); pl.teleport(p.getTeam().getRandomSpawn()); Bukkit.getScheduler().runTaskLater(AnnihilationMain.getInstance(), new Runnable(){ @Override public void run() { openKitMap(pl); }}, 40); } } } }
Example 3
Source File: ExploitEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPortalEvent(PlayerPortalEvent event) { Player player = event.getPlayer(); if (usePortals || event.getTo() == null || (!plugin.getWorldManager().isSkyAssociatedWorld(event.getTo().getWorld()) && !plugin.getWorldManager().isSkyAssociatedWorld(event.getFrom().getWorld()))) { return; // We only care about portals going into or out of skyworld } if (player.hasPermission("usb.mod.bypassprotection") || plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) { return; } if (event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL || event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL) { us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(player); if (islandInfo == null || (!islandInfo.contains(event.getTo()) && !islandInfo.contains(event.getFrom()))) { event.setCancelled(true); player.sendMessage(tr("\u00a7eYou can not use another island''s portals!")); } } }
Example 4
Source File: BukkitFollowListener.java From Parties with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler (ignoreCancelled = true) public void onEntityPortalEvent(PlayerPortalEvent event) { if (!event.isCancelled()) { BukkitPartyPlayerImpl pp = (BukkitPartyPlayerImpl) plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId()); if (pp.getPortalTimeoutTask() != null) { event.setCancelled(true); } } }
Example 5
Source File: GlobalProtectionListener.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerPortal(PlayerPortalEvent event) { Block block1 = event.getFrom().getBlock(); Block block2 = block1.getRelative(BlockFace.UP); Block block3 = block2.getRelative(BlockFace.UP); Block block4 = block1.getRelative(BlockFace.DOWN); if (isPortalInNearBy(block1) || isPortalInNearBy(block2) || isPortalInNearBy(block3) || isPortalInNearBy(block4)) { event.setCancelled(true); } }
Example 6
Source File: EndModule.java From UHC with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void on(PlayerPortalEvent event) { if (isEnabled()) return; if (event.getTo() == null) return; if (event.getTo().getWorld().getEnvironment() == World.Environment.THE_END) { event.setCancelled(true); event.getPlayer().sendMessage(messages.getRaw("disabled message")); } }
Example 7
Source File: NetherModule.java From UHC with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void on(PlayerPortalEvent event) { if (isEnabled()) return; if (event.getTo() == null) return; if (event.getTo().getWorld().getEnvironment() == World.Environment.NETHER) { event.setCancelled(true); event.getPlayer().sendMessage(messages.getRaw("disabled message")); } }
Example 8
Source File: PlayerListener.java From civcraft with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerPortalEvent(PlayerPortalEvent event) { if(event.getCause().equals(TeleportCause.END_PORTAL)) { event.setCancelled(true); CivMessage.sendErrorNoRepeat(event.getPlayer(), "The End portal is disabled on this server."); return; } if (event.getCause().equals(TeleportCause.NETHER_PORTAL)) { event.setCancelled(true); CivMessage.sendErrorNoRepeat(event.getPlayer(), "The Nether is disabled on this server."); return; } }
Example 9
Source File: TeleportListener.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerPortalEvent (PlayerPortalEvent event){ GameManager gm = GameManager.getGameManager(); Player player = event.getPlayer(); // Disable nether/end in deathmatch if (gm.getGameState() == GameState.DEATHMATCH){ event.setCancelled(true); return; } if (event.getCause() == TeleportCause.NETHER_PORTAL) { if (!gm.getConfiguration().getEnableNether()){ player.sendMessage(Lang.PLAYERS_NETHER_OFF); event.setCancelled(true); return; } // No Going back! if (gm.getScenarioManager().isActivated(Scenario.NOGOINGBACK) && event.getFrom().getWorld().getEnvironment() == Environment.NETHER){ player.sendMessage(Lang.SCENARIO_NOGOINGBACK_ERROR); event.setCancelled(true); return; } // Handle event using versions utils as on 1.14+ PortalTravelAgent got removed. VersionUtils.getVersionUtils().handleNetherPortalEvent(event); }else if (event.getCause() == TeleportCause.END_PORTAL){ if (gm.getConfiguration().getEnableTheEnd() && event.getFrom().getWorld().getEnvironment() == Environment.NORMAL){ // Teleport to end Location end = new Location(Bukkit.getWorld(gm.getConfiguration().getTheEndUuid()), -42, 48, -18); createEndSpawnAir(end); createEndSpawnObsidian(end); event.setTo(end); } } }