diff options
author | Abel <[email protected]> | 2024-11-22 12:22:20 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-11-22 12:22:20 +0100 |
commit | 8dc42fadfa85c772ab06e23f21573e8e56d147b1 (patch) | |
tree | 16b79875521381864b2320be916b579918f67db2 | |
parent | f8e2a671eb46eb9acaa6b563a9813cb2d235088a (diff) | |
download | Paper-8dc42fadfa85c772ab06e23f21573e8e56d147b1.tar.gz Paper-8dc42fadfa85c772ab06e23f21573e8e56d147b1.zip |
Add API to check if the server is sleeping (#11605)
-rw-r--r-- | patches/api/0498-API-to-check-if-the-server-is-sleeping.patch | 22 | ||||
-rw-r--r-- | patches/server/1068-API-to-check-if-the-server-is-sleeping.patch | 37 |
2 files changed, 59 insertions, 0 deletions
diff --git a/patches/api/0498-API-to-check-if-the-server-is-sleeping.patch b/patches/api/0498-API-to-check-if-the-server-is-sleeping.patch new file mode 100644 index 0000000000..219c527547 --- /dev/null +++ b/patches/api/0498-API-to-check-if-the-server-is-sleeping.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Abel <[email protected]> +Date: Sun, 10 Nov 2024 16:32:51 +0100 +Subject: [PATCH] API to check if the server is sleeping + + +diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java +index 0b78564256ebc647ebac402e549d86ab6e307c8d..ba366576a571214e67bcc529dc1bca19e1d59ef8 100644 +--- a/src/main/java/org/bukkit/Server.java ++++ b/src/main/java/org/bukkit/Server.java +@@ -2572,4 +2572,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + */ + boolean isOwnedByCurrentRegion(@NotNull Entity entity); + // Paper end - Folia region threading API ++ ++ // Paper start - API to check if the server is sleeping ++ /** ++ * Returns whether the server is sleeping/paused. ++ */ ++ boolean isPaused(); ++ // Paper end - API to check if the server is sleeping + } diff --git a/patches/server/1068-API-to-check-if-the-server-is-sleeping.patch b/patches/server/1068-API-to-check-if-the-server-is-sleeping.patch new file mode 100644 index 0000000000..ac432cd932 --- /dev/null +++ b/patches/server/1068-API-to-check-if-the-server-is-sleeping.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Abel <[email protected]> +Date: Sun, 10 Nov 2024 16:32:34 +0100 +Subject: [PATCH] API to check if the server is sleeping + + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 64b56abf8900d0424100da460fc68ac964394793..5d070f036dae6d93f863c55192b557419634456d 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -3186,4 +3186,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa + } + } + // Paper end - Add tick times API and /mspt command ++ ++ // Paper start - API to check if the server is sleeping ++ public boolean isTickPaused() { ++ return this.emptyTicks > 0 && this.emptyTicks >= this.pauseWhileEmptySeconds() * 20; ++ } ++ // Paper end - API to check if the server is sleeping + } +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index 806e56cb60235a99f468d36a059fdbd54c2d46e3..605662917a7720a6c5134fd1d93aa2d26116b76d 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -3246,4 +3246,11 @@ public final class CraftServer implements Server { + return this.potionBrewer; + } + // Paper end ++ ++ // Paper start - API to check if the server is sleeping ++ @Override ++ public boolean isPaused() { ++ return this.console.isTickPaused(); ++ } ++ // Paper end - API to check if the server is sleeping + } |