PaperMC/Spigot-API-Patches/0192-Expose-MinecraftServer-isRunning.patch

45 lines
1.6 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JRoy <joshroy126@gmail.com>
Date: Fri, 10 Apr 2020 21:24:35 -0400
Subject: [PATCH] Expose MinecraftServer#isRunning
This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading.
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 296c8fbb9239ab28f5ebbd4c322a3b9226a3ce11..86ac6702b3aeab1126b2b2879b87ef3883793d44 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1846,6 +1846,15 @@ public final class Bukkit {
public static int getCurrentTick() {
return server.getCurrentTick();
}
+
+ /**
+ * Checks if the server is in the process of being shutdown.
+ *
+ * @return true if server is in the process of being shutdown
+ */
+ public static boolean isStopping() {
+ return server.isStopping();
+ }
// Paper end
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 7195b480a16aa67f8e06fd3064b1072eafbb27b2..16a74b834c4d4b907f9b11ccf9ef9804514df224 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1620,5 +1620,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return Current tick
*/
int getCurrentTick();
+
+ /**
+ * Checks if the server is in the process of being shutdown.
+ *
+ * @return true if server is in the process of being shutdown
+ */
+ boolean isStopping();
// Paper end
}