diff --git a/patches/api/Paper-Plugins.patch b/patches/api/Paper-Plugins.patch index 78e78542a9..973e380fb9 100644 --- a/patches/api/Paper-Plugins.patch +++ b/patches/api/Paper-Plugins.patch @@ -1626,6 +1626,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Preconditions.checkArgument(directory != null, "Directory cannot be null"); Preconditions.checkArgument(directory.isDirectory(), "Directory must be a directory"); +@@ -0,0 +0,0 @@ public final class SimplePluginManager implements PluginManager { + */ + @NotNull + public Plugin[] loadPlugins(@NotNull File[] files) { ++ // TODO Replace with Paper plugin loader + Preconditions.checkArgument(files != null, "File list cannot be null"); + + List result = new ArrayList(); @@ -0,0 +0,0 @@ public final class SimplePluginManager implements PluginManager { @Nullable public synchronized Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyException { diff --git a/patches/unapplied/server/Add-WorldEdit-plugin-flag-test-task.patch b/patches/server/Add-WorldEdit-plugin-flag-test-task.patch similarity index 100% rename from patches/unapplied/server/Add-WorldEdit-plugin-flag-test-task.patch rename to patches/server/Add-WorldEdit-plugin-flag-test-task.patch diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch index c38869edb0..17b61f0a36 100644 --- a/patches/server/Build-system-changes.patch +++ b/patches/server/Build-system-changes.patch @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for (tld in setOf("net", "com", "org")) { attributes("$tld/bukkit", "Sealed" to true) @@ -0,0 +0,0 @@ tasks.shadowJar { - } + configurations = listOf(project.configurations.vanillaServer.get()) } +// Paper start diff --git a/patches/unapplied/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch similarity index 73% rename from patches/unapplied/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch rename to patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 97f95e72a3..05c05a22bb 100644 --- a/patches/unapplied/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -14,28 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files implementation("commons-lang:commons-lang:2.6") + implementation("net.fabricmc:mapping-io:0.5.0") // Paper - needed to read mappings for stacktrace deobfuscation - runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1") - runtimeOnly("com.mysql:mysql-connector-j:8.2.0") runtimeOnly("com.lmax:disruptor:3.4.4") // Paper -@@ -0,0 +0,0 @@ tasks.check { - } - // Paper end -+// Paper start - include reobf mappings in jar for stacktrace deobfuscation -+val includeMappings = tasks.register("includeMappings") { -+ inputJar.set(tasks.fixJarForReobf.flatMap { it.outputJar }) -+ mappings.set(tasks.reobfJar.flatMap { it.mappingsFile }) -+ mappingsDest.set("META-INF/mappings/reobf.tiny") -+} -+ -+tasks.reobfJar { -+ inputJar.set(includeMappings.flatMap { it.outputJar }) -+} -+// Paper end - include reobf mappings in jar for stacktrace deobfuscation -+ - tasks.test { - exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") - useJUnitPlatform() + runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.6") diff --git a/src/log4jPlugins/java/io/papermc/paper/logging/StacktraceDeobfuscatingRewritePolicy.java b/src/log4jPlugins/java/io/papermc/paper/logging/StacktraceDeobfuscatingRewritePolicy.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -108,19 +89,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return new StacktraceDeobfuscatingRewritePolicy(); + } +} -diff --git a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java -+++ b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java -@@ -0,0 +0,0 @@ public class SyncLoadFinder { - - final JsonArray traces = new JsonArray(); - -- for (StackTraceElement element : pair.getFirst().stacktrace) { -+ for (StackTraceElement element : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(pair.getFirst().stacktrace)) { - traces.add(String.valueOf(element)); - } - diff --git a/src/main/java/io/papermc/paper/util/ObfHelper.java b/src/main/java/io/papermc/paper/util/ObfHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -443,33 +411,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return lineMap; + } +} -diff --git a/src/main/java/io/papermc/paper/util/TraceUtil.java b/src/main/java/io/papermc/paper/util/TraceUtil.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/io/papermc/paper/util/TraceUtil.java -+++ b/src/main/java/io/papermc/paper/util/TraceUtil.java -@@ -0,0 +0,0 @@ public final class TraceUtil { - - public static void dumpTraceForThread(Thread thread, String reason) { - Bukkit.getLogger().warning(thread.getName() + ": " + reason); -- StackTraceElement[] trace = thread.getStackTrace(); -+ StackTraceElement[] trace = StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace()); - for (StackTraceElement traceElement : trace) { - Bukkit.getLogger().warning("\tat " + traceElement); - } - } - - public static void dumpTraceForThread(String reason) { -- new Throwable(reason).printStackTrace(); -+ final Throwable throwable = new Throwable(reason); -+ StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(throwable); -+ throwable.printStackTrace(); -+ } -+ -+ public static void printStackTrace(Throwable thr) { -+ StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(thr); -+ thr.printStackTrace(); - } - } diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/CrashReport.java @@ -499,8 +440,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { - public static final AttributeKey> ATTRIBUTE_SERVERBOUND_PROTOCOL = AttributeKey.valueOf("serverbound_protocol"); - public static final AttributeKey> ATTRIBUTE_CLIENTBOUND_PROTOCOL = AttributeKey.valueOf("clientbound_protocol"); + marker.add(Connection.PACKET_MARKER); + }); public static final Supplier NETWORK_WORKER_GROUP = Suppliers.memoize(() -> { - return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build()); + return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper @@ -513,8 +454,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build()); + return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper }); + private static final ProtocolInfo INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND; private final PacketFlow receiving; - private final Queue> pendingActions = Queues.newConcurrentLinkedQueue(); @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { } @@ -524,26 +465,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet packet) { -diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/PacketEncoder.java -+++ b/src/main/java/net/minecraft/network/PacketEncoder.java -@@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder> { - - JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k); - } catch (Throwable var13) { -- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", i, packet.isSkippable(), var13); // Paper - Give proper error message -+ // Paper start - Give proper error message -+ String packetName = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(packet.getClass().getName()); -+ if (packetName.contains(".")) { -+ packetName = packetName.substring(packetName.lastIndexOf(".") + 1); -+ } -+ -+ LOGGER.error("Packet encoding of packet {} (ID: {}) threw (skippable? {})", packetName, i, packet.isSkippable(), var13); -+ // Paper end - if (packet.isSkippable()) { - throw new SkipPacketException(var13); - } diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -556,19 +477,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - initialize global and world-defaults configuration this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); -diff --git a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis - ServerConfigurationPacketListenerImpl.LOGGER.error("Couldn't place player in world", exception); - // Paper start - Debugging - if (MinecraftServer.getServer().isDebugging()) { -- exception.printStackTrace(); -+ io.papermc.paper.util.TraceUtil.printStackTrace(exception); - } - // Paper end - Debugging - this.connection.send(new ClientboundDisconnectPacket(ServerConfigurationPacketListenerImpl.DISCONNECT_REASON_INVALID_DATA)); diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java @@ -596,60 +504,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } catch (Exception exception) { - exception.printStackTrace(); + io.papermc.paper.util.TraceUtil.printStackTrace(exception); // Paper - com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent } + if (root != null) { @@ -0,0 +0,0 @@ public class OldUsersConverter { try { NbtIo.writeCompressed(root, new java.io.FileOutputStream(file2)); } catch (Exception exception) { - exception.printStackTrace(); + io.papermc.paper.util.TraceUtil.printStackTrace(exception); // Paper - com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent } } -diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess { - + " (" + getBlockState(blockposition) + ") where there was no entity tile!\n" + - "Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16) + - "\nWorld: " + level.getLevel().dimension().location()); -- e.printStackTrace(); -+ io.papermc.paper.util.TraceUtil.printStackTrace(e); - ServerInternalException.reportInternalException(e); - // Paper end - ServerExceptionEvent - // CraftBukkit end -diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java -+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java -@@ -0,0 +0,0 @@ public class CraftAsyncScheduler extends CraftScheduler { - - private final ThreadPoolExecutor executor = new ThreadPoolExecutor( - 4, Integer.MAX_VALUE,30L, TimeUnit.SECONDS, new SynchronousQueue<>(), -- new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %1$d").build()); -+ new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %1$d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper - private final Executor management = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder() -- .setNameFormat("Craft Async Scheduler Management Thread").build()); -+ .setNameFormat("Craft Async Scheduler Management Thread").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper - private final List temp = new ArrayList<>(); - - CraftAsyncScheduler() { + // CraftBukkit end diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java -@@ -0,0 +0,0 @@ public class WatchdogThread extends Thread - log.log(Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity"); - log.log(Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated"); - log.log(Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage()); -- for (StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace()) { -+ for (StackTraceElement stack : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace())) { // Paper - log.log( Level.SEVERE, "\t\t" + stack ); - } - } @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread } log.log( Level.SEVERE, "\tStack:" ); diff --git a/patches/unapplied/server/Handle-plugin-prefixes-using-Log4J-configuration.patch b/patches/server/Handle-plugin-prefixes-using-Log4J-configuration.patch similarity index 99% rename from patches/unapplied/server/Handle-plugin-prefixes-using-Log4J-configuration.patch rename to patches/server/Handle-plugin-prefixes-using-Log4J-configuration.patch index c8f5bc619c..0001b021cc 100644 --- a/patches/unapplied/server/Handle-plugin-prefixes-using-Log4J-configuration.patch +++ b/patches/server/Handle-plugin-prefixes-using-Log4J-configuration.patch @@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -0,0 +0,0 @@ - + - diff --git a/patches/unapplied/server/Improve-Log4J-Configuration-Plugin-Loggers.patch b/patches/server/Improve-Log4J-Configuration-Plugin-Loggers.patch similarity index 100% rename from patches/unapplied/server/Improve-Log4J-Configuration-Plugin-Loggers.patch rename to patches/server/Improve-Log4J-Configuration-Plugin-Loggers.patch diff --git a/patches/unapplied/server/Paper-Metrics.patch b/patches/server/Paper-Metrics.patch similarity index 100% rename from patches/unapplied/server/Paper-Metrics.patch rename to patches/server/Paper-Metrics.patch diff --git a/patches/unapplied/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch similarity index 100% rename from patches/unapplied/server/Paper-Plugins.patch rename to patches/server/Paper-Plugins.patch diff --git a/patches/unapplied/server/Paper-command.patch b/patches/server/Paper-command.patch similarity index 100% rename from patches/unapplied/server/Paper-command.patch rename to patches/server/Paper-command.patch diff --git a/patches/unapplied/server/Plugin-remapping.patch b/patches/server/Plugin-remapping.patch similarity index 96% rename from patches/unapplied/server/Plugin-remapping.patch rename to patches/server/Plugin-remapping.patch index 14efb64e56..d6ef899d05 100644 --- a/patches/unapplied/server/Plugin-remapping.patch +++ b/patches/server/Plugin-remapping.patch @@ -18,10 +18,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +} + +paperweight { -+ craftBukkitPackageVersion.set("v1_20_R3") // also needs to be updated in MappingEnvironment ++ craftBukkitPackageVersion.set("v1_20_R4") // also needs to be updated in MappingEnvironment } --val craftbukkitPackageVersion = "1_20_R3" // Paper +-val craftbukkitPackageVersion = "1_20_R4" // Paper tasks.jar { archiveClassifier.set("dev") @@ -34,54 +34,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ) for (tld in setOf("net", "com", "org")) { attributes("$tld/bukkit", "Sealed" to true) -@@ -0,0 +0,0 @@ tasks.compileTestJava { - - publishing { - publications.create("maven") { -- artifact(tasks.shadowJar) -- } --} -- --relocation { -- // Order matters here - e.g. craftbukkit proper must be relocated before any of the libs are relocated into the cb package -- relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$craftbukkitPackageVersion") { -- exclude("org.bukkit.craftbukkit.Main*") - } - } - - tasks.shadowJar { - configurations = listOf(project.configurations.vanillaServer.get(), alsoShade) -- archiveClassifier.set("mojang-mapped") -- -- for (relocation in relocation.relocations.get()) { -- relocate(relocation.fromPackage, relocation.toPackage) { -- for (exclude in relocation.excludes) { -- exclude(exclude) -- } -- } -- } - } - - // Paper start -@@ -0,0 +0,0 @@ tasks.check { - } - // Paper end - --// Paper start - include reobf mappings in jar for stacktrace deobfuscation --val includeMappings = tasks.register("includeMappings") { -- inputJar.set(tasks.fixJarForReobf.flatMap { it.outputJar }) -- mappings.set(tasks.reobfJar.flatMap { it.mappingsFile }) -- mappingsDest.set("META-INF/mappings/reobf.tiny") --} -- --tasks.reobfJar { -- inputJar.set(includeMappings.flatMap { it.outputJar }) --} --// Paper end - include reobf mappings in jar for stacktrace deobfuscation -- - tasks.test { - exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") - useJUnitPlatform() @@ -0,0 +0,0 @@ val runtimeClasspathWithoutVanillaServer = configurations.runtimeClasspath.flatM runtime.filterNot { it.asFile.absolutePath == vanilla } } @@ -1533,7 +1485,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop extraPluginJars() { @@ -0,0 +0,0 @@ public final class CraftServer implements Server { this.enablePlugins(PluginLoadOrder.STARTUP); this.enablePlugins(PluginLoadOrder.POSTWORLD); this.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.RELOAD)); + if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins - org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Disable watchdog early timeout on reload } + @Override diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -1905,21 +1848,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private CraftMagicNumbers() {} @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - if (pluginIndex < minimumIndex) { - throw new InvalidPluginException("Plugin API version " + pdf.getAPIVersion() + " is lower than the minimum allowed version. Please update or replace it."); - } -- } else { -+ } else if (!DISABLE_PLUGIN_REWRITING) { - if (minimumIndex == -1) { - CraftLegacy.init(); - Bukkit.getLogger().log(Level.WARNING, "Legacy plugin " + pdf.getFullName() + " does not specify an api-version."); + throw new InvalidPluginException("Plugin API version " + pdf.getAPIVersion() + " is lower than the minimum allowed version. Please update or replace it."); + } + +- if (toCheck.isOlderThan(ApiVersion.FLATTENING)) { ++ if (!DISABLE_PLUGIN_REWRITING && toCheck.isOlderThan(ApiVersion.FLATTENING)) { // Paper + CraftLegacy.init(); + } + @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public byte[] processClass(PluginDescriptionFile pdf, String path, byte[] clazz) { -+ if (DISABLE_PLUGIN_REWRITING) { -+ return clazz; -+ } ++ if (DISABLE_PLUGIN_REWRITING) return clazz; // Paper try { - clazz = Commodore.convert(clazz, !CraftMagicNumbers.isLegacy(pdf)); + clazz = Commodore.convert(clazz, pdf.getName(), ApiVersion.getOrCreateVersion(pdf.getAPIVersion())); } catch (Exception ex) { diff --git a/patches/unapplied/server/Remap-reflection-calls-in-plugins-using-internals.patch b/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch similarity index 83% rename from patches/unapplied/server/Remap-reflection-calls-in-plugins-using-internals.patch rename to patches/server/Remap-reflection-calls-in-plugins-using-internals.patch index 0a737c48e8..8fcd746466 100644 --- a/patches/unapplied/server/Remap-reflection-calls-in-plugins-using-internals.patch +++ b/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch @@ -14,9 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files implementation("commons-lang:commons-lang:2.6") - implementation("net.fabricmc:mapping-io:0.5.0") // Paper - needed to read mappings for stacktrace deobfuscation - runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1") - runtimeOnly("com.mysql:mysql-connector-j:8.2.0") runtimeOnly("com.lmax:disruptor:3.4.4") // Paper + + runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.6") @@ -0,0 +0,0 @@ dependencies { testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest implementation("net.neoforged:AutoRenamingTool:2.0.3") // Paper - remap plugins @@ -30,27 +30,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } paperweight { -diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java -+++ b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java -@@ -0,0 +0,0 @@ import com.destroystokyo.paper.entity.RangedEntity; - import com.destroystokyo.paper.util.set.OptimizedSmallEnumSet; - import com.google.common.collect.BiMap; - import com.google.common.collect.HashBiMap; -+import io.papermc.paper.util.MappingEnvironment; - import io.papermc.paper.util.ObfHelper; - import java.lang.reflect.Constructor; - import java.util.EnumSet; -@@ -0,0 +0,0 @@ public class MobGoalHelper { - } - - public static String getUsableName(Class clazz) { -- String name = ObfHelper.INSTANCE.deobfClassName(clazz.getName()); -+ String name = MappingEnvironment.reobf() ? ObfHelper.INSTANCE.deobfClassName(clazz.getName()) : clazz.getName(); - name = name.substring(name.lastIndexOf(".") + 1); - boolean flag = false; - // inner classes diff --git a/src/main/java/io/papermc/paper/configuration/serializer/PacketClassSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/PacketClassSerializer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/io/papermc/paper/configuration/serializer/PacketClassSerializer.java @@ -665,32 +644,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.pool.computeIfAbsent(string, Function.identity()); + } +} -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -@@ -0,0 +0,0 @@ public abstract class Behavior implements BehaviorContro - this.maxDuration = maxRunTime; - this.entryCondition = requiredMemoryState; - // Paper start - configurable behavior tick rate and timings -- String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()); -+ String key = io.papermc.paper.util.MappingEnvironment.reobf() ? io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()) : this.getClass().getName(); - int lastSeparator = key.lastIndexOf('.'); - if (lastSeparator != -1) { - key = key.substring(lastSeparator + 1); -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -@@ -0,0 +0,0 @@ public abstract class Sensor { - - public Sensor(int senseInterval) { - // Paper start - configurable sensor tick rate and timings -- String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()); -+ String key = io.papermc.paper.util.MappingEnvironment.reobf() ? io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()) : this.getClass().getName(); - int lastSeparator = key.lastIndexOf('.'); - if (lastSeparator != -1) { - key = key.substring(lastSeparator + 1); diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java @@ -704,60 +657,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean runNext(Level world); } -diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -@@ -0,0 +0,0 @@ public class Commodore { - - // Paper start - Plugin rewrites - private static final String CB_PACKAGE = org.bukkit.Bukkit.getServer().getClass().getPackageName().replace('.', '/'); -- private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); -- private static Map initReplacementsMap() { -- Map getAndRemove = new HashMap<>(); -- // Be wary of maven shade's relocations -- -- final java.util.jar.Manifest manifest = io.papermc.paper.util.JarManifests.manifest(Commodore.class); -- if (Boolean.getBoolean( "debug.rewriteForIde") && manifest != null) -- { -- // unversion incoming calls for pre-relocate debug work -- final String NMS_REVISION_PACKAGE = "v" + manifest.getMainAttributes().getValue("CraftBukkit-Package-Version") + "/"; -- -- getAndRemove.put("org/bukkit/".concat("craftbukkit/" + NMS_REVISION_PACKAGE), NMS_REVISION_PACKAGE); -- } -- -- return getAndRemove; -- } -+ private static final String CB_PACKAGE_PREFIX = "org/bukkit/".concat("craftbukkit/"); -+ private static final String LEGACY_CB_PACKAGE_PREFIX = CB_PACKAGE_PREFIX + io.papermc.paper.util.MappingEnvironment.LEGACY_CB_VERSION + "/"; - - @Nonnull - private static String getOriginalOrRewrite(@Nonnull String original) - { -- String rewrite = null; -- for ( Map.Entry entry : SEARCH_AND_REMOVE.entrySet() ) -- { -- if ( original.contains( entry.getKey() ) ) -- { -- rewrite = original.replace( entry.getValue(), "" ); -+ // Relocation is applied in reobf, and when mappings are present they handle the relocation -+ if (!io.papermc.paper.util.MappingEnvironment.reobf() && !io.papermc.paper.util.MappingEnvironment.hasMappings()) { -+ if (original.contains(LEGACY_CB_PACKAGE_PREFIX)) { -+ original = original.replace(LEGACY_CB_PACKAGE_PREFIX, CB_PACKAGE_PREFIX); - } - } - -- return rewrite != null ? rewrite : original; -+ return original; - } - // Paper end - Plugin rewrites - -@@ -0,0 +0,0 @@ public class Commodore { - ClassReader cr = new ClassReader(b); - ClassWriter cw = new ClassWriter(cr, 0); - -- cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, cw) { -+ cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, io.papermc.paper.pluginremap.reflect.ReflectionRemapper.visitor(cw)) { // Paper - - // Paper start - Rewrite plugins - @Override diff --git a/patches/unapplied/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch b/patches/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch similarity index 100% rename from patches/unapplied/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch rename to patches/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index 41cf6e4239..56ab8f4ab6 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -87,28 +87,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +publishing { + publications.create("maven") { -+ artifact(tasks.shadowJar) -+ } -+} -+ -+relocation { -+ // Order matters here - e.g. craftbukkit proper must be relocated before any of the libs are relocated into the cb package -+ relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$craftbukkitPackageVersion") { -+ exclude("org.bukkit.craftbukkit.Main*") + } +} + +tasks.shadowJar { + configurations = listOf(project.configurations.vanillaServer.get()) -+ archiveClassifier.set("mojang-mapped") -+ -+ for (relocation in relocation.relocations.get()) { -+ relocate(relocation.fromPackage, relocation.toPackage) { -+ for (exclude in relocation.excludes) { -+ exclude(exclude) -+ } -+ } -+ } +} + +tasks.test { diff --git a/patches/server/Test-changes.patch b/patches/server/Test-changes.patch index 12d358765a..eea3a6bdf8 100644 --- a/patches/server/Test-changes.patch +++ b/patches/server/Test-changes.patch @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + publishing { publications.create("maven") { - artifact(tasks.shadowJar) + } diff --git a/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/unapplied/server/Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch b/patches/server/Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch similarity index 87% rename from patches/unapplied/server/Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch rename to patches/server/Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch index 32c3dd9dea..e8c22ec7d1 100644 --- a/patches/unapplied/server/Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch +++ b/patches/server/Use-AsyncAppender-to-keep-logging-IO-off-main-thread.patch @@ -9,9 +9,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { + implementation("org.ow2.asm:asm-commons:9.7") + implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files implementation("commons-lang:commons-lang:2.6") - runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1") - runtimeOnly("com.mysql:mysql-connector-j:8.2.0") +- runtimeOnly("org.xerial:sqlite-jdbc:3.45.3.0") +- runtimeOnly("com.mysql:mysql-connector-j:8.3.0") + runtimeOnly("com.lmax:disruptor:3.4.4") // Paper runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.6") diff --git a/patches/unapplied/server/Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch similarity index 96% rename from patches/unapplied/server/Use-TerminalConsoleAppender-for-console-improvements.patch rename to patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch index 1ab0f48204..415c4c0f6b 100644 --- a/patches/unapplied/server/Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch @@ -57,18 +57,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + runtimeOnly(log4jPlugins.output) + alsoShade(log4jPlugins.output) + // Paper end - implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion + implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion implementation("org.ow2.asm:asm-commons:9.7") implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files -@@ -0,0 +0,0 @@ relocation { +@@ -0,0 +0,0 @@ publishing { } tasks.shadowJar { - configurations = listOf(project.configurations.vanillaServer.get()) -+ configurations = listOf(project.configurations.vanillaServer.get(), alsoShade) - archiveClassifier.set("mojang-mapped") ++ configurations = listOf(project.configurations.vanillaServer.get(), alsoShade) // Paper + } - for (relocation in relocation.relocations.get()) { + // Paper start diff --git a/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java b/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -267,7 +267,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public OptionSet options; public org.bukkit.command.ConsoleCommandSender console; - public ConsoleReader reader; - public static int currentTick; // Paper - improve tick loop + public static int currentTick = (int) (System.currentTimeMillis() / 50); public java.util.Queue processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop - + - -- +- - - + - -- +- - + + + -- +- + diff --git a/patches/unapplied/server/Add-command-line-option-to-load-extra-plugin-jars-no.patch b/patches/unapplied/server/Add-command-line-option-to-load-extra-plugin-jars-no.patch index 22811394ef..2e46a0ce6f 100644 --- a/patches/unapplied/server/Add-command-line-option-to-load-extra-plugin-jars-no.patch +++ b/patches/unapplied/server/Add-command-line-option-to-load-extra-plugin-jars-no.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public File getPluginsFolder() { -+ return (File) this.console.options.valueOf("plugins"); ++ return this.console.getPluginsFolder(); + } + + private List extraPluginJars() { diff --git a/patches/unapplied/server/Implement-Mob-Goal-API.patch b/patches/unapplied/server/Implement-Mob-Goal-API.patch index 932883924a..9e48781de9 100644 --- a/patches/unapplied/server/Implement-Mob-Goal-API.patch +++ b/patches/unapplied/server/Implement-Mob-Goal-API.patch @@ -273,7 +273,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + public static String getUsableName(Class clazz) { -+ String name = ObfHelper.INSTANCE.deobfClassName(clazz.getName()); ++ String name = MappingEnvironment.reobf() ? ObfHelper.INSTANCE.deobfClassName(clazz.getName()) : clazz.getName(); + name = name.substring(name.lastIndexOf(".") + 1); + boolean flag = false; + // inner classes diff --git a/patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch b/patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch index 2cbd0da1d5..91af1425a3 100644 --- a/patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch +++ b/patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch @@ -47,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.maxDuration = maxRunTime; this.entryCondition = requiredMemoryState; + // Paper start - configurable behavior tick rate and timings -+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()); ++ String key = io.papermc.paper.util.MappingEnvironment.reobf() ? io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()) : this.getClass().getName(); + int lastSeparator = key.lastIndexOf('.'); + if (lastSeparator != -1) { + key = key.substring(lastSeparator + 1); @@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public Sensor(int senseInterval) { + // Paper start - configurable sensor tick rate and timings -+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()); ++ String key = io.papermc.paper.util.MappingEnvironment.reobf() ? io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName()) : this.getClass().getName(); + int lastSeparator = key.lastIndexOf('.'); + if (lastSeparator != -1) { + key = key.substring(lastSeparator + 1);