mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-13 10:21:13 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
90 lines
5.1 KiB
Diff
90 lines
5.1 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 c83f2636ae93d92381e019d5b13ac82c5a1d30bf..892ca65d258b0745be95d7ef4886c49899b24d92 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -2,9 +2,6 @@ package net.minecraft.server;
|
|
|
|
import com.google.common.base.Splitter;
|
|
import com.google.common.collect.ImmutableList;
|
|
-import co.aikar.timings.Timings;
|
|
-import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
|
-import com.google.common.base.Stopwatch;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Sets;
|
|
@@ -181,6 +178,7 @@ import org.bukkit.event.server.ServerLoadEvent;
|
|
import co.aikar.timings.MinecraftTimings; // Paper
|
|
import org.spigotmc.SlackActivityAccountant; // Spigot
|
|
import io.papermc.paper.util.PaperJvmChecker; // Paper
|
|
+import io.papermc.paper.event.server.ServerResourcesReloadedEvent; // Paper
|
|
|
|
public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements SnooperPopulator, CommandSource, AutoCloseable {
|
|
|
|
@@ -1934,9 +1932,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
return this.functionManager;
|
|
}
|
|
|
|
+ // Paper start - add cause
|
|
+ @Deprecated
|
|
public CompletableFuture<Void> reloadResources(Collection<String> datapacks) {
|
|
+ return this.reloadServerResources(datapacks, ServerResourcesReloadedEvent.Cause.PLUGIN);
|
|
+ }
|
|
+ public CompletableFuture<Void> reloadServerResources(Collection<String> collection, ServerResourcesReloadedEvent.Cause cause) {
|
|
+ // Paper end
|
|
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
|
- Stream<String> stream = datapacks.stream(); // CraftBukkit - decompile error
|
|
+ Stream<String> stream = collection.stream(); // CraftBukkit - decompile error
|
|
PackRepository resourcepackrepository = this.packRepository;
|
|
|
|
this.packRepository.getClass();
|
|
@@ -1947,9 +1951,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
this.resources.close();
|
|
this.resources = datapackresources;
|
|
this.server.syncCommands(); // SPIGOT-5884: Lost on reload
|
|
- this.packRepository.setSelected(datapacks);
|
|
+ this.packRepository.setSelected(collection);
|
|
this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository));
|
|
datapackresources.updateGlobals();
|
|
+ new 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 38642911113baf253560960af992e942a3dc87e1..33e34f302b046f819bf9a4c14459bfbbff18b786 100644
|
|
--- a/src/main/java/net/minecraft/server/commands/ReloadCommand.java
|
|
+++ b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
|
|
@@ -12,15 +12,16 @@ import net.minecraft.server.packs.repository.PackRepository;
|
|
import net.minecraft.world.level.storage.WorldData;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
+import io.papermc.paper.event.server.ServerResourcesReloadedEvent; // Paper
|
|
|
|
public class ReloadCommand {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
|
|
public static void reloadPacks(Collection<String> collection, CommandSourceStack commandlistenerwrapper) {
|
|
- commandlistenerwrapper.getServer().reloadResources(collection).exceptionally((throwable) -> {
|
|
- ReloadCommand.LOGGER.warn("Failed to execute reload", throwable);
|
|
- commandlistenerwrapper.sendFailure(new TranslatableComponent("commands.reload.failure"));
|
|
+ commandlistenerwrapper.getServer().reloadServerResources(collection, ServerResourcesReloadedEvent.Cause.COMMAND).exceptionally((throwable) -> { // Paper
|
|
+ CommandReload.LOGGER.warn("Failed to execute reload", throwable);
|
|
+ commandlistenerwrapper.sendFailureMessage(new ChatMessage("commands.reload.failure"));
|
|
return null;
|
|
});
|
|
}
|
|
@@ -48,7 +49,7 @@ public class ReloadCommand {
|
|
WorldData savedata = minecraftserver.getWorldData();
|
|
Collection<String> collection = resourcepackrepository.getSelectedIds();
|
|
Collection<String> collection1 = discoverNewPacks(resourcepackrepository, savedata, collection);
|
|
- minecraftserver.reloadResources(collection1);
|
|
+ minecraftserver.reloadServerResources(collection1, ServerResourcesReloadedEvent.Cause.PLUGIN); // Paper
|
|
}
|
|
// CraftBukkit end
|
|
|