diff --git a/gradle.properties b/gradle.properties index 563a511..39cca0f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,6 +5,8 @@ org.gradle.parallel = true org.gradle.vfs.watch = false org.gradle.jvmargs = -Xmx4G -Dfile.encoding=UTF-8 -Dgraal.CompilerConfiguration=community -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true -Dgraal.SpeculativeGuardMovement=true -Dgraal.WriteableCodeCache=true +paper.runMemoryGb = 8 + org.plazmamc.alwaysuptodate.paper.repository = https://github.com/PaperMC/Paper org.plazmamc.alwaysuptodate.purpur.repository = https://github.com/PurpurMC/Purpur diff --git a/patches/server/0007-Warn-on-startup.patch b/patches/server/0007-Warn-on-startup.patch index 086229e..d1d00a7 100644 --- a/patches/server/0007-Warn-on-startup.patch +++ b/patches/server/0007-Warn-on-startup.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Warn on startup diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index 2579b32009a5f5e288edf56ee8f1246cd70343fc..c59a1b6a365bf80ac913c1a9c939ad2cc5f3b963 100644 +index 2579b32009a5f5e288edf56ee8f1246cd70343fc..dafd37b3a31fbf63113787ccf6697651f5e1770d 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java @@ -127,6 +127,18 @@ public class Main { @@ -17,7 +17,7 @@ index 2579b32009a5f5e288edf56ee8f1246cd70343fc..c59a1b6a365bf80ac913c1a9c939ad2c + LOGGER.warn("Warning! Plazma may cause unexpected problems, so be sure to test it thoroughly before using it on a public server."); + if (com.destroystokyo.paper.PaperVersionFetcher.DEVELOPMENT) { + LOGGER.error("*********************** CAUTION ***********************"); -+ LOGGER.error("This version is a developed version of Plazma."); ++ LOGGER.error("This version is a development version of Plazma."); + LOGGER.error("Nobody knows what kind of problem you're going to have, and there's always the possibility of unexpected problems."); + LOGGER.error("Never use this version on a public server, and after you've tested it enough before using it!"); + LOGGER.error("*******************************************************"); diff --git a/patches/server/0009-Port-SparklyPaper-patches.patch b/patches/server/0009-Port-SparklyPaper-patches.patch index 73938ca..bdf0fc2 100644 --- a/patches/server/0009-Port-SparklyPaper-patches.patch +++ b/patches/server/0009-Port-SparklyPaper-patches.patch @@ -191,6 +191,18 @@ index 2903c9a2480ac505f0931d29ac3c5013037e65f1..39f7a4d3711a182b30d5b8eb77c23541 // Paper start for (final io.papermc.paper.chunk.SingleThreadChunkRegionManager regionManager : worldserver.getChunkSource().chunkMap.regionManagers) { regionManager.recalculateRegions(); +diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +index 8289334e77999f72214c330a3306cbfeb17afbf1..f661418d27f5692a51b880f64180866f7d19d66a 100644 +--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +@@ -224,6 +224,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + this.plazmaConfigurations.initializeGlobalConfiguration(this.registryAccess()); // Plazma - Configurable Plazma + this.plazmaConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); // Plazma - Configurable Plazma ++ net.sparklypower.sparklypaper.HalloweenManager.startSyncEpochTask(); // Plazma - Port SparklyPaper patches; Optimize Spooky Season + // Paper end - initialize global and world-defaults configuration + // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save + if (this.convertOldUsers()) { diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java index 4e6fccec4f5ca14562bf5bae495ac36c14982d85..9162c6338dbb516ce60f4853e57da6e49be79282 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -304,7 +316,7 @@ index f890738d3bb9fb5e70a9d323c6cec97f9948f9cf..eb3fc1af68768383d524cf0f50c4f4b3 } } diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -index 47a7c7f9527e1c4ea457eeafe0e11145653a871f..ed5a98b7e9ef2879fdcb2d5a77aeb1d483682a14 100644 +index 47a7c7f9527e1c4ea457eeafe0e11145653a871f..d2151a355e3ee8a6f8b4f28b2ce7ac382c939ad3 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java @@ -306,7 +306,7 @@ public class Bat extends AmbientCreature { @@ -324,7 +336,7 @@ index 47a7c7f9527e1c4ea457eeafe0e11145653a871f..ed5a98b7e9ef2879fdcb2d5a77aeb1d4 + // Plazma start - Port SparklyPaper patches; Optimize Spooky Season + private static boolean isSpookySeason(Level level) { + if (level.purpurConfig.forceHalloweenSeason) return true; -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.spookyOptimize.enabled) ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.spookyOptimize) + return net.sparklypower.sparklypaper.HalloweenManager.isSpookySeason() + || net.sparklypower.sparklypaper.HalloweenManager.isHalloween(); + return isHalloween(); @@ -332,7 +344,7 @@ index 47a7c7f9527e1c4ea457eeafe0e11145653a871f..ed5a98b7e9ef2879fdcb2d5a77aeb1d4 + + public static boolean isHalloweenSeason(Level level) { + if (level.purpurConfig.forceHalloweenSeason) return true; -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.spookyOptimize.enabled) ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.spookyOptimize) + return net.sparklypower.sparklypaper.HalloweenManager.isHalloween(); + return isHalloween(); + } @@ -731,10 +743,10 @@ index fd637415625fdabcac07e120e9168d09c06141d4..37120fcb31f4c9a90be37db252b17eb9 } diff --git a/src/main/java/net/sparklypower/sparklypaper/HalloweenManager.java b/src/main/java/net/sparklypower/sparklypaper/HalloweenManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..0df2a464845193382bd559141955e31337c9e4e2 +index 0000000000000000000000000000000000000000..f8c26e26025d7a7b5489ed5b3274ba734db27a1d --- /dev/null +++ b/src/main/java/net/sparklypower/sparklypaper/HalloweenManager.java -@@ -0,0 +1,100 @@ +@@ -0,0 +1,78 @@ +package net.sparklypower.sparklypaper; + +import com.mojang.logging.LogUtils; @@ -755,8 +767,7 @@ index 0000000000000000000000000000000000000000..0df2a464845193382bd559141955e313 + +public class HalloweenManager { + -+ private static final Logger LOGGER = LogUtils.getLogger(); -+ private static final CountDownLatch LATCH = new CountDownLatch(1); ++ private static final Logger LOGGER = LogUtils.getClassLogger(); + private static final ScheduledExecutorService EXECUTOR = Executors.newSingleThreadScheduledExecutor(factory -> { + Thread thread = new Thread(factory); + thread.setName("halloween-timer-updater"); @@ -764,30 +775,10 @@ index 0000000000000000000000000000000000000000..0df2a464845193382bd559141955e313 + return thread; + }); + -+ private static ScheduledFuture TASK; -+ private static Pair spookyStart; -+ private static Pair spookyEnd; -+ private static Pair halloweenStart; -+ private static Pair halloweenEnd; -+ ++ private static ScheduledFuture future; + private static Pair spookyEpoch; + private static Pair halloweenEpoch; + -+ public static void syncConfiguration() { -+ if (!get().entity.spookyOptimize.enabled && TASK != null && !TASK.isCancelled()) { -+ TASK.cancel(true); -+ TASK = null; -+ return; -+ } else if (get().entity.spookyOptimize.enabled && TASK == null) { -+ startSyncEpochTask(); -+ } -+ spookyStart = get().entity.spookyOptimize.spookySeason.start.toPair(); -+ spookyEnd = get().entity.spookyOptimize.spookySeason.end.toPair(); -+ halloweenStart = get().entity.spookyOptimize.halloween.start.toPair(); -+ halloweenEnd = get().entity.spookyOptimize.halloween.end.toPair(); -+ syncEpoch(); -+ } -+ + private static long getEpochMillisAtDate(Month month, int day, boolean start) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime target = LocalDateTime.of( @@ -801,31 +792,30 @@ index 0000000000000000000000000000000000000000..0df2a464845193382bd559141955e313 + private static void syncEpoch() { + LOGGER.info("Updating Spooky Season and Halloween epoch..."); + spookyEpoch = Pair.of( -+ getEpochMillisAtDate(spookyStart.first(), spookyStart.second(), true), -+ getEpochMillisAtDate(spookyEnd.first(), spookyEnd.second(), false) ++ getEpochMillisAtDate(Month.OCTOBER, 20, true), ++ getEpochMillisAtDate(Month.NOVEMBER, 3, false) + ); + halloweenEpoch = Pair.of( -+ getEpochMillisAtDate(halloweenStart.first(), halloweenStart.second(), true), -+ getEpochMillisAtDate(halloweenEnd.first(), halloweenEnd.second(), false) ++ getEpochMillisAtDate(Month.OCTOBER, 31, true), ++ getEpochMillisAtDate(Month.OCTOBER, 31, false) + ); + LOGGER.info("Successfully updated Spooky Season and Halloween epoch"); + } + -+ private static void startSyncEpochTask() { -+ if (!get().entity.spookyOptimize.enabled) return; -+ final AtomicBoolean first = new AtomicBoolean(false); -+ TASK = EXECUTOR.scheduleAtFixedRate(() -> { -+ syncEpoch(); -+ if (first.get()) LATCH.countDown(); -+ first.set(false); -+ }, 0, 90, TimeUnit.DAYS); -+ try { -+ LATCH.await(); -+ } catch (InterruptedException e) { -+ throw new RuntimeException(e); ++ public static void syncConfiguration() { ++ if (get().entity.spookyOptimize && future == null) { ++ startSyncEpochTask(); ++ } else if (!get().entity.spookyOptimize && future != null) { ++ future.cancel(true); ++ future = null; + } + } + ++ public static void startSyncEpochTask() { ++ if (!get().entity.spookyOptimize) return; ++ future = EXECUTOR.scheduleAtFixedRate(HalloweenManager::syncEpoch, 0, 90, TimeUnit.DAYS); ++ } ++ + public static boolean isSpookySeason() { + return spookyEpoch.first() <= System.currentTimeMillis() && System.currentTimeMillis() <= spookyEpoch.second(); + } @@ -875,56 +865,15 @@ index 8149b9c51b78eb5c689b7218a2ca3aab60e73bcf..b9a303f6280a2f6ad3616da152922a4f } diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 57d29f8f3bc89529db9ee8f6dc3fffdbd4a03ceb..5b0d1ad2d3e8fb7ddb9f58288c175ffd0f4ccd57 100644 +index 57d29f8f3bc89529db9ee8f6dc3fffdbd4a03ceb..73dd69941a004b4a2ec244f28d8683e9bdb0a445 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -40,9 +40,53 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -40,9 +40,12 @@ public class GlobalConfiguration extends ConfigurationPart { public Entity entity; public class Entity extends ConfigurationPart { + boolean skipSqrWhenNoDeltaChanges = OPTIMIZE; -+ -+ public SpookyOptimize spookyOptimize; -+ public class SpookyOptimize extends ConfigurationPart { -+ -+ public boolean enabled = OPTIMIZE; -+ public Time spookySeason = new Time(10, 20, 11, 3); -+ public Time halloween = new Time(11, 31, 11, 31); -+ -+ @PostProcess -+ public void post() { -+ net.sparklypower.sparklypaper.HalloweenManager.syncConfiguration(); -+ } -+ -+ public class Time extends ConfigurationPart { -+ -+ public Date start; -+ public Date end; -+ -+ public class Date extends ConfigurationPart { -+ -+ int month; -+ int day; -+ -+ Date(int month, int day) { -+ this.month = month; -+ this.day = day; -+ } -+ -+ public it.unimi.dsi.fastutil.Pair toPair() { -+ return it.unimi.dsi.fastutil.Pair.of(java.time.Month.of(this.month), this.day); -+ } -+ -+ } -+ -+ Time(int startMonth, int startDay, int endMonth, int endDay) { -+ this.start = new Date(startMonth, startDay); -+ this.end = new Date(endMonth, endDay); -+ } -+ -+ } -+ -+ } ++ public boolean spookyOptimize = OPTIMIZE; @PostProcess public void post() { @@ -932,7 +881,7 @@ index 57d29f8f3bc89529db9ee8f6dc3fffdbd4a03ceb..5b0d1ad2d3e8fb7ddb9f58288c175ffd } } -@@ -50,9 +94,11 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -50,9 +53,11 @@ public class GlobalConfiguration extends ConfigurationPart { public World world; public class World extends ConfigurationPart { diff --git a/patches/server/0013-Tweak-console-logging.patch b/patches/server/0013-Tweak-console-logging.patch index 42e8666..22448bf 100644 --- a/patches/server/0013-Tweak-console-logging.patch +++ b/patches/server/0013-Tweak-console-logging.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Tweak console logging diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 8289334e77999f72214c330a3306cbfeb17afbf1..361dc9c3434d9b4ac4b9966fa09b17f6820b0f22 100644 +index f661418d27f5692a51b880f64180866f7d19d66a..ddfbc49a693d3100e915f5083f1f8e99df2d4b64 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -193,16 +193,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -25,9 +25,9 @@ index 8289334e77999f72214c330a3306cbfeb17afbf1..361dc9c3434d9b4ac4b9966fa09b17f6 DedicatedServer.LOGGER.info("Loading properties"); DedicatedServerProperties dedicatedserverproperties = this.settings.getProperties(); -@@ -225,6 +215,17 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - this.plazmaConfigurations.initializeGlobalConfiguration(this.registryAccess()); // Plazma - Configurable Plazma +@@ -226,6 +216,17 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface this.plazmaConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); // Plazma - Configurable Plazma + net.sparklypower.sparklypaper.HalloweenManager.startSyncEpochTask(); // Plazma - Port SparklyPaper patches; Optimize Spooky Season // Paper end - initialize global and world-defaults configuration + // Plazma - Tweak console logging; Moved down + // Paper start - detect running as root @@ -43,7 +43,7 @@ index 8289334e77999f72214c330a3306cbfeb17afbf1..361dc9c3434d9b4ac4b9966fa09b17f6 // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save if (this.convertOldUsers()) { this.getProfileCache().save(false); // Paper -@@ -330,6 +331,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -331,6 +332,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; // Paper end - Add Velocity IP Forwarding Support @@ -51,7 +51,7 @@ index 8289334e77999f72214c330a3306cbfeb17afbf1..361dc9c3434d9b4ac4b9966fa09b17f6 if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -343,7 +345,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -344,7 +346,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); } // Spigot end @@ -73,10 +73,10 @@ index b863f6fe65c796a1d3102cc3eddb5d6c5becd3ac..2707a96f9e22469d008ec7d2fa8a8c49 this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message); diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 306b503737394a51407a03f7f5cb8f7bd4b0eea2..fa01da3de63db24b069d7888283650394bf4af83 100644 +index 73dd69941a004b4a2ec244f28d8683e9bdb0a445..e725f6e8205976a7b137aefb98b874cf4ae14893 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -109,4 +109,13 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -68,4 +68,13 @@ public class GlobalConfiguration extends ConfigurationPart { } diff --git a/patches/server/0015-Completely-remove-Mojang-Profiler.patch b/patches/server/0015-Completely-remove-Mojang-Profiler.patch index 7528dfd..8081e47 100644 --- a/patches/server/0015-Completely-remove-Mojang-Profiler.patch +++ b/patches/server/0015-Completely-remove-Mojang-Profiler.patch @@ -361,10 +361,10 @@ index 8c587f829c5e8c6b6df3150024c4ae704988c47b..319f484b535143a94ee2da11114acacc } +// Plazma end - Completely remove Mojang's Profiler diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 361dc9c3434d9b4ac4b9966fa09b17f6820b0f22..705a71ca533ad9b6dab394c8cbcbb9814d72ec84 100644 +index ddfbc49a693d3100e915f5083f1f8e99df2d4b64..6d39a0d5455fbb0af3916b751d02386af3aa3598 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -922,11 +922,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -923,11 +923,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface return this.settings.getProperties().serverResourcePackInfo; } @@ -1377,7 +1377,7 @@ index c5454b92ca2565461c799d7340160f9fb72c1b0f..760a4f4b15a02f9cbb7a368961286ae3 + */ // Plazma - Completely remove Mojang's Profiler } 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 7efe0fc559463bf84fc9d7f66339d096993bcb43..694fe048daec091ac1ebd372cfc3db0d8da731fa 100644 +index 37120fcb31f4c9a90be37db252b17eb93db2cb0f..8764e00de0ae8730bf1f12414f431d6cf75613b8 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -26,7 +26,7 @@ import net.minecraft.network.FriendlyByteBuf; diff --git a/patches/server/0017-Reduce-create-random-instance.patch b/patches/server/0017-Reduce-create-random-instance.patch index 59eeed7..76f676d 100644 --- a/patches/server/0017-Reduce-create-random-instance.patch +++ b/patches/server/0017-Reduce-create-random-instance.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Reduce create random instance diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index be39e6292e4d6571f3b8a92358e35f9496ec8cde..cbbf9f5c775850301a012c613257ca7a8a134f1c 100644 +index d1dec1a4671f59fb1b7fe6a2188bd7581a33e40e..ee5914eddb70adbda4c24b7c31fc4ca34ce06005 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -235,6 +235,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop