diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index f46e7cc94f..76de6823a4 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -565,10 +565,12 @@ if (!iworlddataserver.isInitialized()) { try { -@@ -427,30 +727,8 @@ - iworlddataserver.setInitialized(true); - } +@@ -425,32 +725,10 @@ + } + iworlddataserver.setInitialized(true); +- } +- - this.getPlayerList().addWorldborderListener(worldserver); - if (this.worldData.getCustomBossEvents() != null) { - this.getCustomBossEvents().load(this.worldData.getCustomBossEvents(), this.registryAccess()); @@ -589,8 +591,8 @@ - worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(worldserver1.getWorldBorder())); - this.levels.put(resourcekey1, worldserver1); - } -- } -- + } + - worldborder.applySettings(iworlddataserver.getWorldBorder()); } + // CraftBukkit end @@ -910,7 +912,7 @@ this.nextTickTimeNanos += i; try { -@@ -830,6 +1269,13 @@ +@@ -830,6 +1269,14 @@ this.services.profileCache().clearExecutor(); } @@ -921,10 +923,11 @@ + } catch (Exception ignored) { + } + // CraftBukkit end ++ io.papermc.paper.log.CustomLogManager.forceReset(); // Paper - Reset loggers after shutdown this.onServerExit(); } -@@ -889,9 +1335,16 @@ +@@ -889,9 +1336,16 @@ } private boolean haveTime() { @@ -942,7 +945,7 @@ public static boolean throwIfFatalException() { RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get(); -@@ -903,7 +1356,7 @@ +@@ -903,7 +1357,7 @@ } public static void setFatalException(RuntimeException exception) { @@ -951,7 +954,7 @@ } @Override -@@ -961,6 +1414,7 @@ +@@ -961,6 +1415,7 @@ if (super.pollTask()) { return true; } else { @@ -959,7 +962,7 @@ if (this.tickRateManager.isSprinting() || this.haveTime()) { Iterator iterator = this.getAllLevels().iterator(); -@@ -968,16 +1422,16 @@ +@@ -968,16 +1423,16 @@ ServerLevel worldserver = (ServerLevel) iterator.next(); if (worldserver.getChunkSource().pollTask()) { @@ -979,7 +982,7 @@ Profiler.get().incrementCounter("runTask"); super.doRunTask(ticktask); } -@@ -1025,6 +1479,7 @@ +@@ -1025,6 +1480,7 @@ } public void tickServer(BooleanSupplier shouldKeepTicking) { @@ -987,7 +990,7 @@ long i = Util.getNanos(); int j = this.pauseWhileEmptySeconds() * 20; -@@ -1041,11 +1496,13 @@ +@@ -1041,11 +1497,13 @@ this.autoSave(); } @@ -1001,7 +1004,7 @@ ++this.tickCount; this.tickRateManager.tick(); this.tickChildren(shouldKeepTicking); -@@ -1055,12 +1512,18 @@ +@@ -1055,12 +1513,18 @@ } --this.ticksUntilAutosave; @@ -1021,7 +1024,7 @@ gameprofilerfiller.push("tallying"); long k = Util.getNanos() - i; int l = this.tickCount % 100; -@@ -1069,12 +1532,17 @@ +@@ -1069,12 +1533,17 @@ this.aggregatedTickTimesNanos += k; this.tickTimesNanos[l] = k; this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; @@ -1040,7 +1043,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); ProfilerFiller gameprofilerfiller = Profiler.get(); -@@ -1123,7 +1591,7 @@ +@@ -1123,7 +1592,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players serverping_serverpingplayersample = this.buildPlayerStatus(); @@ -1049,7 +1052,7 @@ } private ServerStatus.Players buildPlayerStatus() { -@@ -1133,7 +1601,7 @@ +@@ -1133,7 +1602,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(i, list.size(), List.of()); } else { @@ -1058,7 +1061,7 @@ ObjectArrayList objectarraylist = new ObjectArrayList(j); int k = Mth.nextInt(this.random, 0, list.size() - j); -@@ -1154,24 +1622,58 @@ +@@ -1154,24 +1623,58 @@ this.getPlayerList().getPlayers().forEach((entityplayer) -> { entityplayer.connection.suspendFlushing(); }); @@ -1118,7 +1121,7 @@ gameprofilerfiller.push("tick"); -@@ -1186,7 +1688,9 @@ +@@ -1186,7 +1689,9 @@ gameprofilerfiller.pop(); gameprofilerfiller.pop(); @@ -1128,7 +1131,7 @@ gameprofilerfiller.popPush("connection"); this.tickConnection(); -@@ -1267,6 +1771,22 @@ +@@ -1267,6 +1772,22 @@ return (ServerLevel) this.levels.get(key); } @@ -1151,7 +1154,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1296,7 +1816,7 @@ +@@ -1296,7 +1817,7 @@ @DontObfuscate public String getServerModName() { @@ -1160,7 +1163,7 @@ } public SystemReport fillSystemReport(SystemReport details) { -@@ -1347,7 +1867,7 @@ +@@ -1347,7 +1868,7 @@ @Override public void sendSystemMessage(Component message) { @@ -1169,7 +1172,7 @@ } public KeyPair getKeyPair() { -@@ -1385,11 +1905,14 @@ +@@ -1385,11 +1906,14 @@ } } @@ -1189,7 +1192,7 @@ } } -@@ -1403,7 +1926,7 @@ +@@ -1403,7 +1927,7 @@ while (iterator.hasNext()) { ServerLevel worldserver = (ServerLevel) iterator.next(); @@ -1198,7 +1201,7 @@ } } -@@ -1481,10 +2004,20 @@ +@@ -1481,10 +2005,20 @@ @Override public String getMotd() { @@ -1220,7 +1223,7 @@ this.motd = motd; } -@@ -1507,7 +2040,7 @@ +@@ -1507,7 +2041,7 @@ } public ServerConnectionListener getConnection() { @@ -1229,7 +1232,7 @@ } public boolean isReady() { -@@ -1632,13 +2165,19 @@ +@@ -1632,13 +2166,19 @@ return this.functionManager; } @@ -1251,7 +1254,7 @@ }, this).thenCompose((immutablelist) -> { MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist); List> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess()); -@@ -1654,17 +2193,21 @@ +@@ -1654,17 +2194,21 @@ }).thenAcceptAsync((minecraftserver_reloadableresources) -> { this.resources.close(); this.resources = minecraftserver_reloadableresources; @@ -1273,7 +1276,7 @@ }, this); if (this.isSameThread()) { -@@ -1789,14 +2332,15 @@ +@@ -1789,14 +2333,15 @@ if (this.isEnforceWhitelist()) { PlayerList playerlist = source.getServer().getPlayerList(); UserWhiteList whitelist = playerlist.getWhiteList(); @@ -1291,7 +1294,7 @@ } } -@@ -1952,7 +2496,7 @@ +@@ -1952,7 +2497,7 @@ final List list = Lists.newArrayList(); final GameRules gamerules = this.getGameRules(); @@ -1300,7 +1303,7 @@ @Override public > void visit(GameRules.Key key, GameRules.Type type) { list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key))); -@@ -2058,7 +2602,7 @@ +@@ -2058,7 +2603,7 @@ try { label51: { @@ -1309,7 +1312,7 @@ try { arraylist = Lists.newArrayList(NativeModuleLister.listModules()); -@@ -2105,9 +2649,24 @@ +@@ -2105,9 +2650,24 @@ if (bufferedwriter != null) { bufferedwriter.close(); } @@ -1334,7 +1337,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { -@@ -2225,18 +2784,24 @@ +@@ -2225,18 +2785,24 @@ } public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) { @@ -1363,7 +1366,7 @@ } public boolean logIPs() { -@@ -2379,4 +2944,30 @@ +@@ -2379,4 +2945,30 @@ public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) { } diff --git a/paper-server/src/main/java/io/papermc/paper/log/CustomLogManager.java b/paper-server/src/main/java/io/papermc/paper/log/CustomLogManager.java new file mode 100644 index 0000000000..c1d3bac79b --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/log/CustomLogManager.java @@ -0,0 +1,26 @@ +package io.papermc.paper.log; + +import java.util.logging.LogManager; + +public class CustomLogManager extends LogManager { + private static CustomLogManager instance; + + public CustomLogManager() { + instance = this; + } + + @Override + public void reset() { + // Ignore calls to this method + } + + private void superReset() { + super.reset(); + } + + public static void forceReset() { + if (instance != null) { + instance.superReset(); + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index dd2e1ff287..1c2439ffc1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -19,6 +19,12 @@ public class Main { public static boolean useJline = true; public static boolean useConsole = true; + // Paper start - Reset loggers after shutdown + static { + System.setProperty("java.util.logging.manager", "io.papermc.paper.log.CustomLogManager"); + } + // Paper end - Reset loggers after shutdown + public static void main(String[] args) { // Paper start final String warnWhenLegacyFormattingDetected = String.join(".", "net", "kyori", "adventure", "text", "warnWhenLegacyFormattingDetected");