From 90b3c7669b7b5808e195686482fbe6ad29ad1408 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 7 Nov 2020 11:53:15 +0100 Subject: [PATCH] Improve Scoreboard (And tps rendering) --- .../bausystem/world/BauScoreboard.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java index cfeb64c..bbe4330 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -20,11 +20,11 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.commands.CommandFreeze; -import de.steamwar.bausystem.commands.CommandInfo; import de.steamwar.bausystem.commands.CommandTNT; import de.steamwar.bausystem.tracer.TraceManager; import de.steamwar.bausystem.tracer.recorder.RecordManager; import de.steamwar.bausystem.tracer.recorder.TNTRecorder; +import de.steamwar.core.TPSWatcher; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; import org.bukkit.entity.Player; @@ -44,7 +44,7 @@ public class BauScoreboard implements Listener { SWScoreboard.createScoreboard(player, new ScoreboardCallback() { @Override public HashMap getData() { - return render(sidebar(player)); + return sidebar(player); } @Override @@ -54,16 +54,7 @@ public class BauScoreboard implements Listener { }); } - private HashMap render(List strings) { - HashMap data = new HashMap<>(); - String[] elements = strings.toArray(new String[0]); - for (int i = elements.length - 1; i >= 0; i--) { - data.put(elements[i], elements.length - i - 1); - } - return data; - } - - private List sidebar(Player p) { + private HashMap sidebar(Player p) { List strings = new ArrayList<>(); strings.add("§1"); strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())); @@ -81,8 +72,13 @@ public class BauScoreboard implements Listener { } strings.add("§4"); - strings.add("§eTPS§8: §7" + CommandInfo.getTps()[0]); - return strings; + strings.add("§eTPS§8: §7" + TPSWatcher.getTPS()); + + int i = strings.size(); + HashMap result = new HashMap<>(); + for(String s : strings) + result.put(s, i--); + return result; } private long traceTicks() {