aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1065-API-to-check-if-the-server-is-sleeping.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/1065-API-to-check-if-the-server-is-sleeping.patch')
-rw-r--r--patches/server/1065-API-to-check-if-the-server-is-sleeping.patch37
1 files changed, 37 insertions, 0 deletions
diff --git a/patches/server/1065-API-to-check-if-the-server-is-sleeping.patch b/patches/server/1065-API-to-check-if-the-server-is-sleeping.patch
new file mode 100644
index 0000000000..9f542e8138
--- /dev/null
+++ b/patches/server/1065-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 6a4f99c56f8f49f5087a582a8c77be2c261537bb..78ec2c6d4546bc4eaedd64fa8340f5654876f65c 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 11ff5f3b5cd25f0ad6ca944d59bca8434f8510d8..7afc3d4244c096f78d48338da2eb65c4e834b6f1 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+@@ -3258,4 +3258,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
+ }