Java Code Examples for org.bukkit.entity.Player#setScoreboard()
The following examples show how to use
org.bukkit.entity.Player#setScoreboard() .
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: Assemble.java From Assemble with GNU General Public License v3.0 | 6 votes |
public void cleanup() { if (this.thread != null) { this.thread.stop(); this.thread = null; } if (listeners != null) { HandlerList.unregisterAll(listeners); listeners = null; } for (UUID uuid : getBoards().keySet()) { Player player = Bukkit.getPlayer(uuid); if (player == null || !player.isOnline()) { continue; } getBoards().remove(uuid); player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } }
Example 2
Source File: GScoreboard.java From GlobalWarming with GNU Lesser General Public License v3.0 | 6 votes |
/** * Connect the player to the scoreboard * - Disconnects from any existing scoreboards * - Creates a new scoreboard for the world if required */ public void connect(GPlayer gPlayer) { if (gPlayer != null && isEnabled) { //Disconnect the player from the current scoreboard (if required): disconnect(gPlayer); //Connect online players to their associated-world scoreboards: Player onlinePlayer = gPlayer.getOnlinePlayer(); if (onlinePlayer != null) { Scoreboard scoreboard = getScoreboard(gPlayer); onlinePlayer.setScoreboard(scoreboard); Team team = scoreboard.registerNewTeam(onlinePlayer.getName()); team.addEntry(onlinePlayer.getName()); update(gPlayer); } } }
Example 3
Source File: Scoreboards.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Puts a player into a team of their own and sets the team suffix to be the level * @param playerUUID - the player's UUID */ public void setLevel(UUID playerUUID) { Player player = plugin.getServer().getPlayer(playerUUID); if (player == null) { // Player is offline... return; } // The default team name is their own name String teamName = player.getName(); String level = String.valueOf(plugin.getPlayers().getIslandLevel(playerUUID)); Team team = board.getTeam(teamName); if (team == null) { //Team does not exist team = board.registerNewTeam(teamName); } // Add the suffix team.setSuffix(Settings.teamSuffix.replace("[level]",String.valueOf(level))); //Adding player to team team.addPlayer(player); // Assign scoreboard to player player.setScoreboard(board); }
Example 4
Source File: Scoreboards.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Sets the player's level explicitly * @param playerUUID - the player's UUID * @param l */ public void setLevel(UUID playerUUID, long l) { Player player = plugin.getServer().getPlayer(playerUUID); if (player == null) { // Player is offline... return; } // The default team name is their own name - must be 16 chars or less String teamName = player.getName(); Team team = board.getTeam(teamName); if (team == null) { //Team does not exist team = board.registerNewTeam(teamName); } // Add the suffix team.setSuffix(Settings.teamSuffix.replace("[level]",String.valueOf(l))); //Adding player to team team.addPlayer(player); // Assign scoreboard to player player.setScoreboard(board); }
Example 5
Source File: ScoreBoardManager.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
public void removeScoreboard(Player player) { UUID uuid = player.getUniqueId(); CustomScoreBoard customScoreBoard = this.customScoreBoardMap.remove(uuid); if(customScoreBoard == null) return; customScoreBoard.disableScoreboard(); if(shouldSavePrevious() && this.previousScoreboardMap.containsKey(uuid)) { Scoreboard previousScoreboard = this.previousScoreboardMap.get(uuid); if(previousScoreboard == null) return; Objective objective = previousScoreboard.getObjective("combatlogx"); if(objective != null) return; player.setScoreboard(previousScoreboard); } }
Example 6
Source File: Resident.java From civcraft with GNU General Public License v2.0 | 5 votes |
public void showScoreboard() { if (this.scoreboard != null) { Player player; try { player = CivGlobal.getPlayer(this); player.setScoreboard(this.scoreboard); } catch (CivException e) { e.printStackTrace(); } } }
Example 7
Source File: AssembleBoard.java From Assemble with GNU General Public License v3.0 | 5 votes |
private void setup(Player player) { Scoreboard scoreboard = getScoreboard(); player.setScoreboard(scoreboard); getObjective(); //Send Update AssembleBoardCreatedEvent createdEvent = new AssembleBoardCreatedEvent(this); Bukkit.getPluginManager().callEvent(createdEvent); }
Example 8
Source File: MatchManager.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private void preparePlayer(Player player, GameMap gameMap) { if (debug) { Util.get().logToFile(debugName + ChatColor.YELLOW + "Preparing " + player.getName() + " for SkyWars"); } player.setFoodLevel(20); player.setSaturation(20); player.setHealth(20.0); player.setExp(0.0f); player.setLevel(0); player.setScoreboard(SkyWarsReloaded.get().getServer().getScoreboardManager().getNewScoreboard()); player.setScoreboard(gameMap.getGameBoard().getScoreboard()); Util.get().clear(player); player.getInventory().setBoots(new ItemStack(Material.AIR, 1)); player.getInventory().setChestplate(new ItemStack(Material.AIR, 1)); player.getInventory().setHelmet(new ItemStack(Material.AIR, 1)); player.getInventory().setLeggings(new ItemStack(Material.AIR, 1)); if (SkyWarsReloaded.getCfg().areKitsEnabled()) { ItemStack kitItem = SkyWarsReloaded.getIM().getItem("kitvote"); player.getInventory().setItem(SkyWarsReloaded.getCfg().getKitVotePos(), kitItem); } if (SkyWarsReloaded.getCfg().votingEnabled()) { ItemStack timeItem = SkyWarsReloaded.getIM().getItem("votingItem"); player.getInventory().setItem(SkyWarsReloaded.getCfg().getVotingPos(), timeItem); } ItemStack exitItem = SkyWarsReloaded.getIM().getItem("exitGameItem"); player.getInventory().setItem(SkyWarsReloaded.getCfg().getExitPos(), exitItem); if (debug) { Util.get().logToFile(debugName + ChatColor.YELLOW + "Finished Preparing " + player.getName() + " for SkyWars on map " + gameMap.getName()); } }
Example 9
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
private void updateScoreboardTimer() { Objective obj = this.scoreboard.getObjective("display"); if (obj == null) { obj = this.scoreboard.registerNewObjective("display", "dummy"); } obj.setDisplayName(this.formatScoreboardTitle()); for (Player player : this.getPlayers()) { player.setScoreboard(this.scoreboard); } }
Example 10
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public void updateScoreboard() { if (this.state == GameState.WAITING && BedwarsRel.getInstance().getBooleanConfig("lobby-scoreboard.enabled", true)) { this.updateLobbyScoreboard(); return; } Objective obj = this.scoreboard.getObjective("display"); if (obj == null) { obj = this.scoreboard.registerNewObjective("display", "dummy"); } obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(this.formatScoreboardTitle()); for (Team t : this.teams.values()) { this.scoreboard.resetScores(this.formatScoreboardTeam(t, false)); this.scoreboard.resetScores(this.formatScoreboardTeam(t, true)); boolean teamDead = (t.isDead(this) && this.getState() == GameState.RUNNING) ? true : false; Score score = obj.getScore(this.formatScoreboardTeam(t, teamDead)); score.setScore(t.getPlayers().size()); } for (Player player : this.getPlayers()) { player.setScoreboard(this.scoreboard); } }
Example 11
Source File: Core.java From skRayFall with GNU General Public License v3.0 | 5 votes |
/** * Generates a new private scoreboard for the player when they join the server if * enableFastScoreboards is set to true. * * @param evt The Player Join Event */ @EventHandler public void onJoinScoreboards(PlayerJoinEvent evt) { if (enableFastScoreboards) { Player player = evt.getPlayer(); ScoreboardManager manager = Bukkit.getScoreboardManager(); Scoreboard board = manager.getNewScoreboard(); player.setScoreboard(board); } }
Example 12
Source File: TagUtils.java From TabooLib with MIT License | 5 votes |
public static Scoreboard getScoreboardComputeIfAbsent(Player player) { Scoreboard scoreboard = player.getScoreboard(); if (scoreboard == null) { player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } return player.getScoreboard(); }
Example 13
Source File: UHPlugin.java From KTP with GNU General Public License v3.0 | 4 votes |
public void updatePlayerListName(Player p) { p.setScoreboard(sb); Integer he = (int) Math.round(p.getHealth()); sb.getObjective("Vie").getScore(p).setScore(he); }
Example 14
Source File: CustomScoreBoard.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
public void enableScoreboard() { Player player = getPlayer(); if(player == null) return; player.setScoreboard(this.scoreboard); }
Example 15
Source File: UHPlugin.java From KTP with GNU General Public License v3.0 | 4 votes |
public void setLife(Player entity, int i) { entity.setScoreboard(sb); sb.getObjective("Vie").getScore(entity).setScore(i); }
Example 16
Source File: UHPlugin.java From KTP with GNU General Public License v3.0 | 4 votes |
public void addToScoreboard(Player player) { player.setScoreboard(sb); sb.getObjective("Vie").getScore(player).setScore(0); this.updatePlayerListName(player); }
Example 17
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); } } } }
Example 18
Source File: Scoreboards.java From TabooLib with MIT License | 4 votes |
public static Scoreboard display(Player p, String... elements) { elements = fixLines(elements); try { if (p.getScoreboard() == null || p.getScoreboard() == Bukkit.getScoreboardManager().getMainScoreboard() || p.getScoreboard().getObjectives().size() != 1) { p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } if (p.getScoreboard().getObjective(p.getUniqueId().toString().substring(0, 16)) == null) { p.getScoreboard().registerNewObjective(p.getUniqueId().toString().substring(0, 16), "dummy"); p.getScoreboard().getObjective(p.getUniqueId().toString().substring(0, 16)).setDisplaySlot(DisplaySlot.SIDEBAR); } p.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(elements[0]); for (int i = 1; i < elements.length; i++) { if (elements[i] != null) { if (p.getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).getScore() != 16 - i) { p.getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).setScore(16 - i); for (String string : p.getScoreboard().getEntries()) { if (p.getScoreboard().getObjective(p.getUniqueId().toString().substring(0, 16)).getScore(string).getScore() == 16 - i) { if (!string.equals(elements[i])) { p.getScoreboard().resetScores(string); } } } } } } for (String entry : p.getScoreboard().getEntries()) { boolean toErase = true; for (String element : elements) { if (element != null && element.equals(entry) && p.getScoreboard().getObjective(p.getUniqueId().toString().substring(0, 16)).getScore(entry).getScore() == 16 - Arrays.asList(elements).indexOf(element)) { toErase = false; break; } } if (toErase) { p.getScoreboard().resetScores(entry); } } return p.getScoreboard(); } catch (Exception e) { return null; } }
Example 19
Source File: LoginListener.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); //adding player plugin.getPlayerManager().addIfNotExists(player); final NovaPlayer nPlayer = PlayerManager.getPlayer(player); //Send version message if there's an update if(VersionUtils.isUpdateAvailable() && Permission.NOVAGUILDS_ADMIN_UPDATEAVAILABLE.has(player)) { Message.CHAT_UPDATE.send(player); } //Schedule region check NovaGuilds.runTask(new Runnable() { @Override public void run() { plugin.getRegionManager().checkAtRegionChange(nPlayer); } }); if(nPlayer.hasGuild()) { for(Player onlinePlayer : CompatibilityUtils.getOnlinePlayers()) { NovaPlayer onlineNPlayer = PlayerManager.getPlayer(onlinePlayer); if(onlineNPlayer.equals(nPlayer) || !onlineNPlayer.isAtRegion() || !onlineNPlayer.getAtRegion().getGuild().equals(nPlayer.getGuild())) { continue; } plugin.getRegionManager().checkRaidInit(onlineNPlayer); } //Show bank hologram nPlayer.getGuild().showVaultHologram(player); } //TabAPI if(Config.TAGAPI_ENABLED.getBoolean()) { if(player.getScoreboard() == null || player.getScoreboard() == Bukkit.getScoreboardManager().getMainScoreboard()) { player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } TagUtils.refresh(); } //PacketExtension if(plugin.getPacketExtension() != null) { plugin.getPacketExtension().registerPlayer(player); } //Tab if(Config.TABLIST_ENABLED.getBoolean()) { nPlayer.setTabList(plugin.createTabList(nPlayer)); TabUtils.refresh(nPlayer); } //Guild inactive time if(nPlayer.hasGuild()) { nPlayer.getGuild().updateInactiveTime(); } BossBarUtils.removeBar(player); }
Example 20
Source File: CloudServer.java From CloudNet with Apache License 2.0 | 4 votes |
private void initScoreboard(Player all) { if (all.getScoreboard() == null) { all.setScoreboard(all.getServer().getScoreboardManager().getNewScoreboard()); } }