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 2f4970242c754cfba8ff5656a63af07d9d0a723c..b156b5c635f931a3d4abc0584591f90476d011a6 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -2353,6 +2353,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop selectedIds) { + this.packRepository.setSelected(selectedIds, 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(Collection selectedIds, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause) { // Paper end - Add ServerResourcesReloadedEvent CompletableFuture completableFuture = CompletableFuture.supplyAsync( diff --git a/net/minecraft/server/commands/DataPackCommand.java b/net/minecraft/server/commands/DataPackCommand.java index a5032b34752061d61fd9ddb4db828d35e403f5e7..3eaa9c85d06f6ecc8ed639d8befa861439390eb7 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(2)) - /*.then( // Luminol - Add back read-only datapack command + .then( Commands.literal("enable") .then( Commands.argument("name", StringArgumentType.string()) @@ -160,11 +160,11 @@ public class DataPackCommand { .suggests(SELECTED_PACKS) .executes(commandContext -> disablePack(commandContext.getSource(), getPack(commandContext, "name", false))) ) - )*/ // Luminol - Add back read-only datapack command + ) .then( Commands.literal("list") .executes(commandContext -> listPacks(commandContext.getSource())) - // .then(Commands.literal("available").executes(commandContext -> listAvailablePacks(commandContext.getSource()))) // Luminol - Add back read-only datapack command + .then(Commands.literal("available").executes(commandContext -> listAvailablePacks(commandContext.getSource()))) .then(Commands.literal("enabled").executes(commandContext -> listEnabledPacks(commandContext.getSource()))) ) .then( @@ -252,7 +252,7 @@ public class DataPackCommand { } private static int listPacks(CommandSourceStack source) { - return listEnabledPacks(source) ;// + listAvailablePacks(source); // Luminol - Add back read-only datapack command + return listEnabledPacks(source) + listAvailablePacks(source); } private static int listAvailablePacks(CommandSourceStack source) { @@ -280,7 +280,7 @@ public class DataPackCommand { private static int listEnabledPacks(CommandSourceStack source) { PackRepository packRepository = source.getServer().getPackRepository(); - // packRepository.reload(); // Luminol - Add back read-only datapack command + packRepository.reload(); Collection selectedPacks = packRepository.getSelectedPacks(); if (selectedPacks.isEmpty()) { source.sendSuccess(() -> Component.translatable("commands.datapack.list.enabled.none"), false); diff --git a/net/minecraft/server/commands/ReloadCommand.java b/net/minecraft/server/commands/ReloadCommand.java index b540a3c3a02f7242578a63477e34b9063e86f1d2..bc999de32931558d0d8dc26264653dd63c1cad19 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(Collection selectedIds, CommandSourceStack source) { + // Lophine start - region thread skip reload // TODO - add reload support + source.getServer().saveDatapacks(selectedIds); + source.getSender().sendMessage("You need to restart server to load datapacks update."); + if (false) { source.getServer().reloadResources(selectedIds, 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(PackRepository packRepository, WorldData worldData, Collection selectedIds) {