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
𝑩𝒊𝒒𝒖𝒂𝒕𝒆𝒓𝒏𝒊𝒐𝒏𝒔 a9adcf48e5 Parallel World Ticking API for monitoring tools (#493)
* Parallel World Ticking API for monitoring tools
2025-09-08 22:28:51 -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 82e56218b5c854a16851b75e3145e301d5fedab0..e12d161ac49f4725faf3ad2d13972524f625b862 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2929,4 +2929,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 bb9fe9a6c3116e83d2ebd98f81298454f6677ccc..5b02d1938ddaf02c7f227271c0dc27702a41fc83 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -4494,6 +4494,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
*/