From 9badea8a554448c3574c3aeb1c0f29f5d76239a4 Mon Sep 17 00:00:00 2001 From: Abel <56084910+Abelkrijgtalles@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:22:20 +0100 Subject: [PATCH] Add API to check if the server is sleeping (#11605) --- ...I-to-check-if-the-server-is-sleeping.patch | 22 +++++++++++ ...I-to-check-if-the-server-is-sleeping.patch | 37 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 patches/api/API-to-check-if-the-server-is-sleeping.patch create mode 100644 patches/server/API-to-check-if-the-server-is-sleeping.patch diff --git a/patches/api/API-to-check-if-the-server-is-sleeping.patch b/patches/api/API-to-check-if-the-server-is-sleeping.patch new file mode 100644 index 0000000000..0bbc301a3f --- /dev/null +++ b/patches/api/API-to-check-if-the-server-is-sleeping.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Abel +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Server.java ++++ b/src/main/java/org/bukkit/Server.java +@@ -0,0 +0,0 @@ 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/API-to-check-if-the-server-is-sleeping.patch b/patches/server/API-to-check-if-the-server-is-sleeping.patch new file mode 100644 index 0000000000..a83410e206 --- /dev/null +++ b/patches/server/API-to-check-if-the-server-is-sleeping.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Abel +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -0,0 +0,0 @@ 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 + }