diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4434243..9581767 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '21' + java-version: '25' - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - name: Configure Git User Details diff --git a/build-data/buildSrc.build.gradle.kts.patch b/build-data/buildSrc.build.gradle.kts.patch index 3725480..c1f5102 100644 --- a/build-data/buildSrc.build.gradle.kts.patch +++ b/build-data/buildSrc.build.gradle.kts.patch @@ -1,6 +1,6 @@ --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts -@@ -8,6 +_,7 @@ +@@ -9,6 +_,7 @@ mavenLocal() mavenCentral() gradlePluginPortal() @@ -8,7 +8,7 @@ } fun convertPlugin(plugin: Provider): String { -@@ -22,7 +_,7 @@ +@@ -23,7 +_,7 @@ implementation(convertPlugin(libs.plugins.profiles)) implementation(convertPlugin(libs.plugins.kotlin.jvm)) implementation(convertPlugin(libs.plugins.lombok)) diff --git a/build.gradle.kts b/build.gradle.kts index e80a983..1b79a03 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -83,7 +83,7 @@ subprojects { extensions.configure { toolchain { - languageVersion = JavaLanguageVersion.of(21) + languageVersion = JavaLanguageVersion.of(25) } } @@ -106,7 +106,7 @@ subprojects { } tasks.withType { options.encoding = Charsets.UTF_8.name() - options.release = 21 + options.release = 25 options.isFork = true } tasks.withType { diff --git a/gradle.properties b/gradle.properties index 6861f66..89fa906 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,11 @@ group=com.legitimoose.legitslimepaper -version=1.21.10-R0.1-SNAPSHOT -mcVersion=1.21.10 +version=26.1.2.build.61-stable +mcVersion=26.1.2 #Update with ASP!! (also update gradle/libs.versions.toml) -aspRef=cd28d91fa92818b296ad914b584f9aae911e4045 -apiVersion=4.2.0-SNAPSHOT +aspRef=2e69d9f6e20da479e8a3edea0a57ce1a16888fe7 +apiVersion=26.1.2 +aspApiVersion=4.2.0-SNAPSHOT org.gradle.caching=true org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0cb3aa9..c28a2da 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -adventure = "4.24.0" -annotations = "26.0.1" +adventure = "4.26.1" +annotations = "1.0.0" autoservice = "1.1.1" blossom = "2.1.0" bstats = "3.1.0" cloud-core = "2.0.0" -cloud-minecraft = "2.0.0-beta.10" +cloud-minecraft = "2.0.0-SNAPSHOT" configurate = "4.1.2" indra-git = "3.1.3" gradle-profiles = "0.54.0" @@ -15,7 +15,7 @@ lettuce = "6.5.1.RELEASE" lombok = "1.18.36" lombok-plugin = "8.11" mongo = "5.2.1" -paperweight = "2.0.0-beta.18" +paperweight = "2.0.0-SNAPSHOT" plugin-yml-paper = "0.6.0" shadow = "9.2.2" slf4j = "2.0.16" @@ -33,7 +33,7 @@ shadow = { id = "com.gradleup.shadow", version.ref = "shadow" } [libraries] adventure-nbt = { module = "net.kyori:adventure-nbt", version.ref = "adventure" } -annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" } +annotations = { module = "org.jspecify:jspecify", version.ref = "annotations" } auto-service = { module = "com.google.auto.service:auto-service", version.ref = "autoservice" } auto-service-annotations = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoservice" } bstats = { module = "org.bstats:bstats-bukkit", version.ref = "bstats" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 002b867..c61a118 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/legitslimepaper-api/build.gradle.kts.patch b/legitslimepaper-api/build.gradle.kts.patch index 02e9a93..e9a4053 100644 --- a/legitslimepaper-api/build.gradle.kts.patch +++ b/legitslimepaper-api/build.gradle.kts.patch @@ -1,6 +1,6 @@ --- a/aspaper-api/build.gradle.kts +++ b/aspaper-api/build.gradle.kts -@@ -101,17 +_,21 @@ +@@ -103,17 +_,21 @@ java { srcDir(generatedDir) srcDir(file("../paper-api/src/main/java")) diff --git a/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/SlimeNMSBridgeImpl.java.patch b/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/SlimeNMSBridgeImpl.java.patch index dad2d5a..fbbf616 100644 --- a/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/SlimeNMSBridgeImpl.java.patch +++ b/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/SlimeNMSBridgeImpl.java.patch @@ -1,13 +1,15 @@ --- a/src/main/java/com/infernalsuite/asp/SlimeNMSBridgeImpl.java +++ b/src/main/java/com/infernalsuite/asp/SlimeNMSBridgeImpl.java -@@ -79,8 +_,10 @@ +@@ -80,9 +_,11 @@ + // See MinecraftServer loading logic // Some stuff is needed when loading overworld world SlimeLevelInstance instance = ((SlimeInMemoryWorld) this.loadInstance(defaultWorld, Level.OVERWORLD)).getInstance(); - DimensionDataStorage worldpersistentdata = instance.getDataStorage(); -+ instance.getServer().readScoreboard(worldpersistentdata); // Moose +- SavedDataStorage worldpersistentdata = instance.getDataStorage(); ++ SavedDataStorage worldpersistentdata = instance.getServer().getDataStorage(); // Moose - Ensure vanilla behavior ++ instance.getServer().getScoreboard().load(worldpersistentdata.computeIfAbsent(net.minecraft.world.scores.ScoreboardSaveData.TYPE).getData()); // Moose instance.getCraftServer().scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(instance.getServer(), instance.getScoreboard()); instance.getServer().commandStorage = new CommandStorage(worldpersistentdata); -+ instance.getServer().worldData = instance.serverLevelData; // Moose - Set default spawn location correctly (and prob more) ++// instance.getServer().worldData = instance.serverLevelData; // Moose - Set default spawn location correctly (and prob more) return true; } diff --git a/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/level/SlimeLevelInstance.java.patch b/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/level/SlimeLevelInstance.java.patch index 3c9c94a..b7f152d 100644 --- a/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/level/SlimeLevelInstance.java.patch +++ b/legitslimepaper-server/aspaper-patches/files/src/main/java/com/infernalsuite/asp/level/SlimeLevelInstance.java.patch @@ -1,40 +1,52 @@ --- a/src/main/java/com/infernalsuite/asp/level/SlimeLevelInstance.java +++ b/src/main/java/com/infernalsuite/asp/level/SlimeLevelInstance.java -@@ -68,16 +_,10 @@ - public static LevelStorageSource CUSTOM_LEVEL_STORAGE; +@@ -46,10 +_,7 @@ + import net.minecraft.world.level.gamerules.GameRules; + import net.minecraft.world.level.levelgen.WorldGenSettings; + import net.minecraft.world.level.levelgen.WorldOptions; +-import net.minecraft.world.level.storage.LevelData; +-import net.minecraft.world.level.storage.LevelResource; +-import net.minecraft.world.level.storage.LevelStorageSource; +-import net.minecraft.world.level.storage.PrimaryLevelData; ++import net.minecraft.world.level.storage.*; + import net.minecraft.world.level.validation.DirectoryValidator; + import org.apache.commons.io.FileUtils; + import org.bukkit.Bukkit; +@@ -80,17 +_,9 @@ + private static final Logger LOGGER = LogUtils.getClassLogger(); static { - try { - Path path = Files.createTempDirectory("swm-" + UUID.randomUUID().toString().substring(0, 5)).toAbsolutePath(); - DirectoryValidator directoryvalidator = LevelStorageSource.parseValidator(path.resolve("allowed_symlinks.txt")); -- CUSTOM_LEVEL_STORAGE = new LevelStorageSource(path, path, directoryvalidator, DataFixers.getDataFixer()); +- CUSTOM_LEVEL_STORAGE_ACCESS = new LevelStorageSource(path, path, directoryvalidator, DataFixers.getDataFixer()) +- .createAccess("slime"); - - FileUtils.forceDeleteOnExit(path.toFile()); - - } catch (IOException ex) { - throw new IllegalStateException("Couldn't create dummy file directory.", ex); - } -+ // Moose start -+ Path path = MinecraftServer.getServer().server.getWorldContainer().toPath(); -+ CUSTOM_LEVEL_STORAGE = LevelStorageSource.createDefault(path); ++ // Moose start - Ensure the data directory is mapped correctly ++ CUSTOM_LEVEL_STORAGE_ACCESS = MinecraftServer.getServer().storageSource; + // Moose end } private static final ExecutorService WORLD_SAVER_SERVICE = Executors.newFixedThreadPool(4, new ThreadFactoryBuilder() -@@ -91,7 +_,7 @@ - org.bukkit.World.Environment environment) throws IOException { - - super(slimeBootstrap, MinecraftServer.getServer(), MinecraftServer.getServer().executor, -- CUSTOM_LEVEL_STORAGE.createAccess(slimeBootstrap.initial().getName() + UUID.randomUUID(), dimensionKey), -+ CUSTOM_LEVEL_STORAGE.createAccess("dat_files", dimensionKey), // Moose - primaryLevelData, worldKey, worldDimension, false, 0, - Collections.emptyList(), true, null, environment, null, null); +@@ -139,7 +_,7 @@ + environment, + null, + null, +- new ReadOnlyDimensionDataStorage(CUSTOM_LEVEL_STORAGE_ACCESS.getDimensionPath(dimensionKey), MinecraftServer.getServer().getFixerUpper(), MinecraftServer.getServer().registryAccess()), ++ new SavedDataStorage(CUSTOM_LEVEL_STORAGE_ACCESS.getDimensionPath(dimensionKey), MinecraftServer.getServer().getFixerUpper(), MinecraftServer.getServer().registryAccess()), + data + ); this.slimeInstance = new SlimeInMemoryWorld(slimeBootstrap, this); -@@ -169,6 +_,7 @@ +@@ -213,6 +_,7 @@ Bukkit.getPluginManager().callEvent(new WorldSaveEvent(getWorld())); //this.getChunkSource().save(forceSave); -+ this.getDataStorage().saveAndJoin(); // Moose - this.serverLevelData.setCustomBossEvents(MinecraftServer.getServer().getCustomBossEvents().save(MinecraftServer.getServer().registryAccess())); - ++ this.getDataStorage().saveAndJoin(); if (MinecraftServer.getServer().isStopped()) { // Make sure the world gets saved before stopping the server by running it from the main thread + saveInternal().get(); // Async wait for it to finish + } else { diff --git a/legitslimepaper-server/build.gradle.kts.patch b/legitslimepaper-server/build.gradle.kts.patch index 23c5238..0ff2b13 100644 --- a/legitslimepaper-server/build.gradle.kts.patch +++ b/legitslimepaper-server/build.gradle.kts.patch @@ -1,30 +1,30 @@ --- a/aspaper-server/build.gradle.kts +++ b/aspaper-server/build.gradle.kts -@@ -32,7 +_,22 @@ +@@ -31,7 +_,22 @@ } } - activeFork = aspaper -+ val legitslimepaper = forks.register("legitslimepaper") { -+ forks = aspaper -+ upstream.patchRepo("paperServer") { -+ upstreamRepo = aspaper.patchedRepo("paperServer") -+ patchesDir = rootDirectory.dir("legitslimepaper-server/paper-patches") -+ outputDir = rootDirectory.dir("paper-server") -+ } -+ upstream.patchDir("aspaperServer") { -+ upstreamPath = "aspaper-server" -+ excludes = setOf("src/minecraft", "paper-patches", "minecraft-patches", "build.gradle.kts", "build.gradle.kts.patch") -+ patchesDir = rootDirectory.dir("legitslimepaper-server/aspaper-patches") -+ outputDir = rootDirectory.dir("aspaper-server") -+ } -+ } ++ val legitslimepaper = forks.register("legitslimepaper") { ++ forks = aspaper ++ upstream.patchRepo("paperServer") { ++ upstreamRepo = aspaper.patchedRepo("paperServer") ++ patchesDir = rootDirectory.dir("legitslimepaper-server/paper-patches") ++ outputDir = rootDirectory.dir("paper-server") ++ } ++ upstream.patchDir("aspaperServer") { ++ upstreamPath = "aspaper-server" ++ excludes = setOf("src/minecraft", "paper-patches", "minecraft-patches", "build.gradle.kts", "build.gradle.kts.patch") ++ patchesDir = rootDirectory.dir("legitslimepaper-server/aspaper-patches") ++ outputDir = rootDirectory.dir("aspaper-server") ++ } ++ } + -+ activeFork = legitslimepaper ++ activeFork = legitslimepaper - spigot { - enabled = true -@@ -119,10 +_,14 @@ + // updatingMinecraft { + // oldPaperCommit = "7e80cef5198561d0db53406127e5b8bc7af51577" +@@ -101,10 +_,14 @@ main { java { srcDir("../paper-server/src/main/java") } resources { srcDir("../paper-server/src/main/resources") } @@ -39,16 +39,16 @@ } } val log4jPlugins = sourceSets.create("log4jPlugins") { -@@ -150,7 +_,7 @@ +@@ -132,7 +_,7 @@ } dependencies { - implementation(project(":aspaper-api")) //ASP + implementation(project(":legitslimepaper-api")) //ASP + Moose implementation(project(":core")) //ASP - implementation("ca.spottedleaf:concurrentutil:0.0.7") + implementation("ca.spottedleaf:concurrentutil:0.0.10") implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ -@@ -221,14 +_,14 @@ +@@ -195,14 +_,14 @@ val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim() attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", diff --git a/legitslimepaper-server/minecraft-patches/sources/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java.patch b/legitslimepaper-server/minecraft-patches/sources/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java.patch new file mode 100644 index 0000000..07c6071 --- /dev/null +++ b/legitslimepaper-server/minecraft-patches/sources/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java.patch @@ -0,0 +1,11 @@ +--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +@@ -545,6 +_,8 @@ + if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) { + continue; + } ++ if (except instanceof net.minecraft.server.level.ServerPlayer player && !player.getBukkitEntity().canSee(entity.getBukkitEntity())) // Moose - Disable collisions for hidden entities ++ continue; + + if (predicate != null && !predicate.test(entity)) { + continue; diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/Commands.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/Commands.java.patch index 2e23ffa..c51c32f 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/Commands.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -9,16 +_,15 @@ +@@ -9,17 +_,15 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.mojang.brigadier.context.CommandContextBuilder; import com.mojang.brigadier.context.ContextChain; @@ -13,6 +13,7 @@ import com.mojang.logging.LogUtils; -import java.util.HashMap; -import java.util.Map; +-import java.util.Objects; -import java.util.Optional; -import java.util.Set; + @@ -20,7 +21,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.UnaryOperator; -@@ -40,7 +_,6 @@ +@@ -39,7 +_,6 @@ import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -28,23 +29,15 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.protocol.game.ClientboundCommandsPacket; -@@ -145,6 +_,7 @@ - import net.minecraft.util.profiling.jfr.JvmProfiler; - import net.minecraft.world.flag.FeatureFlagSet; - import net.minecraft.world.flag.FeatureFlags; -+import net.minecraft.world.level.BaseCommandBlock; - import net.minecraft.world.level.GameRules; - import org.slf4j.Logger; - -@@ -177,6 +_,7 @@ +@@ -188,6 +_,7 @@ } }; private final CommandDispatcher dispatcher = new CommandDispatcher<>(); + public static CommandDispatcher vanillaCommands = new CommandDispatcher<>(); // Moose - public Commands(Commands.CommandSelection selection, CommandBuildContext context) { + public Commands(final Commands.CommandSelection commandSelection, final CommandBuildContext context) { // Paper start - Brigadier API - modern minecraft overloads that do not use redirects but are copies instead -@@ -293,6 +_,25 @@ +@@ -306,6 +_,25 @@ PublishCommand.register(this.dispatcher); } @@ -70,37 +63,37 @@ // Paper start - Vanilla command permission fixes for (final CommandNode node : this.dispatcher.getRoot().getChildren()) { if (node.getRequirement() == com.mojang.brigadier.builder.ArgumentBuilder.defaultRequirement()) { -@@ -360,6 +_,15 @@ - ContextChain contextChain = finishParsing(parseResults, command, commandSourceStack); +@@ -373,6 +_,15 @@ + ContextChain commandChain = finishParsing(command, commandString, sender); try { + // Moose start - Command block whitelist -+ if (parseResults.getContext().getSource().source instanceof BaseCommandBlock.CloseableCommandBlockSource) { -+ List> context = parseResults.getContext().getNodes(); ++ if (command.getContext().getSource().source instanceof net.minecraft.world.level.BaseCommandBlock.CloseableCommandBlockSource) { ++ List> context = command.getContext().getNodes(); + if (!context.isEmpty() && !context.getFirst().getNode().commandBlockAllowed) { + throw new Exception("Non-vanilla commands cannot be executed in command blocks."); + } + } + // Moose end + - if (contextChain != null) { + if (commandChain != null) { executeCommandInContext( - commandSourceStack, -@@ -370,7 +_,7 @@ + sender, +@@ -383,7 +_,7 @@ } // Paper start } catch (Throwable var12) { // always gracefully handle it, no matter how bad:tm: - if (throwCommandError) throw var12; // rethrow directly if requested + if (throwCommandError) throw new RuntimeException(var12); // Paper + Moose - // Paper end - MutableComponent mutableComponent = Component.literal(var12.getMessage() == null ? var12.getClass().getName() : var12.getMessage()); - LOGGER.error("Command exception: /{}", command, var12); // Paper - always show execution exception in console log -@@ -507,6 +_,20 @@ - runSync(player, bukkit, rootCommandNode); + MutableComponent hover = Component.literal(var12.getMessage() == null ? var12.getClass().getName() : var12.getMessage()); + LOGGER.error("Command exception: /{}", commandString, var12); // Paper - always show execution exception in console log + if (sender.getServer().isDebugging() || LOGGER.isDebugEnabled()) { // Paper - Debugging +@@ -518,6 +_,20 @@ + runSync(player, bukkit, root); }); } + // Moose start - Make sure non-vanilla commands are restricted -+ static class SpecialPermissionCheck implements Predicate, PermissionSource.RestrictedMarker { ++ static class SpecialPermissionCheck implements Predicate, RestrictedMarker { + private final Predicate originalRequirement; + + public SpecialPermissionCheck(Predicate originalRequirement) { @@ -114,21 +107,21 @@ + } + // Moose end - private void runSync(ServerPlayer player, java.util.Collection bukkit, RootCommandNode rootCommandNode) { + private void runSync(ServerPlayer player, java.util.Collection bukkit, RootCommandNode root) { // Paper end - Perf: Async command map building -@@ -521,6 +_,15 @@ +@@ -532,6 +_,15 @@ } } // CraftBukkit end + + // Moose start - Make sure non-vanilla commands are restricted + // Put here since some events might change requirements and all -+ rootCommandNode.getChildren().forEach(commandNode -> { ++ root.getChildren().forEach(commandNode -> { + if (vanillaCommands.getRoot().getChild(commandNode.getName()) == null && !(commandNode.requirement instanceof SpecialPermissionCheck)) { + commandNode.requirement = new SpecialPermissionCheck(commandNode.requirement); + } + }); + // Moose end - player.connection.send(new ClientboundCommandsPacket(rootCommandNode, COMMAND_NODE_INSPECTOR)); + player.connection.send(new ClientboundCommandsPacket(root, COMMAND_NODE_INSPECTOR)); } diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java.patch index ccff13d..608b818 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java +++ b/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java -@@ -345,7 +_,7 @@ +@@ -323,7 +_,7 @@ boolean var9; - try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(entity.problemPath(), LOGGER)) { - TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, entity.registryAccess()); -- entity.saveWithoutId(tagValueOutput); -+ entity.saveWithoutId(tagValueOutput, !com.legitimoose.lsp.MooseConfig.disableEnderchestSerializationInSelectors, false, false); // Moose - Disable enderchest serializing in nbt selectors - if (entity instanceof ServerPlayer serverPlayer) { - ItemStack selectedItem = serverPlayer.getInventory().getSelectedItem(); - if (!selectedItem.isEmpty()) { + try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(e.problemPath(), LOGGER)) { + TagValueOutput output = TagValueOutput.createWithContext(reporter, e.registryAccess()); +- e.saveWithoutId(output); ++ e.saveWithoutId(output, !com.legitimoose.lsp.MooseConfig.disableEnderchestSerializationInSelectors, false, false); // Moose - Disable enderchest serializing in nbt selectors + if (e instanceof ServerPlayer player) { + ItemStack selected = player.getInventory().getSelectedItem(); + if (!selected.isEmpty()) { diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/functions/MacroFunction.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/functions/MacroFunction.java.patch index 6c93ee1..b4e4e5c 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/functions/MacroFunction.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/functions/MacroFunction.java.patch @@ -1,18 +1,12 @@ --- a/net/minecraft/commands/functions/MacroFunction.java +++ b/net/minecraft/commands/functions/MacroFunction.java -@@ -13,6 +_,7 @@ - import java.util.Locale; - import javax.annotation.Nullable; - import net.minecraft.Util; -+import net.minecraft.commands.Commands; - import net.minecraft.commands.ExecutionCommandSource; - import net.minecraft.commands.FunctionInstantiationException; - import net.minecraft.commands.execution.UnboundEntryAction; -@@ -51,6 +_,7 @@ +@@ -50,7 +_,8 @@ + } @Override - public InstantiatedFunction instantiate(@Nullable CompoundTag arguments, CommandDispatcher dispatcher) throws FunctionInstantiationException { -+ dispatcher = (CommandDispatcher) Commands.vanillaCommands; // Moose +- public InstantiatedFunction instantiate(final @Nullable CompoundTag arguments, final CommandDispatcher dispatcher) throws FunctionInstantiationException { ++ public InstantiatedFunction instantiate(final @Nullable CompoundTag arguments, CommandDispatcher dispatcher) throws FunctionInstantiationException { ++ dispatcher = (CommandDispatcher) net.minecraft.commands.Commands.vanillaCommands; // Moose if (arguments == null) { throw new FunctionInstantiationException(Component.translatable("commands.function.error.missing_arguments", Component.translationArg(this.id()))); } else { diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/network/chat/Style.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/network/chat/Style.java.patch index 903cf16..834bdf0 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/network/chat/Style.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/network/chat/Style.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/network/chat/Style.java +++ b/net/minecraft/network/chat/Style.java -@@ -7,6 +_,7 @@ - import java.util.Optional; - import javax.annotation.Nullable; - import net.minecraft.ChatFormatting; -+import net.minecraft.commands.Commands; - import net.minecraft.network.RegistryFriendlyByteBuf; - import net.minecraft.network.codec.ByteBufCodecs; - import net.minecraft.network.codec.StreamCodec; -@@ -86,7 +_,20 @@ +@@ -76,7 +_,20 @@ this.underlined = underlined; this.strikethrough = strikethrough; this.obfuscated = obfuscated; @@ -21,7 +13,7 @@ + cmd = cmd.split(" ", 2)[0]; + String finalCmd = cmd; + -+ if (Commands.vanillaCommands.getRoot().getChildren().stream().noneMatch((node) -> node.commandBlockAllowed && finalCmd.startsWith(node.getName()))) { ++ if (net.minecraft.commands.Commands.vanillaCommands.getRoot().getChildren().stream().noneMatch((node) -> node.commandBlockAllowed && finalCmd.startsWith(node.getName()))) { + blackListedCommand = true; + } + } diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch index 4d7c00d..4273547 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,18 +1,26 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -193,11 +_,12 @@ - map.put(registry.key(), new IllegalStateException("Registry must be non-empty: " + registry.key().location())); - } - }); -+ // Moose start - Don't throw an exception on invalid registry - if (!map.isEmpty()) { -- throw logErrors(map); -- } else { -- return new RegistryAccess.ImmutableRegistryAccess(list.stream().map(RegistryDataLoader.Loader::registry).toList()).freeze(); -+ logErrors(map); - } -+ return new RegistryAccess.ImmutableRegistryAccess(list.stream().map(RegistryDataLoader.Loader::registry).toList()).freeze(); -+ // Moose end - } - - private static RegistryOps.RegistryInfoLookup createContext( +@@ -216,18 +_,17 @@ + .thenApplyAsync( + ignored -> { + List> frozenRegistries = loadTasks.stream().filter(task -> task.freezeRegistry(loadingErrors)).toList(); ++ // Moose start - Don't throw an exception on invalid registry + if (!loadingErrors.isEmpty()) { +- throw logErrors(loadingErrors); +- } else { ++ logErrors(loadingErrors); ++ } + List> registries = frozenRegistries.stream() + .flatMap(task -> task.validateRegistry(loadingErrors).stream()) + .toList(); + if (!loadingErrors.isEmpty()) { +- throw logErrors(loadingErrors); +- } else { +- return new RegistryAccess.ImmutableRegistryAccess(registries).freeze(); ++ logErrors(loadingErrors); + } +- } ++ return new RegistryAccess.ImmutableRegistryAccess(registries).freeze(); + }, + executor + ); diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch index ee2527c..e157af1 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch @@ -8,48 +8,35 @@ import com.mojang.datafixers.DataFixer; import com.mojang.logging.LogUtils; import com.mojang.serialization.Dynamic; -@@ -16,12 +_,9 @@ - import java.util.Optional; - import java.util.function.BooleanSupplier; - import javax.annotation.Nullable; --import joptsimple.OptionParser; -+ - import joptsimple.OptionSet; --import joptsimple.OptionSpec; --import joptsimple.util.PathConverter; - import net.minecraft.CrashReport; --import net.minecraft.DefaultUncaughtExceptionHandler; - import net.minecraft.SharedConstants; - import net.minecraft.SuppressForbidden; - import net.minecraft.Util; -@@ -52,11 +_,7 @@ - import net.minecraft.world.level.levelgen.WorldDimensions; - import net.minecraft.world.level.levelgen.WorldOptions; - import net.minecraft.world.level.levelgen.presets.WorldPresets; --import net.minecraft.world.level.storage.LevelDataAndDimensions; --import net.minecraft.world.level.storage.LevelStorageSource; --import net.minecraft.world.level.storage.LevelSummary; --import net.minecraft.world.level.storage.PrimaryLevelData; --import net.minecraft.world.level.storage.WorldData; -+import net.minecraft.world.level.storage.*; - import org.slf4j.Logger; - - public class Main { -@@ -139,6 +_,8 @@ +@@ -142,6 +_,8 @@ return; } -+ MooseConfig.init((File) optionSet.valueOf("moose-settings")); // Moose - Load moose.yml ++ MooseConfig.init((File) options.valueOf("moose-settings")); // Moose - Load moose.yml + - // Spigot start + // Paper start - eula system property boolean eulaAgreed = Boolean.getBoolean("com.mojang.eula.agree"); if (eulaAgreed) { -@@ -228,7 +_,7 @@ +@@ -202,8 +_,11 @@ + LOGGER.info("This world was created by an incompatible version."); + return; + } +- +- levelDataTag = DataFixers.getFileFixer().fix(access, levelDataUnfixed, new UpgradeProgress()); ++ // Moose start - Calls the filefixer for 26.1 world folder migration, whilst keeping the "default" level.dat behavior ++ io.papermc.paper.world.migration.WorldFolderMigration.didInitialLoad = true; // Disable 30s conversion warning ++ DataFixers.getFileFixer().fix(access, levelDataUnfixed, new UpgradeProgress()); // (Note: Ensure a fake level.dat with a matching DataVersion exists when upgrading from 1.21.10) ++ levelDataTag = null; ++ // Moose end + } else { + levelDataTag = null; + } +@@ -214,7 +_,7 @@ LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); } -- PackRepository packRepository = ServerPacksSource.createPackRepository(levelStorageAccess); -+ PackRepository packRepository = hasOptionSpec ? ServerPacksSource.createVanillaTrustedRepository() : ServerPacksSource.createPackRepository(levelStorageAccess); // Moose +- PackRepository packRepository = ServerPacksSource.createPackRepository(access); ++ PackRepository packRepository = safeModeEnabled ? ServerPacksSource.createVanillaTrustedRepository() : ServerPacksSource.createPackRepository(access); // Moose // CraftBukkit start - File bukkitDataPackFolder = new File(levelStorageAccess.getLevelPath(net.minecraft.world.level.storage.LevelResource.DATAPACK_DIR).toFile(), "bukkit"); + File bukkitDataPackFolder = new File(access.getLevelPath(net.minecraft.world.level.storage.LevelResource.DATAPACK_DIR).toFile(), "bukkit"); if (!bukkitDataPackFolder.exists()) { diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch new file mode 100644 index 0000000..19daa22 --- /dev/null +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/server/MinecraftServer.java ++++ b/net/minecraft/server/MinecraftServer.java +@@ -998,8 +_,9 @@ + public void saveGlobalData(final boolean flush) { + this.scoreboard.storeToSaveDataIfDirty(this.getDataStorage().computeIfAbsent(ScoreboardSaveData.TYPE)); + +- GameProfile singleplayerProfile = this.getSingleplayerProfile(); +- this.storageSource.saveDataTag(this.worldData, singleplayerProfile == null ? null : singleplayerProfile.id()); ++ // Moose - Disable level.dat saving ++ // GameProfile singleplayerProfile = this.getSingleplayerProfile(); ++ // this.storageSource.saveDataTag(this.worldData, singleplayerProfile == null ? null : singleplayerProfile.id()); + if (flush) { + this.savedDataStorage.saveAndJoin(); + } else { diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch index b93ef68..7168c3f 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch @@ -1,19 +1,11 @@ --- a/net/minecraft/server/ServerFunctionLibrary.java +++ b/net/minecraft/server/ServerFunctionLibrary.java -@@ -17,6 +_,7 @@ - import java.util.concurrent.Executor; - import net.minecraft.commands.CommandSource; - import net.minecraft.commands.CommandSourceStack; -+import net.minecraft.commands.Commands; - import net.minecraft.commands.functions.CommandFunction; - import net.minecraft.core.Registry; - import net.minecraft.core.registries.Registries; -@@ -90,7 +_,7 @@ - ResourceLocation resourceLocation1 = LISTER.fileToId(resourceLocation); - map1.put(resourceLocation1, CompletableFuture.supplyAsync(() -> { - List lines = readLines(entry.getValue()); -- return CommandFunction.fromLines(resourceLocation1, this.dispatcher, commandSourceStack, lines); -+ return CommandFunction.fromLines(resourceLocation1, Commands.vanillaCommands, commandSourceStack, lines); - }, backgroundExecutor)); - } +@@ -88,7 +_,7 @@ + Identifier id = LISTER.fileToId(resourceId); + result.put(id, CompletableFuture.supplyAsync(() -> { + List lines = readLines(entry.getValue()); +- return CommandFunction.fromLines(id, this.dispatcher, compilationContext, lines); ++ return CommandFunction.fromLines(id, Commands.vanillaCommands, compilationContext, lines); // Moose - Ensure functions use vanilla commands + }, taskExecutor)); + } diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ExecuteCommand.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ExecuteCommand.java.patch index d802c19..24734c1 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ExecuteCommand.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ExecuteCommand.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/ExecuteCommand.java +++ b/net/minecraft/server/commands/ExecuteCommand.java -@@ -142,7 +_,7 @@ +@@ -148,7 +_,7 @@ dispatcher.register( Commands.literal("execute") - .requires(Commands.hasPermission(2)) + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) - .then(Commands.literal("run").redirect(dispatcher.getRoot())) + .then(Commands.literal("run").redirect(Commands.vanillaCommands.getRoot())) // Moose - Only run vanilla commands - .then(addConditionals(literalCommandNode, Commands.literal("if"), true, buildContext)) - .then(addConditionals(literalCommandNode, Commands.literal("unless"), false, buildContext)) - .then(Commands.literal("as").then(Commands.argument("targets", EntityArgument.entities()).fork(literalCommandNode, commandContext -> { + .then(addConditionals(execute, Commands.literal("if"), true, context)) + .then(addConditionals(execute, Commands.literal("unless"), false, context)) + .then(Commands.literal("as").then(Commands.argument("targets", EntityArgument.entities()).fork(execute, c -> { diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/TickCommand.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/TickCommand.java.patch index 6011af9..706e38e 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/TickCommand.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/TickCommand.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/TickCommand.java +++ b/net/minecraft/server/commands/TickCommand.java @@ -20,7 +_,7 @@ - public static void register(CommandDispatcher dispatcher) { + public static void register(final CommandDispatcher dispatcher) { dispatcher.register( Commands.literal("tick") -- .requires(Commands.hasPermission(3)) -+ .requires(Commands.hasPermission(2)) - .then(Commands.literal("query").executes(commandContext -> tickQuery(commandContext.getSource()))) +- .requires(Commands.hasPermission(Commands.LEVEL_ADMINS)) ++ .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) + .then(Commands.literal("query").executes(c -> tickQuery(c.getSource()))) .then( Commands.literal("rate") diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/data/EntityDataAccessor.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/data/EntityDataAccessor.java.patch index 89226ac..9b0d86a 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/data/EntityDataAccessor.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/data/EntityDataAccessor.java.patch @@ -18,9 +18,9 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.storage.TagValueInput; import org.slf4j.Logger; -@@ -48,7 +_,65 @@ +@@ -49,7 +_,65 @@ @Override - public void setData(CompoundTag other) throws CommandSyntaxException { + public void setData(final CompoundTag tag) throws CommandSyntaxException { if (this.entity instanceof Player) { - throw ERROR_NO_PLAYERS.create(); + // Moose start - Allow modifying player data @@ -30,26 +30,26 @@ + CompoundTag oldNbt = NbtPredicate.getEntityTagToCompare(entity); + + ServerPlayer player = (ServerPlayer) entity; -+ for (String key : other.keySet()) { -+ if (other.get(key).equals(oldNbt.get(key))) { ++ for (String key : tag.keySet()) { ++ if (tag.get(key).equals(oldNbt.get(key))) { + continue; + } + switch (key) { -+ case "Air" -> player.setAirSupply(((NumericTag) other.get(key)).intValue()); -+ case "Fire" -> player.setRemainingFireTicks(((NumericTag) other.get(key)).intValue()); -+ case "Glowing" -> player.setGlowingTag(((NumericTag) other.get(key)).byteValue() != 0); -+ case "Invulnerable" -> player.setInvulnerable(((NumericTag) other.get(key)).byteValue() != 0); ++ case "Air" -> player.setAirSupply(((NumericTag) tag.get(key)).intValue()); ++ case "Fire" -> player.setRemainingFireTicks(((NumericTag) tag.get(key)).intValue()); ++ case "Glowing" -> player.setGlowingTag(((NumericTag) tag.get(key)).byteValue() != 0); ++ case "Invulnerable" -> player.setInvulnerable(((NumericTag) tag.get(key)).byteValue() != 0); + case "Motion" -> { -+ ListTag velocity = (ListTag) other.get(key); ++ ListTag velocity = (ListTag) tag.get(key); + player.setDeltaMovement(((NumericTag)velocity.get(0)).doubleValue(), ((NumericTag)velocity.get(1)).doubleValue(), ((NumericTag)velocity.get(2)).doubleValue()); + player.connection.send(new ClientboundSetEntityMotionPacket(player)); + } -+ case "NoGravity" -> player.setNoGravity(((NumericTag) other.get(key)).byteValue() != 0); -+ case "PortalCooldown" -> player.setPortalCooldown(((NumericTag) other.get(key)).intValue()); -+ case "Silent" -> player.setSilent(((NumericTag) other.get(key)).byteValue() != 0); -+ case "Health" -> player.setHealth(((NumericTag) other.get(key)).floatValue()); ++ case "NoGravity" -> player.setNoGravity(((NumericTag) tag.get(key)).byteValue() != 0); ++ case "PortalCooldown" -> player.setPortalCooldown(((NumericTag) tag.get(key)).intValue()); ++ case "Silent" -> player.setSilent(((NumericTag) tag.get(key)).byteValue() != 0); ++ case "Health" -> player.setHealth(((NumericTag) tag.get(key)).floatValue()); + case "abilities" -> { -+ CompoundTag abilities = (CompoundTag) other.get(key); ++ CompoundTag abilities = (CompoundTag) tag.get(key); + abilities.getBoolean("flying").ifPresent( flying -> player.getAbilities().flying = flying); + abilities.getFloat("flySpeed").ifPresent( flySpeed -> player.getAbilities().setFlyingSpeed(flySpeed)); + abilities.getBoolean("instabuild").ifPresent( instabuild -> player.getAbilities().instabuild = instabuild); @@ -61,24 +61,24 @@ + player.onUpdateAbilities(); + } + case "SelectedItemSlot" -> { -+ int slot = ((NumericTag) other.get(key)).intValue(); ++ int slot = ((NumericTag) tag.get(key)).intValue(); + if (Inventory.isHotbarSlot(slot)) { + player.getInventory().setSelectedSlot(slot); + player.connection.send(new ClientboundSetHeldSlotPacket(slot)); + } + } -+// case "HasVisualFire" -> player.hasVisualFire = (((NumericTag) other.get(key)).byteValue() != 0); -+ case "TicksFrozen" -> player.setTicksFrozen(((NumericTag) other.get(key)).intValue()); ++// case "HasVisualFire" -> player.hasVisualFire = (((NumericTag) tag.get(key)).byteValue() != 0); ++ case "TicksFrozen" -> player.setTicksFrozen(((NumericTag) tag.get(key)).intValue()); + case "FallFlying" -> { -+ if (((NumericTag) other.get(key)).byteValue() != 0) { ++ if (((NumericTag) tag.get(key)).byteValue() != 0) { + player.startFallFlying(); + } else { + player.stopFallFlying(); + } + } -+ case "foodExhaustionLevel" -> player.getFoodData().exhaustionLevel = ((NumericTag) other.get(key)).floatValue(); -+ case "foodLevel" -> player.getFoodData().setFoodLevel(((NumericTag) other.get(key)).intValue()); -+ case "foodSaturationLevel" -> player.getFoodData().setSaturation(((NumericTag) other.get(key)).floatValue()); ++ case "foodExhaustionLevel" -> player.getFoodData().exhaustionLevel = ((NumericTag) tag.get(key)).floatValue(); ++ case "foodLevel" -> player.getFoodData().setFoodLevel(((NumericTag) tag.get(key)).intValue()); ++ case "foodSaturationLevel" -> player.getFoodData().setSaturation(((NumericTag) tag.get(key)).floatValue()); + } + } + // Moose end - Allow modifying player data diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch index 6bece03..8ce69b5 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/level/PlayerSpawnFinder.java +++ b/net/minecraft/server/level/PlayerSpawnFinder.java @@ -63,7 +_,12 @@ - playerSpawnFinder.scheduleNext(); - return playerSpawnFinder.finishedFuture; + finder.scheduleNext(); + return finder.finishedFuture; } else { -- return CompletableFuture.completedFuture(fixupSpawnHeight(level, pos)); +- return CompletableFuture.completedFuture(fixupSpawnHeight(level, spawnSuggestion)); + // Moose start - ensure chunks are loaded for spawn search -+ int sectionPosX = SectionPos.blockToSectionCoord(pos.getX()); -+ int sectionPosZ = SectionPos.blockToSectionCoord(pos.getZ()); ++ int sectionPosX = SectionPos.blockToSectionCoord(spawnSuggestion.getX()); ++ int sectionPosZ = SectionPos.blockToSectionCoord(spawnSuggestion.getZ()); + return level.moonrise$getChunkTaskScheduler().chunkHolderManager.addTicketAndLoadWithRadius(TicketType.SPAWN_SEARCH, new ChunkPos(sectionPosX, sectionPosZ), 0, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, ca.spottedleaf.concurrentutil.util.Priority.HIGH). -+ thenApply((v) -> { return fixupSpawnHeight(level, pos); }); ++ thenApply((v) -> { return fixupSpawnHeight(level, spawnSuggestion); }); + // Moose end } } diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch deleted file mode 100644 index 9941af0..0000000 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/level/ServerChunkCache.java -+++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -211,7 +_,7 @@ - } - - //ASP start - No dimension data storage -- if(level instanceof com.infernalsuite.asp.level.SlimeLevelInstance) { -+ if(level instanceof com.infernalsuite.asp.level.SlimeLevelInstance && false) { // Moose - Re-enable dat file storage - this.dataStorage = new com.infernalsuite.asp.level.ReadOnlyDimensionDataStorage(new SavedData.Context(level), path, fixerUpper, level.registryAccess()); - } else { - this.dataStorage = new DimensionDataStorage(new SavedData.Context(level), path, fixerUpper, level.registryAccess()); diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 8590133..f5675ea 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -536,8 +_,8 @@ +@@ -547,8 +_,8 @@ } @Override -- protected void addAdditionalSaveData(ValueOutput output) { +- protected void addAdditionalSaveData(final ValueOutput output) { - super.addAdditionalSaveData(output); + protected void addAdditionalSaveData(ValueOutput output, boolean includeAll) { // Moose - Disable enderchest serializing in nbt selectors + super.addAdditionalSaveData(output, includeAll); // Moose diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 53ee027..96d9135 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,29 +1,20 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1367,7 +_,7 @@ +@@ -1422,7 +_,7 @@ @Override - public void handleEntityTagQuery(ServerboundEntityTagQueryPacket packet) { + public void handleEntityTagQuery(final ServerboundEntityTagQueryPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); -- if (this.player.hasPermissions(2)) { -+ if (this.player.hasPermissions(2) || this.player.getBukkitEntity().hasPermission("minecraft.nbt.query")) { // Moose - Add nbt.query permission +- if (this.player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)) { ++ if (this.player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER) || this.player.getBukkitEntity().hasPermission("minecraft.nbt.query")) { // Moose - Add nbt.query permission Entity entity = this.player.level().getEntity(packet.getEntityId()); if (entity != null) { - try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(entity.problemPath(), LOGGER)) { -@@ -1393,7 +_,7 @@ + try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(entity.problemPath(), LOGGER)) { +@@ -1448,7 +_,7 @@ @Override - public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQueryPacket packet) { + public void handleBlockEntityTagQuery(final ServerboundBlockEntityTagQueryPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); -- if (this.player.hasPermissions(2)) { -+ if (this.player.hasPermissions(2) || this.player.getBukkitEntity().hasPermission("minecraft.nbt.query")) { // Moose - Add nbt.query permission +- if (this.player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)) { ++ if (this.player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER) || this.player.getBukkitEntity().hasPermission("minecraft.nbt.query")) { // Moose - Add nbt.query permission BlockEntity blockEntity = this.player.level().getBlockEntity(packet.getPos()); - CompoundTag compoundTag = blockEntity != null ? blockEntity.saveWithoutMetadata(this.player.registryAccess()) : null; - this.send(new ClientboundTagQueryPacket(packet.getTransactionId(), compoundTag)); -@@ -3509,7 +_,7 @@ - @Override - public void handleChangeGameMode(ServerboundChangeGameModePacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); -- if (!this.player.hasPermissions(2)) { -+ if (!this.player.hasPermissions(2) && !this.player.getBukkitEntity().hasPermission("minecraft.gamemodeswitcher")) { // Moose: Added a permission to allow players to change their own gamemode with F3 shortcut - LOGGER.warn( - "Player {} tried to change game mode to {} without required permissions", - this.player.getGameProfile().name(), + CompoundTag tag = blockEntity != null ? blockEntity.saveWithoutMetadata(this.player.registryAccess()) : null; + this.send(new ClientboundTagQueryPacket(packet.getTransactionId(), tag)); diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/players/PlayerList.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/players/PlayerList.java.patch deleted file mode 100644 index 9cc83ec..0000000 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/players/PlayerList.java -+++ b/net/minecraft/server/players/PlayerList.java -@@ -1187,6 +_,8 @@ - PlayerAdvancements playerAdvancements = player.getAdvancements(); // CraftBukkit - if (playerAdvancements == null) { - Path path = this.server.getWorldPath(LevelResource.PLAYER_ADVANCEMENTS_DIR).resolve(uuid + ".json"); -+ if (MinecraftServer.getServer().overworld() instanceof com.infernalsuite.asp.level.SlimeLevelInstance) // Moose - Change advancements path for slime overworlds -+ path = this.server.getWorldPath(LevelResource.PLAYER_DATA_DIR).resolve("advancements" + File.separator + uuid + ".json"); // Moose - Change advancements path for slime overworlds - playerAdvancements = new PlayerAdvancements(this.server.getFixerUpper(), this, this.server.getAdvancements(), path, player); - // this.advancements.put(uuid, playerAdvancements); // CraftBukkit - } diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/util/filefix/fixes/PlayerStorageFileFix.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/util/filefix/fixes/PlayerStorageFileFix.java.patch new file mode 100644 index 0000000..ec6e90e --- /dev/null +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/util/filefix/fixes/PlayerStorageFileFix.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/util/filefix/fixes/PlayerStorageFileFix.java ++++ b/net/minecraft/util/filefix/fixes/PlayerStorageFileFix.java +@@ -11,7 +_,7 @@ + + @Override + public void makeFixer() { +- this.addFileFixOperation(FileFixOperations.move("advancements", "players/advancements")); ++ this.addFileFixOperation(FileFixOperations.move("playerdata/advancements", "players/advancements")); // Moose - Move advancements from the custom path to the new vanilla one + this.addFileFixOperation(FileFixOperations.move("playerdata", "players/data")); + this.addFileFixOperation(FileFixOperations.move("stats", "players/stats")); + } diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch index d624243..57397f5 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -695,7 +_,7 @@ +@@ -678,7 +_,7 @@ } @Override -- protected void addAdditionalSaveData(ValueOutput output) { +- protected void addAdditionalSaveData(final ValueOutput output) { + protected void addAdditionalSaveData(ValueOutput output, boolean includeAll) { super.addAdditionalSaveData(output); NbtUtils.addCurrentDataVersion(output); this.inventory.save(output.list("Inventory", ItemStackWithSlot.CODEC)); -@@ -708,7 +_,8 @@ +@@ -691,7 +_,8 @@ output.putInt("Score", this.getScore()); this.foodData.addAdditionalSaveData(output); output.store("abilities", Abilities.Packed.CODEC, this.abilities.pack()); - this.enderChestInventory.storeAsSlots(output.list("EnderItems", ItemStackWithSlot.CODEC)); + if (includeAll) // Moose - Disable enderchest serializing in nbt selectors + this.enderChestInventory.storeAsSlots(output.list("EnderItems", ItemStackWithSlot.CODEC)); - this.lastDeathLocation.ifPresent(globalPos -> output.store("LastDeathLocation", GlobalPos.CODEC, globalPos)); - output.storeNullable("current_explosion_impact_pos", Vec3.CODEC, this.currentImpulseImpactPos); - output.putBoolean("ignore_fall_damage_from_current_explosion", this.ignoreFallDamageFromCurrentImpulse); -@@ -1891,7 +_,7 @@ + this.lastDeathLocation.ifPresent(pos -> output.store("LastDeathLocation", GlobalPos.CODEC, pos)); + } + +@@ -2013,7 +_,7 @@ } public boolean canUseGameMasterBlocks() { -- return this.abilities.instabuild && this.getPermissionLevel() >= 2; -+ return this.abilities.instabuild && (this.getPermissionLevel() >= 2 || this.getBukkitEntity().hasPermission("minecraft.commandblock")); // Moose - Add permission for interacting with GameMasterBlocks +- return this.abilities.instabuild && this.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER); ++ return this.abilities.instabuild && (this.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER) || this.getBukkitEntity().hasPermission("minecraft.commandblock")); // Moose - Add permission for interacting with GameMasterBlocks } - public int getPermissionLevel() { + public PermissionSet permissions() { diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch index 0a2187c..7b73714 100644 --- a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java -@@ -104,7 +_,7 @@ +@@ -99,7 +_,7 @@ + return true; } else { this.successCount = 0; - MinecraftServer server = this.getLevel().getServer(); -- if (server.isCommandBlockEnabled() && !StringUtil.isNullOrEmpty(this.command)) { -+ if (server.isCommandBlockEnabled() && com.legitimoose.lsp.MooseConfig.allowCommandBlocks && !StringUtil.isNullOrEmpty(this.command)) { +- if (level.isCommandBlockEnabled() && !StringUtil.isNullOrEmpty(this.command)) { ++ if (level.isCommandBlockEnabled() && com.legitimoose.lsp.MooseConfig.allowCommandBlocks && !StringUtil.isNullOrEmpty(this.command)) { // Moose - allow command blocks config option try { this.lastOutput = null; diff --git a/legitslimepaper-server/paper-patches/files/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java.patch b/legitslimepaper-server/paper-patches/files/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java.patch index aa58df4..cb0c7e4 100644 --- a/legitslimepaper-server/paper-patches/files/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java.patch +++ b/legitslimepaper-server/paper-patches/files/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java -@@ -235,6 +_,7 @@ +@@ -240,6 +_,7 @@ if (!plugin.isEnabled()) { return; } diff --git a/legitslimepaper-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/Main.java.patch b/legitslimepaper-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/Main.java.patch index 2b36bf2..fb0a7e8 100644 --- a/legitslimepaper-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/Main.java.patch +++ b/legitslimepaper-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/Main.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -169,6 +_,14 @@ +@@ -174,6 +_,14 @@ .ofType(String.class) .defaultsTo("Unknown Server") .describedAs("Name"); diff --git a/legitslimepaper-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/util/Versioning.java.patch b/legitslimepaper-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/util/Versioning.java.patch deleted file mode 100644 index 1adcedf..0000000 --- a/legitslimepaper-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/util/Versioning.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -@@ -11,7 +_,7 @@ - public static String getBukkitVersion() { - String result = "Unknown-Version"; - -- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/com.infernalsuite.asp/aspaper-api/pom.properties"); -+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/com.legitimoose.legitslimepaper/legitslimepaper-api/pom.properties"); - Properties properties = new Properties(); - - if (stream != null) { diff --git a/settings.gradle.kts b/settings.gradle.kts index 77d899d..72cb3d9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,19 +1,29 @@ pluginManagement { repositories { + maven("https://repo.papermc.io/repository/maven-public/") mavenLocal() mavenCentral() gradlePluginPortal() - maven("https://repo.papermc.io/repository/maven-public/") } } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" } rootProject.name = "legitslimepaper" +fun optionalProject(path: String) { + val d = file(path) + if (d.isDirectory) { + include(path) + } else { + logger.lifecycle("Skipping $path (missing dir: ${d.path})") + } +} + +optionalProject("core") +optionalProject("api") + include("legitslimepaper-api") include("legitslimepaper-server") - -include("core", "api") \ No newline at end of file