Yatopia/patches/server/0020-EMC-ServerShutdownEvent-and-move-disablePlugins.patch

51 lines
2.2 KiB
Diff
Raw Normal View History

2020-02-26 20:12:29 +01:00
From 7d38d336a161d1e4c27f77eda8ca63f9b2a244a8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 8 May 2015 19:56:21 -0400
Subject: [PATCH] EMC ServerShutdownEvent and move disablePlugins
---
src/main/java/net/minecraft/server/MinecraftServer.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index b5bd0e38..816f4ff1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -99,6 +99,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
private boolean A;
private boolean spawnAnimals;
private boolean spawnNPCs;
+ public String shutdownReason; // EMC
private boolean pvpMode;
private boolean allowFlight;
@Nullable
@@ -739,7 +740,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
MinecraftTimings.stopServer(); // Paper
// CraftBukkit start
if (this.server != null) {
- this.server.disablePlugins();
+ // this.server.disablePlugins(); // EMC - Moved below after everything has unloaded so plugins can get events
+ new com.empireminecraft.customevents.ServerShutdownEvent(shutdownReason).callEvent(); // EMC
}
// CraftBukkit end
if (this.getServerConnection() != null) {
@@ -778,6 +780,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
}
}
+ if (server != null) { this.server.disablePlugins(); } // EMC
if (this.snooper.d()) {
this.snooper.e();
@@ -809,6 +812,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.safeShutdown(flag, false);
}
public void safeShutdown(boolean flag, boolean isRestarting) {
+ if (shutdownReason == null) { shutdownReason = "Server Shutting Down"; } // EMC
this.isRunning = false;
this.isRestarting = isRestarting;
if (flag) {
--
2.25.1.windows.1