Merge pull request 'Improve Scoreboard (And tps rendering)' (#110) from improveScoreboard into master
Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Commit
9dd02f6c52
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<String, Integer> getData() {
|
||||
return render(sidebar(player));
|
||||
return sidebar(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,16 +54,7 @@ public class BauScoreboard implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private HashMap<String, Integer> render(List<String> strings) {
|
||||
HashMap<String, Integer> 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<String> sidebar(Player p) {
|
||||
private HashMap<String, Integer> sidebar(Player p) {
|
||||
List<String> 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<String, Integer> result = new HashMap<>();
|
||||
for(String s : strings)
|
||||
result.put(s, i--);
|
||||
return result;
|
||||
}
|
||||
|
||||
private long traceTicks() {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren