Paper/patches/server/0538-Added-ServerResourcesReloadedEvent.patch

55 lines
3.4 KiB
Diff
Raw Normal View History

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
2022-12-07 21:16:54 +01:00
index f445f6d382c8fe3def980ed3f8517bbf3b75dfed..04137173ca7034b9dff37a68518e8b6fb0330188 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2022-12-07 21:16:54 +01:00
@@ -1982,7 +1982,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
return this.functionManager;
}
+ // Paper start - add cause
+ @Deprecated
2022-03-01 06:43:03 +01:00
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
+ return this.reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN);
+ }
2022-03-01 06:43:03 +01:00
+ public CompletableFuture<Void> reloadResources(Collection<String> dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause) {
+ // Paper end
2022-12-07 21:16:54 +01:00
RegistryAccess.Frozen iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
2022-03-01 06:43:03 +01:00
Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
2022-12-07 21:16:54 +01:00
@@ -2010,6 +2016,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.worldData.setDataConfiguration(worlddataconfiguration);
2022-03-01 06:43:03 +01:00
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
2022-12-07 21:16:54 +01:00
index 7108be7931e0a9e6240c18433d103659254b99af..2247d4452edbffb7c6c5dae4fe6e8e8f1fce4b5f 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);
2022-06-08 09:30:41 +02:00
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