Files
Purpur/patches/server/0124-YAPFA-Disable-mojang-profiler.patch
William Blake Galbreath 860c86191a Updated Upstream (Paper)
Upstream has released updates that appears to apply and compile correctly

Paper Changes:
c8028d1c Fix data version check for ItemStack serialization (#3394)
9254a80a Fix race condition reintroduced in Prioritize class loader patch
6f196fe7 Add Raw Byte ItemStack Serialization
df43f828 Allow server startup for those poor people running <1G Xmx
3c9b65ef Fix cases where no-tick < tick view distance
72f89a07 Workaround for Client Lag Spikes (MC-162253)
3f941c0c Add option for console having all permissions
d2ae4658 Add permission for command blocks
9f8ae5cb Prioritise own classes where possible
74466412 Check portal restrictions when entering end gateways
fc9cf84d Fix NPE when temp ip bans expire (#3373)
16bd420d Add missing mob goals for API (#3367)
b5c4e2f6 Ensure no-tick view is not smaller than ticking VD
52564b1f Expand Pathfinding API with more options
dde65481 Fix usage of vanilla goals
7797aebe Drop Leads from nether portals - Fixes #3226
511b6bc2 Reduce MutableInt and Vec3d allocations, use ArrayDeque
84673141 Optimize NibbleArray to use pooled buffers
897dd2c8 Foundational work for Future Memory usage improvements
bb4002d8 Handle CraftPlayer#setSpectatorTarget better
4ae08959 Fix collision checks on spawning hanging entities and null on async chunk loads
c2f8d1ef Protect Bedrock and End Portal/Frames from being destroyed
827cc632 Updated Upstream (Bukkit/CraftBukkit/Spigot)
92f680ed Fix Pathfinding and obscure glitchy buggy 0 tick farms
7a7c4292 Optimize Pathfinder - Remove Streams / Optimized collections
fc917d16 Optimize Hoppers - Major performance improvement
14ad77c6 Fix PotionEffect API Ignoring Icon bug
eb3ce8a2 Fix EntityRaider picking up items when they shouldn't be able
1ea9ada0 Add a TELEPORT ticket when changing dimensions
8e9459ea Fix missing flag pass for isUrgent
7befec44 Potential bed api (#3339)
27945a6b Optimize WorldBorder collision checks and air
55e17a85 Wait for Async Tasks during shutdown
b5905256 Ensure Entity AABB's are never invalid
a054aa6f Properly remove Entities from current chunk
c894ddfd Fix teleporting onto a chunk line
57d6cc01 Send LOGIN protocol packets immediately - Fix disconnect during async prelogin
cd93e54d Don't use our modified chunk checks for collision in world gen
b4003ef1 Allow loading entities current chunk if needed to fix collision checks
e5f64896 Add Urgent API for Async Chunks API and use it for Async Teleport
ad8e59dc Ensure chunks loaded on respawn for suffocation check
2020-05-18 15:22:23 -05:00

176 lines
7.3 KiB
Diff

From 7f6f02a2a89bc1a6c3cd16cbdcb65871b5bda7f5 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
Date: Thu, 5 Mar 2020 23:08:01 +0100
Subject: [PATCH] YAPFA - Disable mojang profiler
---
.../net/minecraft/server/CommandDebug.java | 5 ++
.../net/minecraft/server/MinecraftServer.java | 5 +-
.../net/pl3x/purpur/GameProfilerNoop.java | 68 +++++++++++++++++++
.../java/org/bukkit/craftbukkit/Main.java | 2 +
src/main/resources/purpur.lang | 1 +
5 files changed, 80 insertions(+), 1 deletion(-)
create mode 100644 src/main/java/net/pl3x/purpur/GameProfilerNoop.java
diff --git a/src/main/java/net/minecraft/server/CommandDebug.java b/src/main/java/net/minecraft/server/CommandDebug.java
index f0d72ea39..e38a68406 100644
--- a/src/main/java/net/minecraft/server/CommandDebug.java
+++ b/src/main/java/net/minecraft/server/CommandDebug.java
@@ -22,6 +22,7 @@ public class CommandDebug {
private static final Logger LOGGER = LogManager.getLogger();
private static final SimpleCommandExceptionType b = new SimpleCommandExceptionType(new ChatMessage("commands.debug.notRunning", new Object[0]));
private static final SimpleCommandExceptionType c = new SimpleCommandExceptionType(new ChatMessage("commands.debug.alreadyRunning", new Object[0]));
+ private static final SimpleCommandExceptionType disabled = new SimpleCommandExceptionType(new ChatMessage("commands.purpur.debug.disabled")); // Purpur
@Nullable
private static final FileSystemProvider d = (FileSystemProvider) FileSystemProvider.installedProviders().stream().filter((filesystemprovider) -> {
return filesystemprovider.getScheme().equalsIgnoreCase("jar");
@@ -43,6 +44,8 @@ public class CommandDebug {
MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
GameProfiler gameprofiler = minecraftserver.getMethodProfiler();
+ if (gameprofiler instanceof net.pl3x.purpur.GameProfilerNoop) throw CommandDebug.disabled.create(); // Purpur
+
if (gameprofiler.d().a()) {
throw CommandDebug.c.create();
} else {
@@ -56,6 +59,8 @@ public class CommandDebug {
MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
GameProfiler gameprofiler = minecraftserver.getMethodProfiler();
+ if (gameprofiler instanceof net.pl3x.purpur.GameProfilerNoop) throw CommandDebug.disabled.create(); // Purpur
+
if (!gameprofiler.d().a()) {
throw CommandDebug.b.create();
} else {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 555374f13..69b2eb0e0 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -80,7 +80,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
private final MojangStatisticsGenerator snooper = new MojangStatisticsGenerator("server", this, SystemUtils.getMonotonicMillis());
public File universe;
private final List<Runnable> tickables = Lists.newArrayList();
- private final GameProfiler methodProfiler = new GameProfiler(this::ak);
+ protected GameProfiler methodProfiler = new net.pl3x.purpur.GameProfilerNoop(this::getTickCount); // Purpur
private ServerConnection serverConnection;
public final WorldLoadListenerFactory worldLoadListenerFactory;
private final ServerPing serverPing = new ServerPing();
@@ -1460,6 +1460,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
String s1 = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
final DedicatedServer dedicatedserver = new DedicatedServer(optionset, dedicatedserversettings, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new, s1);
+ if (optionset.has("enableProfiler") || optionset.nonOptionArguments().contains("enableProfiler")) dedicatedserver.methodProfiler = new GameProfiler(dedicatedserver::getTickCount); // Purpur
+
/*
dedicatedserver.i((String) optionset.valueOf(optionspec7));
dedicatedserver.setPort((Integer) optionset.valueOf(optionspec10));
@@ -1885,6 +1887,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
public abstract boolean a(EnumGamemode enumgamemode, boolean flag, int i);
+ public int getTickCount() { return ak(); } // Purpur - OBFHELPER
public int ak() {
return this.ticks;
}
diff --git a/src/main/java/net/pl3x/purpur/GameProfilerNoop.java b/src/main/java/net/pl3x/purpur/GameProfilerNoop.java
new file mode 100644
index 000000000..b32a5418f
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/GameProfilerNoop.java
@@ -0,0 +1,68 @@
+package net.pl3x.purpur;
+
+import net.minecraft.server.GameProfiler;
+import net.minecraft.server.MethodProfilerResults;
+import net.minecraft.server.MethodProfilerResultsEmpty;
+
+import java.util.function.IntSupplier;
+import java.util.function.Supplier;
+
+public class GameProfilerNoop extends GameProfiler {
+ private final EmptyProfiler profiler = new EmptyProfiler();
+
+ public GameProfilerNoop(IntSupplier tickCount) {
+ super(tickCount);
+ }
+
+ public GameProfiler.a d() {
+ return this.profiler;
+ }
+
+ @Override
+ public void a() {
+ }
+
+ @Override
+ public void b() {
+ }
+
+ @Override
+ public void enter(String s) {
+ }
+
+ @Override
+ public void a(Supplier<String> supplier) {
+ }
+
+ @Override
+ public void exit() {
+ }
+
+ @Override
+ public void exitEnter(String s) {
+ }
+
+ @Override
+ public void c(String s) {
+ }
+
+ @Override
+ public void c(Supplier<String> supplier) {
+ }
+
+ static class EmptyProfiler implements GameProfiler.a {
+ @Override
+ public boolean a() { // isEnabled
+ return false;
+ }
+
+ @Override
+ public MethodProfilerResults b() { // disable
+ return MethodProfilerResultsEmpty.a; // empty
+ }
+
+ @Override
+ public void d() { // enable
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 717c2759f..2b34eb03b 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -145,6 +145,8 @@ public class Main {
.ofType(File.class)
.defaultsTo(new File("purpur.yml"))
.describedAs("Yml file");
+
+ acceptsAll(asList("enableProfiler"), "Enables the vanilla profiler");
// Purpur end
// Paper start
diff --git a/src/main/resources/purpur.lang b/src/main/resources/purpur.lang
index e81beea7f..5c3536b26 100644
--- a/src/main/resources/purpur.lang
+++ b/src/main/resources/purpur.lang
@@ -1,5 +1,6 @@
{
"cannot.ride.mob": "You cannot mount that mob",
+ "commands.purpur.debug.disabled": "The debug profiler is disabled",
"commands.purpur.ping": "§a%s's ping is %sms",
"idle.timeout.broadcast.away": "§e§o%s is now AFK",
"idle.timeout.broadcast.back": "§e§o%s is no longer AFK"
--
2.24.0