public void addPlayerToGame(PropHunt plugin, Player p) { if (p == null || !p.isOnline()) { return; } if (GameManager.seekers.contains(p.getName())) { Scoreboard sb = plugin.getServer().getScoreboardManager().getNewScoreboard(); Objective ob = sb.registerNewObjective("seekerboard", "dummy"); ob.setDisplaySlot(DisplaySlot.SIDEBAR); ob.setDisplayName(ChatColor.GOLD + "PropHunt Stats"); Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); p.setScoreboard(sb); playerBoards.put(p, sb); } if (GameManager.hiders.contains(p.getName())) { Scoreboard sb = plugin.getServer().getScoreboardManager().getNewScoreboard(); Objective ob = sb.registerNewObjective("hiderboard", "dummy"); ob.setDisplaySlot(DisplaySlot.SIDEBAR); ob.setDisplayName( ChatColor.AQUA + DisguiseManager.parseDisguiseToName(PropHunt.dc.getDisguise(p))); Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); p.setScoreboard(sb); playerBoards.put(p, sb); } }
public static boolean unrankedSidebarDisplay(Player p, String[] elements) { elements = cutUnranked(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 true; } catch (Exception e) { e.printStackTrace(); return false; } }
void clearFromBoard(OfflinePlayer player) { if (safeTimeObjective || healthObjective) { if (player instanceof Player) ((Player) player).setScoreboard(getServer().getScoreboardManager().getNewScoreboard()); scoreboard.getBoard().resetScores(player); } }
public static void setVotingScoreboard(int counter) { Objective layer = votingBoard.getObjective("voting"); if (layer == null) { layer = votingBoard.registerNewObjective("voting", "dummy"); } layer.setDisplaySlot(DisplaySlot.SIDEBAR); layer.setDisplayName( "§3MasterBuilders §8| §a" + String.format("%02d:%02d", counter / 60, counter % 60)); layer.getScore("§6--------------").setScore(9); layer.getScore("§c ").setScore(8); layer.getScore("§6Thema:").setScore(7); layer.getScore("§a" + GameUtils.word).setScore(6); layer.getScore("§b ").setScore(5); layer.getScore("§6Erbauer:").setScore(4); layer.getScore("§a*****").setScore(3); layer.getScore("§a ").setScore(2); layer.getScore("§c§6--------------").setScore(1); for (Player p : Bukkit.getOnlinePlayers()) { p.setScoreboard(votingBoard); } }
public void setBoard(Player player, int time) { this.objective.setDisplaySlot(DisplaySlot.SIDEBAR); this.objective.setDisplayName("TNT Tag"); Score money = this.objective.getScore("Players:"); money.setScore(this.players.size()); Score Tags = this.objective.getScore("Time:"); Tags.setScore(time); player.setScoreboard(this.board); }
public void removeScoreboard(PropHunt plugin, Player p) { if (p == null) { return; } if (!p.isOnline()) { return; } if (playerBoards.containsKey(p)) { playerBoards.remove(p); p.setScoreboard(plugin.getServer().getScoreboardManager().getNewScoreboard()); } }
public void updateTab(Player p) { p.setScoreboard(this.scoreboard); for (String configstring : assignedTeams.keySet()) { if (p.hasPermission("rank.assign." + configstring)) { String toStringTeam = assignedTeams.get(configstring); Team team = scoreboard.getTeam("player" + getConfig().getString("rank." + toStringTeam + ".order")); team.addPlayer(p.getPlayer()); break; } } }
private void colorPlayer(Player player, ChatColor color) { uncolorPlayer(player); playerColors.put(player.getUniqueId(), color); player.setDisplayName(color + player.getName() + ChatColor.RESET); Team team = scoreboard.registerNewTeam(player.getName()); team.setDisplayName(player.getName()); team.setPrefix(color.toString()); team.setSuffix(ChatColor.RESET.toString()); team.addEntry(player.getName()); player.setScoreboard(scoreboard); }
public void scoreboard() { boardClass.setDisplaySlot(DisplaySlot.SIDEBAR); Score rank = boardClass.getScore(ChatColor.GREEN + "Rank:"); Score power = boardClass.getScore(ChatColor.GOLD + "Power:"); rank.setScore(userSkillClass.getRank()); power.setScore(userSkillClass.getPower()); Score[] score = new Score[userSkillClass.getSkillClass().getSkills().size()]; for (int i = 0; i < userSkillClass.getSkillClass().getSkills().size(); i++) { Skill skill = userSkillClass.getSkillClass().getSkills().get(i); score[i] = boardClass.getScore(ChatColor.GREEN + skill.getScoreboardName() + ":"); score[i].setScore(userSkillClass.getLevel(skill)); } player.setScoreboard(board); }
public static boolean unrankedSidebarDisplay( Collection<Player> players, String[] elements, Scoreboard board) { try { String objName = "COLLAB-SB-WINTER"; if (board == null) board = Bukkit.getScoreboardManager().getNewScoreboard(); elements = cutUnranked(elements); for (Player player : players) if (player.getScoreboard() != board) player.setScoreboard(board); if (board.getObjective(objName) == null) { board.registerNewObjective(objName, "dummy"); board.getObjective(objName).setDisplaySlot(DisplaySlot.SIDEBAR); } board.getObjective(DisplaySlot.SIDEBAR).setDisplayName(elements[0]); for (int i = 1; i < elements.length; i++) if (elements[i] != null && board.getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).getScore() != 16 - i) { board.getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).setScore(16 - i); for (String string : board.getEntries()) if (board.getObjective(objName).getScore(string).getScore() == 16 - i) if (!string.equals(elements[i])) board.resetScores(string); } for (String entry : board.getEntries()) { boolean toErase = true; for (String element : elements) { if (element != null && element.equals(entry) && board.getObjective(objName).getScore(entry).getScore() == 16 - Arrays.asList(elements).indexOf(element)) { toErase = false; break; } } if (toErase) board.resetScores(entry); } return true; } catch (Exception e) { e.printStackTrace(); return false; } }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender instanceof Player) { Player player = (Player) sender; if (args.length > 0) { switch (args[0]) { case "join": player.teleport(plugin.getActiveArena().getTeleportLocation()); break; case "start": if (player.hasPermission("hexigames.admin")) { if (Objects.equals(plugin.getActiveArena(), plugin.getLobby())) { plugin.getLobby().startNextGame(); } } break; case "stop": if (player.hasPermission("hexigames.admin")) { plugin.returnToLobby(); } break; case "reload": if (player.hasPermission("hexigames.admin")) { plugin.reload(); } break; case "poo": Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objective = scoreboard.registerNewObjective("tester", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName("narnar"); player.setScoreboard(scoreboard); break; default: break; } } } return true; }
@EventHandler public void onPlayerJoin(PlayerJoinEvent e) { FileConfiguration locationsFile = YamlConfiguration.loadConfiguration(Main.getInstance().locations); Player p = e.getPlayer(); SPlayer player = new SPlayer(p); int blue = Team.BLUE.getPlayers().size(); int red = Team.RED.getPlayers().size(); p.teleport(locationUtil.deserializeLoc(locationsFile.getString("arena.lobby"))); gameManager.setCarrying(p, 0); Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard(); org.bukkit.scoreboard.Team r = sb.registerNewTeam("red"); r.setPrefix(Color.np("&c")); org.bukkit.scoreboard.Team b = sb.registerNewTeam("blue"); b.setPrefix(Color.np("&b")); for (Player online : Bukkit.getOnlinePlayers()) { Team team = teamManager.getTeam(online); if (team == Team.BLUE) { b.addEntry(online.getName()); } else { r.addEntry(online.getName()); } } p.setScoreboard(sb); e.setJoinMessage(null); if (blue <= red) { player.setTeam(Team.BLUE); } else { player.setTeam(Team.RED); } }
public static boolean rankedSidebarDisplay( Player p, String title, HashMap<String, Integer> elements) { try { title = cutRankedTitle(title); elements = cutRanked(elements); 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(title); for (String string : elements.keySet()) if (p.getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(string).getScore() != elements.get(string)) p.getScoreboard() .getObjective(DisplaySlot.SIDEBAR) .getScore(string) .setScore(elements.get(string)); for (String string : new ArrayList<>(p.getScoreboard().getEntries())) if (!elements.keySet().contains(string)) p.getScoreboard().resetScores(string); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
public static boolean rankedSidebarDisplay( Collection<Player> players, String title, HashMap<String, Integer> elements, Scoreboard board) { try { title = cutRankedTitle(title); elements = cutRanked(elements); String objName = "COLLAB-SB-WINTER"; if (board == null) board = Bukkit.getScoreboardManager().getNewScoreboard(); for (Player player : players) if (player.getScoreboard() != board) player.setScoreboard(board); if (board.getObjective(objName) == null) { board.registerNewObjective(objName, "dummy"); board.getObjective(objName).setDisplaySlot(DisplaySlot.SIDEBAR); } board.getObjective(DisplaySlot.SIDEBAR).setDisplayName(title); for (String string : elements.keySet()) if (board.getObjective(DisplaySlot.SIDEBAR).getScore(string).getScore() != elements.get(string)) board.getObjective(DisplaySlot.SIDEBAR).getScore(string).setScore(elements.get(string)); for (String string : new ArrayList<>(board.getEntries())) if (!elements.keySet().contains(string)) board.resetScores(string); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
public void removePlayer(Player player) { player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); }
public void removeBoard(Player player) { player.setScoreboard(this.manager.getNewScoreboard()); }
public void send(Player pl) { pl.setScoreboard(scoreboard); }
private void addToBoard(Player p) { if (healthObjective || safeTimeObjective) p.setScoreboard(scoreboard.getBoard()); }
public void removePlayer(Player p) { for (String tn : getPartyMembers()) { if (Bukkit.getPlayer(tn) == null) { continue; } Player t = Bukkit.getPlayer(tn); String name = getPlayerName(p); if (name.length() > 16) name = name.substring(0, 16); ScoreboardMechanics.getBoard(t).resetScores(Bukkit.getOfflinePlayer(name)); } Objective o = ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR); if (o != null) o.unregister(); players.remove(p.getName()); PartyMechanics.party_map.remove(p.getName()); PartyMechanics.party_only.remove(p.getName()); KarmaMechanics.sendAlignColor(p, p); if (ScoreboardMechanics.getBoard(p) != null && ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR) != null) { ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR).unregister(); } InstanceMechanics.teleport_on_load.remove(p.getName()); if (InstanceMechanics.saved_location_instance.containsKey(p.getName())) { // Inside an instance. p.teleport(InstanceMechanics.saved_location_instance.get(p.getName())); InstanceMechanics.saved_location_instance.remove(p.getName()); } InstanceMechanics.removeFromInstanceParty(p.getName()); if (p.getName().equalsIgnoreCase(leader.getName()) && getPartyMembers().size() > 0) { String new_leader = ""; int size_mod = 1; if (getPartyMembers().size() <= 1) { size_mod = 0; } int party_index = new Random().nextInt(getPartyMembers().size() - size_mod); List<String> remaining_members = new ArrayList<String>(); for (String s : getPartyMembers()) { if (s.equalsIgnoreCase(p.getName())) { continue; } remaining_members.add(s); } leader = Bukkit.getPlayer(remaining_members.get(party_index)); for (String x : getPartyMembers()) { if (Bukkit.getPlayer(x) == null) continue; ScoreboardMechanics.getBoard(Bukkit.getPlayer(x)).resetScores(leader); } // TODO MOVES THIS for (String s : remaining_members) { if (Bukkit.getPlayer(s) != null) { Player pty_mem = Bukkit.getPlayer(s); if (!(pty_mem.getScoreboard().getPlayers().contains(Bukkit.getOfflinePlayer(s)))) { pty_mem.setScoreboard(Bukkit.getPlayer(s).getScoreboard()); } /* * if(!new_ui.hasPlayerAdded(pty_mem)){ * new_ui.showToPlayer(pty_mem); } */ pty_mem.sendMessage( ChatColor.LIGHT_PURPLE.toString() + "<" + ChatColor.BOLD + "P" + ChatColor.LIGHT_PURPLE + ">" + ChatColor.GRAY + " " + p.getName() + ChatColor.GRAY.toString() + " has " + ChatColor.LIGHT_PURPLE + ChatColor.UNDERLINE + "left" + ChatColor.GRAY.toString() + " your party."); pty_mem.sendMessage( ChatColor.LIGHT_PURPLE.toString() + "<" + ChatColor.BOLD + "P" + ChatColor.LIGHT_PURPLE + "> " + ChatColor.GRAY + ChatColor.LIGHT_PURPLE.toString() + new_leader + ChatColor.GRAY.toString() + " has been promoted to " + ChatColor.UNDERLINE + "Party Leader"); } } } else { for (String s : getPartyMembers()) { if (Bukkit.getPlayer(s) != null && s != p.getName()) { Player pty_mem = Bukkit.getPlayer(s); pty_mem.sendMessage( ChatColor.LIGHT_PURPLE.toString() + "<" + ChatColor.BOLD + "P" + ChatColor.LIGHT_PURPLE + ">" + ChatColor.GRAY + " " + p.getName() + ChatColor.GRAY.toString() + " has " + ChatColor.RED + ChatColor.UNDERLINE + "left" + ChatColor.GRAY.toString() + " your party."); } } } if (!Hive.pending_upload.contains(p.getName())) { HealthMechanics.setOverheadHP(p, HealthMechanics.getPlayerHP(p.getName())); } }
public void addPlayer(Player player) { player.setScoreboard(this.scoreboard); Objective score = this.scoreboard.getObjective("score"); score.getScore(player.getName()).setScore(PlayerScore.getPlayer(player).getScore()); }