From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Wed, 2 Jul 2025 23:36:25 +0800 Subject: [PATCH] Fix datapack command save function diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java index e7eec08a4d8943b35a76173e39529498c348140c..61983a80191e64942bfdac74c6d2f23cf781484d 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -2475,6 +2475,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop selectedPacks) { + this.packRepository.setSelected(selectedPacks, false); // Paper - add pendingReload flag to determine required pack loading - false as this is *after* a reload (see above) + WorldDataConfiguration worldDataConfiguration = new WorldDataConfiguration( + getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures() + ); + this.worldData.setDataConfiguration(worldDataConfiguration); + } + // Lophine end - region thread skip reload // TODO - add reload support + public CompletableFuture reloadResources( final Collection packsToEnable, final io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause ) { diff --git a/net/minecraft/server/commands/DataPackCommand.java b/net/minecraft/server/commands/DataPackCommand.java index 0c7c829270d3cd3dd05a3dc7dfe82ee01d5c6bd8..991e0362e96488b64d994f1bdfb8ed5d66f98666 100644 --- a/net/minecraft/server/commands/DataPackCommand.java +++ b/net/minecraft/server/commands/DataPackCommand.java @@ -98,7 +98,7 @@ public class DataPackCommand { dispatcher.register( Commands.literal("datapack") .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) - /*.then( // Luminol - Add back read-only datapack command + .then( // Lophine - Fix datapack command save function Commands.literal("enable") .then( Commands.argument("name", StringArgumentType.string()) @@ -145,11 +145,11 @@ public class DataPackCommand { .suggests(SELECTED_PACKS) .executes(c -> disablePack(c.getSource(), getPack(c, "name", false))) ) - )*/ // Luminol - Add back read-only datapack command + ) .then( Commands.literal("list") .executes(c -> listPacks(c.getSource())) - //.then(Commands.literal("available").executes(c -> listAvailablePacks(c.getSource()))) // Luminol - Add back read-only datapack command + .then(Commands.literal("available").executes(c -> listAvailablePacks(c.getSource()))) // Luminol - Add back read-only datapack command .then(Commands.literal("enabled").executes(c -> listEnabledPacks(c.getSource()))) ) .then( @@ -235,7 +235,7 @@ public class DataPackCommand { } private static int listPacks(final CommandSourceStack source) { - return listEnabledPacks(source) ;// + listAvailablePacks(source); // Luminol - Add back read-only datapack command + return listEnabledPacks(source) + listAvailablePacks(source); // Lophine - Fix datapack command save function } private static int listAvailablePacks(final CommandSourceStack source) { diff --git a/net/minecraft/server/commands/ReloadCommand.java b/net/minecraft/server/commands/ReloadCommand.java index 80fef4277b9e986c17a4cb895e130726bdb63229..4bed8d0432508cbe5c0d1fc7d68052ec2af7260f 100644 --- a/net/minecraft/server/commands/ReloadCommand.java +++ b/net/minecraft/server/commands/ReloadCommand.java @@ -16,11 +16,17 @@ public class ReloadCommand { private static final Logger LOGGER = LogUtils.getLogger(); public static void reloadPacks(final Collection selectedPacks, final CommandSourceStack source) { + // Lophine start - region thread skip reload // TODO - add reload support + source.getServer().saveDatapacks(selectedPacks); + source.getSender().sendMessage("You need to restart server to load datapacks update."); + if (false) { source.getServer().reloadResources(selectedPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.COMMAND).exceptionally(throwable -> { // Paper - Add ServerResourcesReloadedEvent LOGGER.warn("Failed to execute reload", throwable); source.sendFailure(Component.translatable("commands.reload.failure")); return null; }); + } + // Lophine end - region thread skip reload // TODO - add reload support } private static Collection discoverNewPacks(final PackRepository packRepository, final WorldData worldData, final Collection currentPacks) {