From eca2ac0d7e402cb33558f9c18e8928433e2c031c Mon Sep 17 00:00:00 2001
From: Bukkit/Spigot <noreply+git-bukkit@papermc.io>
Date: Wed, 6 Nov 2024 20:38:04 +1100
Subject: [PATCH] SPIGOT-7946: API for server pause when empty seconds

By: md_5 <git@md-5.net>
---
 .../src/main/java/org/bukkit/Bukkit.java      | 24 +++++++++++++++++++
 .../src/main/java/org/bukkit/Server.java      | 18 ++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java
index 083b98a999..964677d9d5 100644
--- a/paper-api/src/main/java/org/bukkit/Bukkit.java
+++ b/paper-api/src/main/java/org/bukkit/Bukkit.java
@@ -1845,6 +1845,30 @@ public final class Bukkit {
         return server.getIdleTimeout();
     }
 
+    /**
+     * Gets the pause when empty threshold seconds. To save resources, the
+     * server will pause most functions after this time if there are no players
+     * online.
+     *
+     * @return the pause threshold in seconds
+     */
+    public static int getPauseWhenEmptyTime() {
+        return server.getPauseWhenEmptyTime();
+    }
+
+    /**
+     * Sets the pause when empty threshold seconds. To save resources, the
+     * server will pause most functions after this time if there are no players
+     * online.
+     * <p>
+     * A value of less than 0 will disable the setting
+     *
+     * @param seconds the pause threshold in seconds
+     */
+    public static void setPauseWhenEmptyTime(int seconds) {
+        server.setPauseWhenEmptyTime(seconds);
+    }
+
     /**
      * Create a ChunkData for use in a generator.
      *
diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java
index b574053537..6cd2f9ab64 100644
--- a/paper-api/src/main/java/org/bukkit/Server.java
+++ b/paper-api/src/main/java/org/bukkit/Server.java
@@ -1565,6 +1565,24 @@ public interface Server extends PluginMessageRecipient {
      */
     public int getIdleTimeout();
 
+    /**
+     * Gets the pause when empty threshold seconds. To save resources, the
+     * pause most functions after this time if there are no players online.
+     *
+     * @return the pause threshold in seconds
+     */
+    public int getPauseWhenEmptyTime();
+
+    /**
+     * Sets the pause when empty threshold seconds. To save resources, the
+     * pause most functions after this time if there are no players online.
+     * <p>
+     * A value of less than 0 will disable the setting
+     *
+     * @param seconds the pause threshold in seconds
+     */
+    public void setPauseWhenEmptyTime(int seconds);
+
     /**
      * Create a ChunkData for use in a generator.
      *