2021-06-14 21:17:47 +02:00
|
|
|
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-06-10 16:11:41 +02:00
|
|
|
index 0060211b3d85c07b44be3d3a534dcb8e35547d78..8460437b9210c8ae73795c65596ec35b491b18df 100644
|
2021-06-14 21:17:47 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2022-06-08 09:30:41 +02:00
|
|
|
@@ -1966,7 +1966,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-14 21:17:47 +02:00
|
|
|
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);
|
2021-06-14 21:17:47 +02:00
|
|
|
+ }
|
2022-03-01 06:43:03 +01:00
|
|
|
+ public CompletableFuture<Void> reloadResources(Collection<String> dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause) {
|
2021-06-14 21:17:47 +02:00
|
|
|
+ // Paper end
|
2022-02-28 21:34:23 +01:00
|
|
|
RegistryAccess.Frozen iregistrycustom_dimension = this.registryAccess();
|
2021-06-14 21:17:47 +02:00
|
|
|
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
2022-03-01 06:43:03 +01:00
|
|
|
Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
|
2022-06-08 09:30:41 +02:00
|
|
|
@@ -1992,6 +1998,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2022-03-01 06:43:03 +01:00
|
|
|
this.packRepository.setSelected(dataPacks);
|
2021-06-14 21:17:47 +02:00
|
|
|
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
|
2022-03-01 06:43:03 +01:00
|
|
|
this.resources.managers.updateRegistryTags(this.registryAccess());
|
2021-06-14 21:17:47 +02:00
|
|
|
+ new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
|
|
|
|
if (Thread.currentThread() != this.serverThread) return; // Paper
|
2022-03-01 06:43:03 +01:00
|
|
|
//this.getPlayerList().saveAll(); // Paper - we don't need to do this
|
2021-06-14 21:17:47 +02:00
|
|
|
this.getPlayerList().reloadResources();
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/commands/ReloadCommand.java b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
|
2022-06-08 09:30:41 +02:00
|
|
|
index 1eb85de1d10829bfb4dbbfa01efd5656dee70090..19eacd1b1c3aca23f864a1867e004455312e82f7 100644
|
2021-06-14 21:17:47 +02:00
|
|
|
--- 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"));
|
2021-06-14 21:17:47 +02:00
|
|
|
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
|
|
|
|
|