diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/CommandInfo_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/CommandInfo_12.java deleted file mode 100644 index 9ae06e1..0000000 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/CommandInfo_12.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.commands; - -import net.minecraft.server.v1_12_R1.MinecraftServer; - -class CommandInfo_12 { - private CommandInfo_12(){} - - static double[] getTps(){ - return MinecraftServer.getServer().recentTps; - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/CommandInfo_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/CommandInfo_15.java deleted file mode 100644 index a84f280..0000000 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/CommandInfo_15.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.commands; - -import net.minecraft.server.v1_15_R1.MinecraftServer; - -public class CommandInfo_15 { - private CommandInfo_15(){} - - static double[] getTps(){ - return MinecraftServer.getServer().recentTps; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 3002547..0b506d9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.Core; +import de.steamwar.core.TPSWatcher; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import org.bukkit.command.Command; @@ -32,7 +32,6 @@ import java.util.List; public class CommandInfo implements CommandExecutor { @Override - @SuppressWarnings("deprecation") public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); sender.sendMessage(BauSystem.PREFIX + "TNT-Schaden: " + (CommandTNT.getInstance().isOn() ? "§aAUS" : "§cAN")); @@ -50,29 +49,12 @@ public class CommandInfo implements CommandExecutor { } sender.sendMessage(membermessage.toString()); - StringBuilder tpsmessage = new StringBuilder().append(BauSystem.PREFIX).append("TPS:§e"); - for(float tps : getTps()){ - tpsmessage.append(" " + tps); - } - sender.sendMessage(tpsmessage.toString()); + sender.sendMessage(BauSystem.PREFIX + "TPS:§e" + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); return false; } - - public static float[] getTps() { - double[] tps; - - switch (Core.getVersion()) { - case 15: - tps = CommandInfo_15.getTps(); - break; - default: - tps = CommandInfo_12.getTps(); - } - - float[] roundedTps = new float[3]; - for(int i = 0; i < tps.length; i++) { - roundedTps[i] = tps[i] > 20.0D ? 20.0F : Math.round(tps[i] * 10) / 10f; - } - return roundedTps; - } } 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() {