mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-07 03:10:50 +01:00
1e7dd72f15
The game uses 0.95d now
55 lines
3.6 KiB
Diff
55 lines
3.6 KiB
Diff
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 f73ad3b85ed46913c10891edd3a52b9ad694e5e2..c063dece36e110691297b38635a9d14d70c4e391 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -2108,7 +2108,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
return this.functionManager;
|
|
}
|
|
|
|
+ // Paper start - add cause
|
|
+ @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
|
|
RegistryAccess.Frozen iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
|
|
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
|
Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
|
|
@@ -2149,6 +2155,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 - 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..87d32af973b84fbbea5dcdb34273f3b3fc82d054 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
|
|
|