aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0465-Add-ServerResourcesReloadedEvent.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0465-Add-ServerResourcesReloadedEvent.patch')
-rw-r--r--patches/server/0465-Add-ServerResourcesReloadedEvent.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/patches/server/0465-Add-ServerResourcesReloadedEvent.patch b/patches/server/0465-Add-ServerResourcesReloadedEvent.patch
new file mode 100644
index 0000000000..2268c27b1c
--- /dev/null
+++ b/patches/server/0465-Add-ServerResourcesReloadedEvent.patch
@@ -0,0 +1,54 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Wed, 2 Dec 2020 20:04:01 -0800
+Subject: [PATCH] Add ServerResourcesReloadedEvent
+
+
+diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
+index b47110e9b5d8effdc9e768488f99a614c1070814..691d9d18e72a07b85bf13c6990b44e5cf56dffb5 100644
+--- a/src/main/java/net/minecraft/server/MinecraftServer.java
++++ b/src/main/java/net/minecraft/server/MinecraftServer.java
+@@ -2122,7 +2122,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ return this.functionManager;
+ }
+
++ // Paper start - Add ServerResourcesReloadedEvent
++ @Deprecated @io.papermc.paper.annotation.DoNotUse
+ public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
++ return this.reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN);
++ }
++ public CompletableFuture<Void> reloadResources(Collection<String> dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause) {
++ // Paper end - Add ServerResourcesReloadedEvent
+ CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
+ Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
+ PackRepository resourcepackrepository = this.packRepository;
+@@ -2154,6 +2160,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
+ this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);
+ org.bukkit.craftbukkit.block.data.CraftBlockData.reloadCache(); // Paper - cache block data strings; they can be defined by datapacks so refresh it here
++ new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper - Add ServerResourcesReloadedEvent; fire after everything has been reloaded
+ }, this);
+
+ if (this.isSameThread()) {
+diff --git a/src/main/java/net/minecraft/server/commands/ReloadCommand.java b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
+index fa18d018a8458b30c0048f7e59aea39f928d974a..c020c86194723a5c89816f91e0b7c5eeaf132b7e 100644
+--- a/src/main/java/net/minecraft/server/commands/ReloadCommand.java
++++ b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
+@@ -20,7 +20,7 @@ public class ReloadCommand {
+ public ReloadCommand() {}
+
+ public static void reloadPacks(Collection<String> dataPacks, CommandSourceStack source) {
+- source.getServer().reloadResources(dataPacks).exceptionally((throwable) -> {
++ source.getServer().reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.COMMAND).exceptionally((throwable) -> { // Paper - Add ServerResourcesReloadedEvent
+ ReloadCommand.LOGGER.warn("Failed to execute reload", throwable);
+ source.sendFailure(Component.translatable("commands.reload.failure"));
+ return null;
+@@ -50,7 +50,7 @@ public class ReloadCommand {
+ WorldData savedata = minecraftserver.getWorldData();
+ Collection<String> collection = resourcepackrepository.getSelectedIds();
+ Collection<String> collection1 = ReloadCommand.discoverNewPacks(resourcepackrepository, savedata, collection);
+- minecraftserver.reloadResources(collection1);
++ minecraftserver.reloadResources(collection1, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN); // Paper - Add ServerResourcesReloadedEvent
+ }
+ // CraftBukkit end
+