diff --git a/patches/net/minecraft/client/main/Main.java.patch b/patches/net/minecraft/client/main/Main.java.patch index 352781b7..b5df7d14 100644 --- a/patches/net/minecraft/client/main/Main.java.patch +++ b/patches/net/minecraft/client/main/Main.java.patch @@ -1,14 +1,15 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -1,5 +1,7 @@ +@@ -1,5 +1,8 @@ package net.minecraft.client.main; +import carpet.spark.CarpetSparkAccess; ++import carpet.utils.Log4j2JndiPatch; +import carpet.worldedit.CarpetWorldEditAccess; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.mojang.authlib.properties.PropertyMap; -@@ -70,6 +72,11 @@ +@@ -70,6 +73,11 @@ System.out.println("Completely ignored arguments: " + list); } @@ -20,3 +21,13 @@ String s = func_206236_a(optionset, optionspec5); Proxy proxy = Proxy.NO_PROXY; +@@ -162,6 +170,9 @@ + + static + { ++ // TISCM LOG4J2-3201 PATCH ++ Log4j2JndiPatch.patch(); ++ + System.setProperty("java.awt.headless", "true"); + } + } diff --git a/patches/net/minecraft/server/MinecraftServer.java.patch b/patches/net/minecraft/server/MinecraftServer.java.patch index 7044cbe8..6abd12a9 100644 --- a/patches/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1,5 +1,19 @@ +@@ -1,5 +1,20 @@ package net.minecraft.server; +import carpet.CarpetServer; @@ -14,13 +14,14 @@ +import carpet.settings.CarpetSettings; +import carpet.spark.CarpetSparkAccess; +import carpet.utils.CarpetProfiler; ++import carpet.utils.Log4j2JndiPatch; +import carpet.utils.Messenger; +import carpet.utils.TISCMConfig; +import carpet.worldedit.CarpetWorldEditAccess; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -@@ -178,6 +192,7 @@ +@@ -178,6 +193,7 @@ public final Queue < FutureTask> futureTaskQueue = Queues.newConcurrentLinkedQueue(); private Thread serverThread; private long serverTime = Util.milliTime(); @@ -28,7 +29,7 @@ @OnlyIn(Dist.CLIENT) private boolean worldIconSet; private final IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA); -@@ -212,6 +227,8 @@ +@@ -212,6 +228,8 @@ this.resourceManager.addReloadListener(this.lootTableManager); this.resourceManager.addReloadListener(this.functionManager); this.resourceManager.addReloadListener(this.advancementManager); @@ -37,7 +38,7 @@ } public abstract boolean init() throws IOException; -@@ -571,7 +588,13 @@ +@@ -571,7 +589,13 @@ public void stopServer() { LOGGER.info("Stopping server"); @@ -51,7 +52,7 @@ if (this.getNetworkSystem() != null) { this.getNetworkSystem().terminateEndpoints(); -@@ -639,34 +662,64 @@ +@@ -639,34 +663,64 @@ { try { @@ -133,7 +134,7 @@ } } else -@@ -782,7 +835,16 @@ +@@ -782,7 +836,16 @@ { long i = Util.nanoTime(); ++this.tickCounter; @@ -150,7 +151,7 @@ if (this.startProfiling) { this.startProfiling = false; -@@ -790,6 +852,9 @@ +@@ -790,6 +853,9 @@ } this.profiler.startSection("root"); @@ -160,7 +161,7 @@ this.updateTimeLightAndEntities(hasTimeLeft); if (i - this.nanoTimeSinceStatusRefresh >= 5000000000L) -@@ -810,10 +875,26 @@ +@@ -810,10 +876,26 @@ if (this.tickCounter % 900 == 0) { @@ -187,7 +188,7 @@ } this.profiler.startSection("snooper"); -@@ -829,16 +910,30 @@ +@@ -829,16 +911,30 @@ } this.profiler.endSection(); @@ -218,7 +219,7 @@ FutureTask futuretask; while ((futuretask = this.futureTaskQueue.poll()) != null) -@@ -847,6 +942,7 @@ +@@ -847,6 +943,7 @@ } this.profiler.endStartSection("commandFunctions"); @@ -226,7 +227,7 @@ this.getFunctionManager().tick(); this.profiler.endStartSection("levels"); -@@ -870,6 +966,7 @@ +@@ -870,6 +967,7 @@ this.profiler.startSection("tick"); @@ -234,7 +235,7 @@ try { worldserver.tick(hasTimeLeft); -@@ -878,9 +975,15 @@ +@@ -878,9 +976,15 @@ { CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world"); worldserver.fillCrashReport(crashreport); @@ -251,7 +252,7 @@ try { worldserver.tickEntities(); -@@ -889,7 +992,12 @@ +@@ -889,7 +993,12 @@ { CrashReport crashreport1 = CrashReport.makeCrashReport(throwable, "Exception ticking world entities"); worldserver.fillCrashReport(crashreport1); @@ -265,7 +266,7 @@ } this.profiler.endSection(); -@@ -905,10 +1013,13 @@ +@@ -905,10 +1014,13 @@ }))[this.tickCounter % 100] = Util.nanoTime() - i; } @@ -279,7 +280,20 @@ this.profiler.endStartSection("tickables"); for (int j = 0; j < this.tickables.size(); ++j) -@@ -1004,6 +1115,11 @@ +@@ -929,6 +1041,12 @@ + this.tickables.add(tickable); + } + ++ static ++ { ++ // TISCM LOG4J2-3201 PATCH ++ Log4j2JndiPatch.patch(); ++ } ++ + public static void main(String[] p_main_0_) + { + Bootstrap.register(); +@@ -1004,6 +1122,11 @@ } } @@ -291,7 +305,7 @@ YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); -@@ -1142,7 +1258,8 @@ +@@ -1142,7 +1265,8 @@ public String getServerModName() { @@ -301,7 +315,7 @@ } public CrashReport addServerInfoToCrashReport(CrashReport report) -@@ -1605,6 +1722,12 @@ +@@ -1605,6 +1729,12 @@ { return this.serverTime; } @@ -314,7 +328,7 @@ public Thread getServerThread() { -@@ -1825,4 +1948,17 @@ +@@ -1825,4 +1955,17 @@ return 0; } } diff --git a/src/main/java/carpet/utils/Log4j2JndiPatch.java b/src/main/java/carpet/utils/Log4j2JndiPatch.java new file mode 100644 index 00000000..a0fd8404 --- /dev/null +++ b/src/main/java/carpet/utils/Log4j2JndiPatch.java @@ -0,0 +1,33 @@ +package carpet.utils; + +import org.apache.logging.log4j.core.LoggerContext; + +/** + * Fix from 1.18.1-rc3 + */ +public class Log4j2JndiPatch +{ + private static final LoggerContext loggerContext = LoggerContext.getContext(false); + + public static void patch() + { + // doesn't work before log4j2 2.10 + // System.setProperty("log4j2.formatMsgNoLookups", "true"); + + loggerContext.addPropertyChangeListener(event -> applyFix()); + applyFix(); + } + + private static void applyFix() + { + try + { + loggerContext.getConfiguration().getStrSubstitutor().setVariableResolver(null); + } + catch (Throwable throwable) + { + throwable.printStackTrace(); + throw new RuntimeException("JNDI patch failed"); + } + } +}