mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-21 22:57:01 +01:00
Add isTickSleeping API
This commit is contained in:
parent
fe2f3d4693
commit
fa79d38e66
2 changed files with 61 additions and 0 deletions
25
patches/api/0497-Add-isTickSleeping-API.patch
Normal file
25
patches/api/0497-Add-isTickSleeping-API.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||||
|
Date: Tue, 29 Oct 2024 17:39:42 -0700
|
||||||
|
Subject: [PATCH] Add isTickSleeping API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index 6246251caf2c6f025c824b8e7a944b8d48751fa1..5d492abddced79a3f8f213440b01cdb6d4ae8afe 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -2438,6 +2438,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
* @return the potion brewer
|
||||||
|
*/
|
||||||
|
@NotNull org.bukkit.potion.PotionBrewer getPotionBrewer();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns whether the server is 'tick sleeping' due to being
|
||||||
|
+ * empty for the period configured in server.properties.
|
||||||
|
+ *
|
||||||
|
+ * @return whether the server is 'tick sleeping'
|
||||||
|
+ */
|
||||||
|
+ boolean isTickSleeping();
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
// Paper start - Folia region threading API
|
36
patches/server/1056-Add-isTickSleeping-API.patch
Normal file
36
patches/server/1056-Add-isTickSleeping-API.patch
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||||
|
Date: Tue, 29 Oct 2024 17:39:34 -0700
|
||||||
|
Subject: [PATCH] Add isTickSleeping API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
index 7933d6900dac67a24fb5f9378097dbde34be30b1..7178380c61ad797de636d34731fb7b18c643e9fd 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 - sleeping api
|
||||||
|
+ public boolean isTickSleeping() {
|
||||||
|
+ return this.emptyTicks >= this.pauseWhileEmptySeconds() * 20;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - sleeping api
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
index 9f9eefc7346838a9effcda861cecd098092efb0f..1cb4aa3edb4149a01c3473379e101d926a581cfc 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
@@ -3235,5 +3235,10 @@ public final class CraftServer implements Server {
|
||||||
|
public io.papermc.paper.potion.PaperPotionBrewer getPotionBrewer() {
|
||||||
|
return this.potionBrewer;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isTickSleeping() {
|
||||||
|
+ return this.console.isTickSleeping();
|
||||||
|
+ }
|
||||||
|
// Paper end
|
||||||
|
}
|
Loading…
Reference in a new issue