From 11de41c777955fe091393d47264a6a6a4982ecdb Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Sat, 11 Apr 2020 01:51:35 -0400 Subject: [PATCH] Add API MinecraftServer#isStopping (#3129) --- LICENSE.md | 1 + ...193-Expose-MinecraftServer-isRunning.patch | 47 +++++++++++++++++++ ...464-Expose-MinecraftServer-isRunning.patch | 25 ++++++++++ 3 files changed, 73 insertions(+) create mode 100644 Spigot-API-Patches/0193-Expose-MinecraftServer-isRunning.patch create mode 100644 Spigot-Server-Patches/0464-Expose-MinecraftServer-isRunning.patch diff --git a/LICENSE.md b/LICENSE.md index b2ec4cbfa..2f63bde76 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -40,5 +40,6 @@ MicleBrick Trigary rickyboy320 DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com> +JRoy Robert Norman , ``` diff --git a/Spigot-API-Patches/0193-Expose-MinecraftServer-isRunning.patch b/Spigot-API-Patches/0193-Expose-MinecraftServer-isRunning.patch new file mode 100644 index 000000000..6fbda7b50 --- /dev/null +++ b/Spigot-API-Patches/0193-Expose-MinecraftServer-isRunning.patch @@ -0,0 +1,47 @@ +From 4cafe0ab6318dce5b1775e57728b433bf581267d Mon Sep 17 00:00:00 2001 +From: JRoy +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 + diff --git a/Spigot-Server-Patches/0464-Expose-MinecraftServer-isRunning.patch b/Spigot-Server-Patches/0464-Expose-MinecraftServer-isRunning.patch new file mode 100644 index 000000000..88f53a790 --- /dev/null +++ b/Spigot-Server-Patches/0464-Expose-MinecraftServer-isRunning.patch @@ -0,0 +1,25 @@ +From b8b834494e5bc24038c34e2ad59a46b38a1330fd Mon Sep 17 00:00:00 2001 +From: JRoy +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 +