Some small touchups to the GUI (#11505)

As noted on the issue, the method here can blow up in
certain cases, the GUI logic already handles "the mouse is missing",
and so, we'll just catch this and move on.

Misc fix - There is probably an issue report for this somewhere,
but, the details section utilised the bukkit singleton to try to get
the TPS from the server. We already have the MinecraftServer instance
passed into us, and so we'll just get the information directly from there instead.

Fixes: #11494
This commit is contained in:
Shane Freeder 2024-10-21 00:10:10 +01:00 committed by GitHub
parent 260c3bbec0
commit 14a48cda40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 8 deletions

View file

@ -7,15 +7,20 @@ Subject: [PATCH] Improve ServerGUI
- Show tps in the server stats
diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
index f93373d28d741e1f8a53e07b4e328ce9c4e1657f..039a86034928a5eb7aaa2d7ca76a7bddcca346bd 100644
index f93373d28d741e1f8a53e07b4e328ce9c4e1657f..12b327eea95e0de9e9c39b7d039badee8ec46508 100644
--- a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
+++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
@@ -58,9 +58,17 @@ public class RAMDetails extends JList<String> {
@@ -58,9 +58,22 @@ public class RAMDetails extends JList<String> {
public void update() {
GraphData data = RAMGraph.DATA.peekLast();
Vector<String> vector = new Vector<>();
+
+ double[] tps = org.bukkit.Bukkit.getTPS();
+ // Follows CraftServer#getTPS
+ double[] tps = new double[] {
+ server.tps1.getAverage(),
+ server.tps5.getAverage(),
+ server.tps15.getAverage()
+ };
+ String[] tpsAvg = new String[tps.length];
+
+ for ( int g = 0; g < tps.length; g++) {
@ -28,7 +33,7 @@ index f93373d28d741e1f8a53e07b4e328ce9c4e1657f..039a86034928a5eb7aaa2d7ca76a7bdd
setListData(vector);
}
@@ -71,4 +79,8 @@ public class RAMDetails extends JList<String> {
@@ -71,4 +84,8 @@ public class RAMDetails extends JList<String> {
}
return ((double) total / (double) tickTimes.length) * 1.0E-6D;
}