mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-08 16:56:25 +00:00
Cleanup
This commit is contained in:
@@ -79,47 +79,47 @@ public class Board {
|
||||
|
||||
public void update() {
|
||||
// Checking if we are ready to start updating the Scoreboard.
|
||||
if (!ready) {
|
||||
if(!ready) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Making sure the player is connected.
|
||||
if (!player.isOnline()) {
|
||||
if(!player.isOnline()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Making sure the Scoreboard Provider is set.
|
||||
if (boardSettings == null) {
|
||||
if(boardSettings == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Getting their Scoreboard display from the Scoreboard Provider.
|
||||
final List<String> entries = boardSettings.getBoardProvider().getLines(player).stream().map(APPLY_COLOR_TRANSLATION).collect(Collectors.toList());
|
||||
|
||||
if (boardSettings.getScoreDirection() == ScoreDirection.UP) {
|
||||
if(boardSettings.getScoreDirection() == ScoreDirection.UP) {
|
||||
Collections.reverse(entries);
|
||||
}
|
||||
|
||||
// Setting the Scoreboard title
|
||||
String title = boardSettings.getBoardProvider().getTitle(player);
|
||||
if (title.length() > 32) {
|
||||
if(title.length() > 32) {
|
||||
Bukkit.getLogger().warning("The title " + title + " is over 32 characters in length, substringing to prevent errors.");
|
||||
title = title.substring(0, 32);
|
||||
}
|
||||
objective.setDisplayName(C.translateAlternateColorCodes('&', title));
|
||||
|
||||
// Clearing previous Scoreboard values if entry sizes don't match.
|
||||
if (this.getScoreboard().getEntries().size() != entries.size())
|
||||
if(this.getScoreboard().getEntries().size() != entries.size())
|
||||
this.getScoreboard().getEntries().forEach(this::removeEntry);
|
||||
|
||||
// Setting Scoreboard lines.
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
for(int i = 0; i < entries.size(); i++) {
|
||||
String str = entries.get(i);
|
||||
BoardEntry entry = BoardEntry.translateToEntry(str);
|
||||
Team team = getScoreboard().getTeam(CACHED_ENTRIES[i]);
|
||||
|
||||
if (team == null) {
|
||||
if(team == null) {
|
||||
team = this.getScoreboard().registerNewTeam(CACHED_ENTRIES[i]);
|
||||
team.addEntry(team.getName());
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class Board {
|
||||
team.setPrefix(entry.getPrefix());
|
||||
team.setSuffix(entry.getSuffix());
|
||||
|
||||
switch (boardSettings.getScoreDirection()) {
|
||||
switch(boardSettings.getScoreDirection()) {
|
||||
case UP -> objective.getScore(team.getName()).setScore(1 + i);
|
||||
case DOWN -> objective.getScore(team.getName()).setScore(15 - i);
|
||||
}
|
||||
|
||||
@@ -38,16 +38,16 @@ public class BoardEntry {
|
||||
}
|
||||
|
||||
public static BoardEntry translateToEntry(String input) {
|
||||
if (input.isEmpty()) {
|
||||
if(input.isEmpty()) {
|
||||
return new BoardEntry("", "");
|
||||
}
|
||||
if (input.length() <= 16) {
|
||||
if(input.length() <= 16) {
|
||||
return new BoardEntry(input, "");
|
||||
} else {
|
||||
String prefix = input.substring(0, 16);
|
||||
String suffix = "";
|
||||
|
||||
if (prefix.endsWith("\u00a7")) {
|
||||
if(prefix.endsWith("\u00a7")) {
|
||||
prefix = prefix.substring(0, prefix.length() - 1);
|
||||
suffix = "\u00a7" + suffix;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BoardManager {
|
||||
|
||||
public void setup(Player player) {
|
||||
Optional.ofNullable(scoreboards.remove(player.getUniqueId())).ifPresent(Board::resetScoreboard);
|
||||
if (player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
|
||||
if(player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
scoreboards.put(player.getUniqueId(), new Board(player, boardSettings));
|
||||
|
||||
Reference in New Issue
Block a user