Java Code Examples for org.bukkit.event.player.PlayerTeleportEvent#getPlayer()
The following examples show how to use
org.bukkit.event.player.PlayerTeleportEvent#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: PlayerEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onTeleport(PlayerTeleportEvent event) { if (event.getTo() != null || !plugin.getWorldManager().isSkyWorld(event.getTo().getWorld())) { return; } final Player player = event.getPlayer(); boolean isAdmin = player.isOp() || player.hasPermission("usb.mod.bypassprotection"); IslandInfo islandInfo = uSkyBlock.getInstance().getIslandInfo(WorldGuardHandler.getIslandNameAt(event.getTo())); if (!isAdmin && islandInfo != null && islandInfo.isBanned(player.getUniqueId())) { event.setCancelled(true); player.sendMessage(tr("\u00a74That player has forbidden you from teleporting to their island.")); } if (!isAdmin && islandInfo != null && islandInfo.isLocked() && !islandInfo.getMembers().contains(player.getName()) && !islandInfo.isTrusted(player)) { event.setCancelled(true); player.sendMessage(tr("\u00a74That island is \u00a7clocked.\u00a7e No teleporting to the island.")); } if (!event.isCancelled()) { final PlayerInfo playerInfo = plugin.getPlayerInfo(player); playerInfo.onTeleport(player); } }
Example 2
Source File: DPlayerListener.java From DungeonsXL with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerTeleport(PlayerTeleportEvent event) { Player player = event.getPlayer(); if (isCitizensNPC(player)) { return; } GlobalPlayer dPlayer = dPlayers.get(player); World toWorld = event.getTo().getWorld(); if (dPlayer instanceof InstancePlayer && ((InstancePlayer) dPlayer).getWorld() == toWorld) { return; } if (plugin.getInstanceWorld(toWorld) != null) { dPlayer.sendMessage(DMessage.ERROR_JOIN_GROUP.getMessage()); dPlayer.sendMessage(ChatColor.GOLD + DMessage.CMD_ENTER_HELP.getMessage()); event.setCancelled(true); } }
Example 3
Source File: PetOwnerListener.java From SonarPet with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerTeleport(final PlayerTeleportEvent event) { final Player p = event.getPlayer(); final IPet pi = EchoPet.getManager().getPet(p); Iterator<IPet> i = EchoPet.getManager().getPets().iterator(); while (i.hasNext()) { IPet pet = i.next(); if (pet.getEntityPet() instanceof IEntityPacketPet && ((IEntityPacketPet) pet.getEntityPet()).hasInititiated()) { if (GeometryUtil.getNearbyEntities(event.getTo(), 50).contains(pet)) { ((IEntityPacketPet) pet.getEntityPet()).updatePosition(); } } } if (pi != null) { if (!WorldUtil.allowPets(event.getTo())) { Lang.sendTo(p, Lang.PETS_DISABLED_HERE.toString().replace("%world%", WordUtils.capitalizeFully(event.getTo().getWorld().getName()))); EchoPet.getManager().saveFileData("autosave", pi); EchoPet.getSqlManager().saveToDatabase(pi, false); EchoPet.getManager().removePet(pi, false); } } }
Example 4
Source File: NoEntryListener.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) public void onTeleport(PlayerTeleportEvent e) { ICombatLogX plugin = this.expansion.getPlugin(); ICombatManager manager = plugin.getCombatManager(); Player player = e.getPlayer(); if(!manager.isInCombat(player)) return; LivingEntity enemy = manager.getEnemy(player); if(enemy == null) return; Location toLocation = e.getTo(); TagType tagType = (enemy instanceof Player ? TagType.PLAYER : TagType.MOB); NoEntryHandler handler = this.expansion.getNoEntryHandler(); if(!handler.isSafeZone(player, toLocation, tagType)) return; e.setCancelled(true); this.expansion.sendNoEntryMessage(player, enemy); }
Example 5
Source File: HoloListener.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerTeleport(PlayerTeleportEvent event) { Player player = event.getPlayer(); for (Hologram h : HoloAPI.getManager().getAllHolograms().keySet()) { if (event.getTo().getWorld().getName().equals(h.getWorldName())) { if (h.getLocationFor(player) != null && h.getVisibility().isVisibleTo(player, h.getSaveId())) { h.show(player, true); } } } }
Example 6
Source File: SpectateListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerTeleport(PlayerTeleportEvent e) { final Player player = e.getPlayer(); final GameMap gameMap = MatchManager.get().getSpectatorMap(player); if (gameMap == null || player.hasPermission("sw.opteleport")) { return; } if (e.getCause() != TeleportCause.END_PORTAL) { e.setCancelled(true); } }
Example 7
Source File: Compat19.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onPlayerTeleport(PlayerTeleportEvent e) { final Player p = e.getPlayer(); Location lfrom = e.getFrom(); Location lto = e.getTo(); if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT)) { final Region rfrom = RedProtect.get().rm.getTopRegion(lfrom); final Region rto = RedProtect.get().rm.getTopRegion(lto); if (rfrom != null && !rfrom.canTeleport(p)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse"); e.setCancelled(true); } if (rto != null && !rto.canTeleport(p)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse"); e.setCancelled(true); } } if (p.getInventory().getChestplate() != null && p.getInventory().getChestplate().getType().equals(Material.ELYTRA) && !RedProtect.get().config.globalFlagsRoot().worlds.get(lto.getWorld().getName()).player_glide.allow_elytra) { RedProtect.get().lang.sendMessage(p, "globallistener.elytra.cantworld"); e.setCancelled(true); } }
Example 8
Source File: PlayerTeleportListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false) public void onPlayerTeleport(final PlayerTeleportEvent a1) { Player player = a1.getPlayer(); if (SkyWarsReloaded.getCfg().getSpawn() != null) { if (!a1.getFrom().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld()) && a1.getTo().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld())) { PlayerStat.updatePlayer(a1.getPlayer().getUniqueId().toString()); return; } if (a1.getFrom().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld()) && !a1.getTo().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld())) { if (SkyWarsReloaded.getCfg().lobbyBoardEnabled()) { player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } if (SkyWarsReloaded.getCfg().joinMenuEnabled() && player.hasPermission("sw.join")) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getJoinSlot()) != null) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getJoinSlot()).equals(SkyWarsReloaded.getIM().getItem("joinselect"))) { player.getInventory().setItem(SkyWarsReloaded.getCfg().getJoinSlot(), new ItemStack(Material.AIR, 1)); } } } if (SkyWarsReloaded.getCfg().optionsMenuEnabled()) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getOptionsSlot()) != null) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getOptionsSlot()).equals(SkyWarsReloaded.getIM().getItem("optionselect"))) { player.getInventory().setItem(SkyWarsReloaded.getCfg().getOptionsSlot(), new ItemStack(Material.AIR, 1)); } } } } return; } }
Example 9
Source File: CFIPacketListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onTeleport(PlayerTeleportEvent event) { final Player player = event.getPlayer(); VirtualWorld gen = getGenerator(player); if (gen != null) { Location from = event.getFrom(); Location to = event.getTo(); if (to.getWorld().equals(from.getWorld()) && to.distanceSquared(from) < 8) { event.setTo(player.getLocation()); event.setCancelled(true); player.setVelocity(player.getVelocity()); } } }
Example 10
Source File: ShopUpdateListener.java From ShopChest with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerTeleport(PlayerTeleportEvent e) { Location from = e.getFrom(); Location to = e.getTo(); final Player p = e.getPlayer(); // Wait till the chunk should have loaded on the client if (!from.getWorld().getName().equals(to.getWorld().getName()) || from.getChunk().getX() != to.getChunk().getX() || from.getChunk().getZ() != to.getChunk().getZ()) { new BukkitRunnable() { @Override public void run() { plugin.getUpdater().queue(() -> { if (p.isOnline()) { for (Shop shop : plugin.getShopUtils().getShops()) { if (shop.hasItem()) { shop.getItem().hidePlayer(p); } if (shop.hasHologram()) { shop.getHologram().hidePlayer(p); } } plugin.getShopUtils().resetPlayerLocation(p); } }); plugin.getUpdater().updateShops(p); } }.runTaskLater(plugin, 15L); } }
Example 11
Source File: HologramManager.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerTeleport(PlayerTeleportEvent event) { if (HOLOGRAMS.isEmpty() || !event.getFrom().getWorld().equals(event.getTo().getWorld()) /* World change is handled in another event*/) { return; } List<Hologram> copy = new ArrayList<>(HOLOGRAMS); for (Hologram hologram : copy) { if (hologram.isEmpty() || !hologram.hasViewers()) { HOLOGRAMS.remove(hologram); continue; } try { Player player = event.getPlayer(); List<Player> viewers = hologram.getViewers(); Location loc = hologram.getLocation(); if (viewers.contains(player) && player.getWorld().equals(loc.getWorld())) { if (event.getTo().distanceSquared(loc) < VISIBILITY_DISTANCE_SQUARED && event.getFrom().distanceSquared(loc) >= VISIBILITY_DISTANCE_SQUARED) { hologram.update(player, hologram.getAllSpawnPackets(), false); } else if (event.getTo().distanceSquared(loc) >= VISIBILITY_DISTANCE_SQUARED && event.getFrom().distanceSquared(loc) < VISIBILITY_DISTANCE_SQUARED) { hologram.update(player, Arrays.asList(hologram.getFullDestroyPacket()), false); } } } catch (Throwable t) { } } }
Example 12
Source File: Bar.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerTeleport(final PlayerTeleportEvent event) { if(event.getTo() != null && event.getPlayer() != null) { handleTeleport(event.getPlayer(), event.getTo().clone()); } }
Example 13
Source File: PlayerListener.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerTeleportEvent(PlayerTeleportEvent event) { Player player = event.getPlayer(); player.removeMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, WorldGuardExtraFlagsPlugin.getPlugin()); }
Example 14
Source File: TeleportEvent.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
@EventHandler public void playerTeleport(PlayerTeleportEvent event) { Player p = event.getPlayer(); int id = GameManager.getInstance().getPlayerGameId(p); if(id == -1) return; if(GameManager.getInstance().getGame(id).isPlayerActive(p) && event.getCause() == PlayerTeleportEvent.TeleportCause.COMMAND){ p.sendMessage(ChatColor.RED +" Cannot teleport while ingame!"); event.setCancelled(true); } }
Example 15
Source File: DurabilityBar.java From AdditionsAPI with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerTeleport(PlayerTeleportEvent event) { if (event.isCancelled()) return; Player player = event.getPlayer(); Bukkit.getScheduler().scheduleSyncDelayedTask(AdditionsAPI.getInstance(), () -> { sendDurabilityBossBar(player, player.getInventory().getItemInMainHand(), EquipmentSlot.HAND); sendDurabilityBossBar(player, player.getInventory().getItemInOffHand(), EquipmentSlot.OFF_HAND); }); }
Example 16
Source File: TitleRespawn.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerMove(PlayerTeleportEvent event) { Player player = event.getPlayer(); if (!this.spectate && (isDeadUUID(player.getUniqueId()) && deadPlayers.get(player.getUniqueId()) != 0)) { event.setCancelled(true); } }
Example 17
Source File: TeleportListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerTeleport(PlayerTeleportEvent e){ if (e.getCause() == TeleportCause.SPECTATE && !GameManager.getGameManager().getConfiguration().getSpectatingTeleport()){ Player player = e.getPlayer(); if (!player.hasPermission("uhc-core.commands.teleport-admin")){ e.setCancelled(true); player.sendMessage(Lang.COMMAND_SPECTATING_TELEPORT_ERROR); } } }
Example 18
Source File: HologramManager.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerTeleport(PlayerTeleportEvent event) { if (HOLOGRAMS.isEmpty() || !event.getFrom().getWorld().equals(event.getTo().getWorld()) /* World change is handled in another event*/) { return; } List<Hologram> copy = new ArrayList<>(HOLOGRAMS); for (Hologram hologram : copy) { if (hologram.isEmpty() || !hologram.hasViewers()) { HOLOGRAMS.remove(hologram); continue; } try { Player player = event.getPlayer(); List<Player> viewers = hologram.getViewers(); Location loc = hologram.getLocation(); if (viewers.contains(player) && player.getWorld().equals(loc.getWorld())) { if (event.getTo().distanceSquared(loc) < VISIBILITY_DISTANCE_SQUARED && event.getFrom().distanceSquared(loc) >= VISIBILITY_DISTANCE_SQUARED) { hologram.update(player, hologram.getAllSpawnPackets(), false); } else if (event.getTo().distanceSquared(loc) >= VISIBILITY_DISTANCE_SQUARED && event.getFrom().distanceSquared(loc) < VISIBILITY_DISTANCE_SQUARED) { hologram.update(player, Arrays.asList(hologram.getFullDestroyPacket()), false); } } } catch (Throwable t) { } } }
Example 19
Source File: TeleportsListener.java From Statz with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent event) { final PlayerStat stat = PlayerStat.TELEPORTS; // Get player final Player player = event.getPlayer(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; PlayerStatSpecification specification = new TeleportsSpecification(player.getUniqueId(), 1, player.getWorld().getName(), event.getTo().getWorld().getName(), event.getCause().toString()); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, specification.constructQuery()); }
Example 20
Source File: PlayerTeleportListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerTeleport(final PlayerTeleportEvent a1) { Player player = a1.getPlayer(); final GameMap gameMap = MatchManager.get().getPlayerMap(player); if (gameMap == null) { if (SkyWarsReloaded.getCfg().getSpawn() != null) { if (!a1.getFrom().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld()) && a1.getTo().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld())) { PlayerStat.updatePlayer(a1.getPlayer().getUniqueId().toString()); return; } if (a1.getFrom().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld()) && !a1.getTo().getWorld().equals(SkyWarsReloaded.getCfg().getSpawn().getWorld())) { if (SkyWarsReloaded.getCfg().lobbyBoardEnabled()) { player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } if (SkyWarsReloaded.getCfg().optionsMenuEnabled()) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getOptionsSlot()) != null) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getOptionsSlot()).equals(SkyWarsReloaded.getIM().getItem("optionselect"))) { player.getInventory().setItem(SkyWarsReloaded.getCfg().getOptionsSlot(), new ItemStack(Material.AIR, 1)); } } } if (SkyWarsReloaded.getCfg().joinMenuEnabled() && player.hasPermission("sw.join")) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getJoinSlot()) != null) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getJoinSlot()).equals(SkyWarsReloaded.getIM().getItem("joinselect"))) { player.getInventory().setItem(SkyWarsReloaded.getCfg().getJoinSlot(), new ItemStack(Material.AIR, 1)); } } } if (SkyWarsReloaded.getCfg().spectateMenuEnabled() && player.hasPermission("sw.spectate")) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getSpectateSlot()) != null) { if (player.getInventory().getItem(SkyWarsReloaded.getCfg().getSpectateSlot()).equals(SkyWarsReloaded.getIM().getItem("spectateselect"))) { player.getInventory().setItem(SkyWarsReloaded.getCfg().getSpectateSlot(), new ItemStack(Material.AIR, 1)); } } } } } } else { if (a1.getCause().equals(TeleportCause.END_PORTAL) || player.hasPermission("sw.opteleport") || a1.getTo().getWorld().equals(a1.getFrom().getWorld())) { a1.setCancelled(false); } else { if (a1.getCause().equals(TeleportCause.ENDER_PEARL) && gameMap.getMatchState() != MatchState.ENDING && gameMap.getMatchState() != MatchState.WAITINGSTART) { a1.setCancelled(false); } else { a1.setCancelled(true); } } } }