9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-api/paper-patches/features/0020-Fish-Parallel-World-Ticking-API.patch
2025-09-27 12:42:53 -04:00

68 lines
2.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Biquaternions <biquaternions@serlith.net>
Date: Tue, 2 Sep 2025 13:54:37 -0500
Subject: [PATCH] Fish: Parallel World Ticking API
Original license: MIT
Original project: https://github.com/Biquaternions/Fish
This patch provides an API for performance monitoring plugins like PurpurBars.
A better approach would be to include an event when the world is done ticking,
which will allow to re-use the RollingAverage logic from Spark and Minecraft internals.
However, since every fork developer will want to have said event into their own namespace,
it will be virtually impossible to provide a universal API.
With this approach only new methods are added into already existing Bukkit API, and the same
naming conventions as Bukkit were used, which means there's a bigger chance of this API to
get standarized.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 46773b5921e5d84a9a47b4b0dcad98a4a76050dc..807463113646eb09bc8d7203540c7ed872c30dd2 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2966,4 +2966,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
// Leaves start - Photographer API
@NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager();
// Leaves end - Photographer API
+
+ // Fish start - Parallel World Ticking API
+ /**
+ * Returns whether the software has the Parallel World Ticking feature enabled
+ *
+ * @return If the Parallel World Ticking feature is enabled
+ */
+ public default boolean isParallelWorldTickingEnabled() {
+ return false;
+ }
+ // Fish end - Parallel World Ticking API
}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index d320e8b621a8725d07579fbc3182df9b4822e3fb..f34133fe3492bbdc8d109c323fba14b1cbe9f54d 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -4663,6 +4663,25 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@NotNull
public Collection<GeneratedStructure> getStructures(int x, int z, @NotNull Structure structure);
+ // Fish start - Parallel World Ticking API
+ /**
+ * Get a sample of the world last tick times (in nanos)
+ *
+ * @return A sample of the world last tick times (in nanos)
+ */
+ public default long @NotNull [] getTickTimes() {
+ return new long[0];
+ }
+ /**
+ * Get the world's average tick time (in millis)
+ *
+ * @return World's local average tick time (in millis)
+ */
+ public default double getAverageTickTime () {
+ return 0.0;
+ }
+ // Fish end - Parallel World Ticking API
+
/**
* Represents various map environment types that a world may be
*/