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
|
2021-12-03 01:26:54 +01:00
|
|
|
index b75522558c5277c2e8ec725e5b12eb6d4cb2c36c..b5b7bb3c0147f95ac4036e7d2aa8f26ac755f4df 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
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -1958,7 +1958,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-14 21:17:47 +02:00
|
|
|
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
|
|
|
|
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
|
|
|
Stream<String> stream = datapacks.stream(); // CraftBukkit - decompile error
|
|
|
|
PackRepository resourcepackrepository = this.packRepository;
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -1974,6 +1980,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-14 21:17:47 +02:00
|
|
|
this.packRepository.setSelected(datapacks);
|
|
|
|
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
|
|
|
|
datapackresources.updateGlobals();
|
|
|
|
+ new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
|
|
|
|
if (Thread.currentThread() != this.serverThread) return; // Paper
|
|
|
|
//this.getPlayerList().savePlayers(); // Paper - we don't need to do this
|
|
|
|
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
|
|
|
|
index 3b46b4bf2597354a2c39e8fac2a250ef71034197..23f79f0bef308e6e7dee0bdc0e8b09aa3655cbc7 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(new TranslatableComponent("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
|
|
|
|
|