mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 00:47:42 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: df0d7b0d Update upstream CB 6ea3c2cf [CI-SKIP] Rebuild patches d7bed4cb Heavily optimise random block ticking (#2914) b66d9ff8 Update upstream CB ba71c5d6 Stop stripping private use block Unicode from signs 28d9dcfc Entity Jump API (#1587) 9976a768 Fix PlayerNaturallySpawnCreaturesEvent boolean inversion 054e20da Clean up imports on ThrownEggHatchEvent a8984ccb Add ThrownEggHatchEvent (#1982) 9f24d495 Allow nerfed blazes, endermen to take water damage (#2847)
83 lines
3.4 KiB
Diff
83 lines
3.4 KiB
Diff
From 155caf4cd63022a8e4e2a6e1651ccd9616fca731 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Thu, 30 Jan 2020 00:41:24 -0600
|
|
Subject: [PATCH] Add tick times API
|
|
|
|
---
|
|
.../java/net/pl3x/purpur/gui/info/RAMDetails.java | 4 ++--
|
|
.../java/org/bukkit/craftbukkit/CraftServer.java | 12 ++++++++++++
|
|
.../java/org/spigotmc/TicksPerSecondCommand.java | 10 ++++++++++
|
|
3 files changed, 24 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/gui/info/RAMDetails.java b/src/main/java/net/pl3x/purpur/gui/info/RAMDetails.java
|
|
index 00f79e433..845eb1f8c 100644
|
|
--- a/src/main/java/net/pl3x/purpur/gui/info/RAMDetails.java
|
|
+++ b/src/main/java/net/pl3x/purpur/gui/info/RAMDetails.java
|
|
@@ -15,7 +15,7 @@ import java.util.Locale;
|
|
import java.util.Vector;
|
|
|
|
public class RAMDetails extends JList<String> {
|
|
- private static final DecimalFormat DECIMAL_FORMAT = SystemUtils.a(new DecimalFormat("########0.000"), (format)
|
|
+ public static final DecimalFormat DECIMAL_FORMAT = SystemUtils.a(new DecimalFormat("########0.000"), (format)
|
|
-> format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT)));
|
|
|
|
public RAMDetails() {
|
|
@@ -44,7 +44,7 @@ public class RAMDetails extends JList<String> {
|
|
setListData(vector);
|
|
}
|
|
|
|
- private double getAverage(long[] values) {
|
|
+ public static double getAverage(long[] values) {
|
|
long total = 0L;
|
|
for (long value : values) {
|
|
total += value;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index daa94187f..ca7cc3b87 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -2189,4 +2189,16 @@ public final class CraftServer implements Server {
|
|
return net.minecraft.server.MinecraftServer.currentTick;
|
|
}
|
|
// Paper end
|
|
+
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ public long[] getTickTimes() {
|
|
+ return getServer().getTickTimes();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public double getAverageTickTime() {
|
|
+ return net.pl3x.purpur.gui.info.RAMDetails.getAverage(getTickTimes());
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
index 6d21c3269..5550379a6 100644
|
|
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
|
@@ -32,10 +32,20 @@ public class TicksPerSecondCommand extends Command
|
|
}
|
|
sender.sendMessage( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
|
|
// Paper end
|
|
+ // Purpur start
|
|
+ double avg = org.bukkit.Bukkit.getAverageTickTime();
|
|
+ sender.sendMessage( ChatColor.GOLD + "Average tick time: " + getColor(avg) + net.pl3x.purpur.gui.info.RAMDetails.DECIMAL_FORMAT.format(avg) + " ms");
|
|
+ // Purpur end
|
|
|
|
return true;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ private static String getColor(double avg) {
|
|
+ return (avg >= 50 ? ChatColor.RED : avg >= 40 ? ChatColor.YELLOW : ChatColor.GREEN).toString();
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
private static String format(double tps) // Paper - Made static
|
|
{
|
|
return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
|
|
--
|
|
2.24.0
|
|
|