Add API MinecraftServer#isStopping (#3129)

This commit is contained in:
Josh Roy 2020-04-11 01:51:35 -04:00 committed by GitHub
parent 942ff3c28e
commit 11de41c777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 0 deletions

View File

@ -40,5 +40,6 @@ MicleBrick <miclebrick@outlook.com>
Trigary <trigary0@gmail.com> Trigary <trigary0@gmail.com>
rickyboy320 <rickw320@hotmail.com> rickyboy320 <rickw320@hotmail.com>
DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com> DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com>
JRoy <joshroy126@gmail.com>
Robert Norman <spottedleaf@spottedleaf.dev>, <Spottedleaf@users.noreply.github.com> Robert Norman <spottedleaf@spottedleaf.dev>, <Spottedleaf@users.noreply.github.com>
``` ```

View File

@ -0,0 +1,47 @@
From 4cafe0ab6318dce5b1775e57728b433bf581267d 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 b9973406..dda12412 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1661,6 +1661,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 80f9abdc..5758ae79 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1455,5 +1455,12 @@ public interface Server extends PluginMessageRecipient {
* @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
}
--
2.17.1

View File

@ -0,0 +1,25 @@
From b8b834494e5bc24038c34e2ad59a46b38a1330fd Mon Sep 17 00:00:00 2001
From: JRoy <joshroy126@gmail.com>
Date: Fri, 10 Apr 2020 21:24:12 -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/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b9a398bc5..32121e87b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2207,5 +2207,10 @@ public final class CraftServer implements Server {
public int getCurrentTick() {
return net.minecraft.server.MinecraftServer.currentTick;
}
+
+ @Override
+ public boolean isStopping() {
+ return !net.minecraft.server.MinecraftServer.getServer().isRunning();
+ }
// Paper end
}
--
2.17.1