86 lines
5.2 KiB
Diff
86 lines
5.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
|
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 fb5f9176916931b23ebf4a5b7ecdfc5285ffbc2b..ecdcf0db97341d2cb460f86f451cecd5c40dbfee 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -2450,6 +2450,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
return this.reloadResources(packsToEnable, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN);
|
|
}
|
|
|
|
+ // Lophine start - region thread skip reload // TODO - add reload support
|
|
+ public void saveDatapacks(Collection<String> 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<Void> reloadResources(
|
|
final Collection<String> 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 80d9bc3d680c30dae15064e0e8c3d1379ccd52e6..2bc9cf924d40d5d11935f73cf6d35442b0b0ba06 100644
|
|
--- a/net/minecraft/server/commands/DataPackCommand.java
|
|
+++ b/net/minecraft/server/commands/DataPackCommand.java
|
|
@@ -99,7 +99,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())
|
|
@@ -146,11 +146,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(
|
|
@@ -238,7 +238,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<String> 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<String> discoverNewPacks(final PackRepository packRepository, final WorldData worldData, final Collection<String> currentPacks) {
|