Created
September 7, 2018 07:50
-
-
Save masecla22/86fba61e131ac1b1b4cd0753cb0e5118 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void update(Player who) { | |
LiteBoardAPI.toggleScoreboard(who, false); | |
List<String> scoreboardLines = new ArrayList<String>(); | |
List<String> ltr = new ArrayList<String>(); | |
List<Player> players = getOrderedPlayers(); | |
// Generate the lines from the config | |
for (int i = 1; i <= 15; i++) { | |
scoreboardLines | |
.add(globals.mains.getConfig().getString("scoreboard.lines.line" + Integer.toString(i) + "-text")); | |
} | |
for (int i = 0; i < scoreboardLines.size(); i++) { | |
scoreboardLines.set(i, ChatColor.translateAlternateColorCodes('&', scoreboardLines.get(i))); | |
if (scoreboardLines.get(i).contains("EMPTY_LINE")) { | |
scoreboardLines.set(i, generateSpaces(i)); | |
} | |
if (scoreboardLines.get(i).contains("HIDDEN_LINE")) { | |
ltr.add(scoreboardLines.get(i)); | |
} | |
if (players.size() == 1) { | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%first_player%", players.get(0).getName())); | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%second_player%", "N/A")); | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%third_player%", "N/A")); | |
} | |
if (players.size() == 2) { | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%first_player%", players.get(0).getName())); | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%second_player%", players.get(1).getName())); | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%third_player%", "N/A")); | |
} | |
if (players.size() >= 3) { | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%first_player%", players.get(0).getName())); | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%second_player%", players.get(1).getName())); | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%third_player%", players.get(2).getName())); | |
} | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%arrows_hit%", | |
Integer.toString(getInGameArrowsHit(players.get(0))) + generateSpaces(4))); | |
scoreboardLines.set(i, scoreboardLines.get(i).replace("%arrows_shot%", | |
Integer.toString(getInGameArrowsShot(players.get(0))) + generateSpaces(2))); | |
scoreboardLines.set(i, | |
scoreboardLines.get(i).replace("%arrows_missed%", | |
Integer.toString(getInGameArrowsShot(players.get(0)) - getInGameArrowsHit(players.get(0))) | |
+ generateSpaces(1))); | |
} | |
for (String f : ltr) { | |
scoreboardLines.remove(f); | |
} | |
boolean ok = false; | |
if(globals.sbs.containsKey(who)){ | |
globals.sbs.get(who).getObjective(who.getUniqueId().toString().substring(0,8)).unregister(); | |
} else{ | |
globals.sbs.put(who, globals.sbm.getNewScoreboard()); | |
ok=true; | |
} | |
who.setScoreboard(globals.sbs.get(who)); | |
Objective obj = globals.sbs.get(who).registerNewObjective(who.getUniqueId().toString().substring(0,8), "dummy", "LOVE"); | |
obj.setDisplaySlot(DisplaySlot.SIDEBAR); | |
Score[] scores = new Score[scoreboardLines.size()]; | |
int f = scoreboardLines.size(); | |
for (int i = 0; i < scoreboardLines.size(); i++) { | |
scores[i] = obj.getScore(scoreboardLines.get(i)); | |
scores[i].setScore(f); | |
f--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment