aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0544-Added-ServerResourcesReloadedEvent.patch
blob: 08c7e91119c7ee3852a4a6cf0c9ea6776a797238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 2 Dec 2020 20:04:01 -0800
Subject: [PATCH] Added ServerResourcesReloadedEvent


diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 37df16b8f1dd1f75ed4c922347e648386fa54e6a..a3f5585db8579350c1390d7ee141e1a8af9225ff 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1988,7 +1988,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
         return this.functionManager;
     }
 
+    // Paper start - add cause
+    @Deprecated
     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
         RegistryAccess.Frozen iregistrycustom_dimension = this.registryAccess();
         CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
             Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
@@ -2014,6 +2020,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
             this.packRepository.setSelected(dataPacks);
             this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
             this.resources.managers.updateRegistryTags(this.registryAccess());
+            new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
             // Paper start
             if (Thread.currentThread() != this.serverThread) {
                 return;
diff --git a/src/main/java/net/minecraft/server/commands/ReloadCommand.java b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
index 1eb85de1d10829bfb4dbbfa01efd5656dee70090..19eacd1b1c3aca23f864a1867e004455312e82f7 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) -> {
             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
     }
     // CraftBukkit end