mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 21:17:00 +01:00
b31089a929
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: d264e972 #591: Add option for a consumer before spawning an item 1c537fce #590: Add spawn and transform reasons for piglin zombification. CraftBukkit Changes: ee5006d1 #810: Add option for a consumer before spawning an item f6a39d3c #809: Add spawn and transform reasons for piglin zombification. 0c24068a Organise imports Spigot Changes: bff52619 Organise imports
88 lines
4.7 KiB
Diff
88 lines
4.7 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/CommandReload.java b/src/main/java/net/minecraft/server/CommandReload.java
|
|
index 08e472b71cf85b854eaa831881577ce2c3c03b11..4558147a51be6713c11bda6a60fd5ca3a953c096 100644
|
|
--- a/src/main/java/net/minecraft/server/CommandReload.java
|
|
+++ b/src/main/java/net/minecraft/server/CommandReload.java
|
|
@@ -6,13 +6,14 @@ import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
+import io.papermc.paper.event.server.ServerResourcesReloadedEvent; // Paper
|
|
|
|
public class CommandReload {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
|
|
public static void a(Collection<String> collection, CommandListenerWrapper commandlistenerwrapper) {
|
|
- commandlistenerwrapper.getServer().a(collection).exceptionally((throwable) -> {
|
|
+ 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;
|
|
@@ -42,7 +43,7 @@ public class CommandReload {
|
|
SaveData savedata = minecraftserver.getSaveData();
|
|
Collection<String> collection = resourcepackrepository.d();
|
|
Collection<String> collection1 = a(resourcepackrepository, savedata, collection);
|
|
- minecraftserver.a(collection1);
|
|
+ minecraftserver.reloadServerResources(collection1, ServerResourcesReloadedEvent.Cause.PLUGIN); // Paper
|
|
}
|
|
// CraftBukkit end
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index c858e750018dcf5b1c19ee66d4173119b88101a1..20f44f9952d94aebc64b3ccd9271592bb0890735 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;
|
|
@@ -64,15 +61,13 @@ import com.mojang.serialization.Lifecycle;
|
|
import com.google.common.collect.ImmutableSet;
|
|
// import jline.console.ConsoleReader; // Paper
|
|
import joptsimple.OptionSet;
|
|
-import org.bukkit.Bukkit;
|
|
-import org.bukkit.craftbukkit.CraftServer;
|
|
-import org.bukkit.craftbukkit.Main;
|
|
import org.bukkit.event.server.ServerLoadEvent;
|
|
// CraftBukkit end
|
|
|
|
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 IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
|
|
|
|
@@ -1815,7 +1810,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
return this.customFunctionData;
|
|
}
|
|
|
|
+ // Paper start - add cause
|
|
+ @Deprecated
|
|
public CompletableFuture<Void> a(Collection<String> collection) {
|
|
+ return this.reloadServerResources(collection, ServerResourcesReloadedEvent.Cause.PLUGIN);
|
|
+ }
|
|
+ public CompletableFuture<Void> reloadServerResources(Collection<String> collection, ServerResourcesReloadedEvent.Cause cause) {
|
|
+ // Paper end
|
|
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
|
Stream<String> stream = collection.stream(); // CraftBukkit - decompile error
|
|
ResourcePackRepository resourcepackrepository = this.resourcePackRepository;
|
|
@@ -1831,6 +1832,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
this.resourcePackRepository.a(collection);
|
|
this.saveData.a(a(this.resourcePackRepository));
|
|
datapackresources.i();
|
|
+ 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().reload();
|