Create patch for decompile fixes

This commit is contained in:
William Blake Galbreath
2020-02-27 18:00:18 -06:00
parent f2690c9ecc
commit 5efca4d817
99 changed files with 1501 additions and 102 deletions

View File

@@ -0,0 +1,72 @@
From 908ee9bfb75cd649b85e73df73211c38a4d86265 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
---
.../org/bukkit/craftbukkit/CraftServer.java | 17 +++++++++++++++++
.../org/spigotmc/TicksPerSecondCommand.java | 11 +++++++++++
2 files changed, 28 insertions(+)
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index df4fb5947a..206fd848ad 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2197,4 +2197,21 @@ public final class CraftServer implements Server {
return net.minecraft.server.MinecraftServer.currentTick;
}
// Paper end
+
+ // Purpur start
+ @Override
+ public long[] getTickTimes() {
+ return getServer().getTickTimes().clone();
+ }
+
+ @Override
+ public double getAverageTickTime() {
+ long total = 0L;
+ long[] tickTimes = getTickTimes();
+ for (long value : tickTimes) {
+ total += value;
+ }
+ return ((double) total / (double) tickTimes.length) * 1.0E-6D;
+ }
+ // Purpur end
}
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
index 6d21c32692..b889c32a1a 100644
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
@@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
public class TicksPerSecondCommand extends Command
{
+ private static final java.text.DecimalFormat DF = new java.text.DecimalFormat("########0.000"); // Purpur
public TicksPerSecondCommand(String name)
{
@@ -32,10 +33,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) + DF.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