Java Code Examples for org.bukkit.event.player.PlayerPortalEvent#getPlayer()
The following examples show how to use
org.bukkit.event.player.PlayerPortalEvent#getPlayer() .
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: 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 2
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 3
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); } } }