Java Code Examples for org.bukkit.entity.Player#showPlayer()
The following examples show how to use
org.bukkit.entity.Player#showPlayer() .
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: TutorialPlayer.java From ServerTutorial with MIT License | 6 votes |
public void restorePlayer(Player player) { player.teleport(startLoc); player.getInventory().setContents(inventory); player.setFlying(flight); player.setAllowFlight(allowFlight); player.setExp(exp); player.setLevel(level); player.setFoodLevel(hunger); player.setHealth(health); player.setGameMode(gameMode); for (Player online : Bukkit.getServer().getOnlinePlayers()) { online.showPlayer(player); player.showPlayer(online); } }
Example 2
Source File: MatchPlayer.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
public void refreshVisibility() { final Player bukkit = getBukkit(); bukkit.showInvisibles(isObserving()); for(MatchPlayer other : match.getPlayers()) { if(canSee(other)) { bukkit.showPlayer(other.getBukkit()); } else { bukkit.hidePlayer(other.getBukkit()); } if(other.canSee(this)) { other.getBukkit().showPlayer(bukkit); } else { other.getBukkit().hidePlayer(bukkit); } } }
Example 3
Source File: EffPlayerVisibility.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override protected void execute(Event e) { Player[] targets = targetPlayers == null ? Bukkit.getOnlinePlayers().toArray(new Player[0]) : targetPlayers.getArray(e); for (Player targetPlayer : targets) { for (Player player : players.getArray(e)) { if (reveal) { if (USE_DEPRECATED_METHOD) targetPlayer.showPlayer(player); else targetPlayer.showPlayer(Skript.getInstance(), player); } else { if (USE_DEPRECATED_METHOD) targetPlayer.hidePlayer(player); else targetPlayer.hidePlayer(Skript.getInstance(), player); } } } }
Example 4
Source File: Game.java From Survival-Games with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") public void removeSpectator(Player p) { ArrayList < Player > players = new ArrayList < Player > (); players.addAll(activePlayers); players.addAll(inactivePlayers); if(p.isOnline()){ for (Player pl: Bukkit.getOnlinePlayers()) { pl.showPlayer(p); } } restoreInv(p); p.setAllowFlight(false); p.setFlying(false); p.setFallDistance(0); p.setHealth(p.getMaxHealth()); p.setFoodLevel(20); p.setSaturation(20); p.teleport(SettingsManager.getInstance().getLobbySpawn()); // Bukkit.getServer().broadcastPrefixType("Removing Spec "+p.getName()+" "+spectators.size()+" left"); spectators.remove(p.getName()); // Bukkit.getServer().broadcastPrefixType("Removed"); nextspec.remove(p); }
Example 5
Source File: MatchPlayerImpl.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@Override public void resetVisibility() { final Player bukkit = getBukkit(); bukkit.showInvisibles(isObserving()); for (MatchPlayer other : getMatch().getPlayers()) { if (canSee(other)) { bukkit.showPlayer(other.getBukkit()); } else { bukkit.hidePlayer(other.getBukkit()); } if (other.canSee(this)) { other.getBukkit().showPlayer(getBukkit()); } else { other.getBukkit().hidePlayer(getBukkit()); } } }
Example 6
Source File: Visibility.java From CardinalPGM with MIT License | 6 votes |
private void resetVisibility(Player viewer, Player toSee, Optional<TeamModule> newTeam) { if (viewer.equals(toSee)) return; try { boolean showObs = Settings.getSettingByName("Observers") == null || !Settings.getSettingByName("Observers").getValueByPlayer(viewer).getValue().equalsIgnoreCase("none"); if (match.isRunning()) { if (ObserverModule.testDead(toSee)) { setVisibility(viewer, toSee, false); } else if (ObserverModule.testObserver(viewer)) { setVisibility(viewer, toSee, !(newTeam.isPresent() && newTeam.get().isObserver() && !showObs)); } else { setVisibility(viewer, toSee, !(newTeam.isPresent() && newTeam.get().isObserver())); } } else { setVisibility(viewer, toSee, showObs); } } catch (NullPointerException e) { viewer.showPlayer(toSee); } }
Example 7
Source File: BukkitPlayerHidingUtil.java From SuperVanish with Mozilla Public License 2.0 | 5 votes |
public static void showPlayer(Player player, Player viewer, SuperVanish plugin) { if (isNewPlayerHidingAPISupported(viewer)) viewer.showPlayer(plugin, player); else //noinspection deprecation viewer.showPlayer(player); }
Example 8
Source File: FlagInvisibleSpectate.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onPlayerLeaveGame(PlayerLeaveGameEvent event) { SpleefPlayer player = event.getPlayer(); Player bukkitPlayer = player.getBukkitPlayer(); FlagSpectate flag = (FlagSpectate) getParent(); for (SpleefPlayer spectating : flag.getSpectators()) { if (bukkitPlayer.canSee(spectating.getBukkitPlayer())) { continue; } bukkitPlayer.showPlayer(spectating.getBukkitPlayer()); } }
Example 9
Source File: PlayerStateHolder.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
/** * Applies the default state to the player * and discards the current one<br><br> * * Warning: This deletes the entire inventory * and all other various player attributes * * It is recommended to save the player state * with {@link PlayerStateHolder#create(Player, GameMode)} * and store a reference to it before invoking this method * * @param player */ public static void applyDefaultState(Player player, boolean adventureMode) { player.setGameMode(adventureMode ? GameMode.ADVENTURE : GameMode.SURVIVAL); player.getInventory().clear(); player.getInventory().setArmorContents(new ItemStack[4]); player.setItemOnCursor(null); player.updateInventory(); player.setMaxHealth(20.0); player.setHealth(20.0); player.setFoodLevel(20); player.setLevel(0); player.setExp(0f); player.setAllowFlight(false); player.setFlying(false); player.setFallDistance(0); player.setFireTicks(0); Collection<PotionEffect> effects = player.getActivePotionEffects(); for (PotionEffect effect : effects) { player.removePotionEffect(effect.getType()); } for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { if (player.canSee(player)) { continue; } player.showPlayer(onlinePlayer); } }
Example 10
Source File: Visibility.java From CardinalPGM with MIT License | 5 votes |
private void setVisibility(final Player viewer, final Player toSee, boolean shouldSee) { if (shouldSee) { viewer.showPlayer(toSee); } else { viewer.hidePlayer(toSee); } }
Example 11
Source File: Visibility.java From CardinalPGM with MIT License | 5 votes |
@Override public void unload() { HandlerList.unregisterAll(this); for (Player player : Bukkit.getOnlinePlayers()) { for (Player otherPlayer : Bukkit.getOnlinePlayers()) { player.showPlayer(otherPlayer); } } }
Example 12
Source File: SkinApplier.java From ChangeSkin with MIT License | 5 votes |
@SuppressWarnings("deprecation") private void hideAndShow(Player other) { //removes the entity and display the new skin if (NEW_HIDE_METHOD_AVAILABLE) { other.hidePlayer(plugin, receiver); other.showPlayer(plugin, receiver); } else { other.hidePlayer(receiver); other.showPlayer(receiver); } }
Example 13
Source File: VanishHandler.java From StaffPlus with GNU General Public License v3.0 | 5 votes |
private void unapplyVanish(Player player, VanishType vanishType, boolean shouldMessage) { String message = ""; switch(vanishType) { case TOTAL: for(Player p : Bukkit.getOnlinePlayers()) { p.showPlayer(player); } player.removePotionEffect(PotionEffectType.INVISIBILITY); message = messages.totalVanish.replace("%status%", "disabled"); break; case LIST: versionProtocol.listVanish(player, false); message = messages.listVanish.replace("%status%", "disabled"); break; default: break; } if(shouldMessage && !message.isEmpty()) { this.message.send(player, message, messages.prefixGeneral); } }
Example 14
Source File: ShadowDive.java From MineTinker with GNU General Public License v3.0 | 5 votes |
private void showPlayer(Player p) { if (activePlayers.remove(p)) { for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (!p.equals(player)) player.showPlayer(MineTinker.getPlugin(), p); } } }
Example 15
Source File: ShadowDive.java From MineTinker with GNU General Public License v3.0 | 5 votes |
@Override public void run() { Iterator<Player> iterator = activePlayers.iterator(); //noinspection WhileLoopReplaceableByForEach while (iterator.hasNext()) { Player p = iterator.next(); Location loc = p.getLocation(); byte lightlevel = p.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()).getLightLevel(); if (!p.isSneaking() || lightlevel > requiredLightLevel || p.hasPotionEffect(PotionEffectType.GLOWING)) { showPlayer(p); ChatWriter.sendActionBar(p, ChatColor.RED + ShadowDive.instance().getName() + ": " + LanguageManager.getString("Modifier.Shadow-Dive.LightToHigh", p)); } else if (PlayerInfo.isCombatTagged(p)) { showPlayer(p); ChatWriter.sendActionBar(p, ChatColor.RED + ShadowDive.instance().getName() + ": " + LanguageManager.getString("Modifier.Shadow-Dive.InCombat", p)); } else { for(Player pl : Bukkit.getOnlinePlayers()) { if (pl.equals(p)) continue; if (pl.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { pl.showPlayer(MineTinker.getPlugin(), p); } else { pl.hidePlayer(MineTinker.getPlugin(), p); } } } } }
Example 16
Source File: SingleGameCycle.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
private void kickPlayer(Player player, boolean wasSpectator) { for (Player freePlayer : this.getGame().getFreePlayers()) { player.showPlayer(freePlayer); } if (wasSpectator && this.getGame().isFull()) { this.getGame().playerLeave(player, false); return; } if (BedwarsRel.getInstance().toMainLobby()) { if (BedwarsRel.getInstance().allPlayersBackToMainLobby()) { this.getGame().playerLeave(player, false); return; } else { player.teleport(this.getGame().getLobby()); } } else { player.teleport(this.getGame().getLobby()); } if (BedwarsRel.getInstance().isHologramsEnabled() && BedwarsRel.getInstance().getHolographicInteractor() != null && this.getGame().getLobby() == player.getWorld()) { BedwarsRel.getInstance().getHolographicInteractor().updateHolograms(player); } if (BedwarsRel.getInstance().statisticsEnabled()) { PlayerStatistic statistic = BedwarsRel.getInstance().getPlayerStatisticManager().getStatistic(player); BedwarsRel.getInstance().getPlayerStatisticManager().storeStatistic(statistic); if (BedwarsRel.getInstance().getBooleanConfig("statistics.show-on-game-end", true)) { BedwarsRel.getInstance().getServer().dispatchCommand(player, "bw stats"); } } this.getGame().setPlayerDamager(player, null); PlayerStorage storage = this.getGame().getPlayerStorage(player); storage.clean(); storage.loadLobbyInventory(this.getGame()); }
Example 17
Source File: PerWorldPlayerlist.java From TAB with Apache License 2.0 | 4 votes |
@Override public void unload(){ for (Player p : Main.instance.getOnlinePlayers()) for (Player pl : Main.instance.getOnlinePlayers()) p.showPlayer(pl); }