9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-28 03:19:21 +00:00
Files
Leaf/leaf-server/paper-patches/features/0047-Fish-Parallel-World-Ticking-API.patch
Dreeam 3b162fb788 Move Purpur patches to first
To reduce the difficulty on maintenance and reduce chances to fix conflicts on updating
2025-10-01 18:27:42 -04:00

54 lines
2.4 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/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6d721742598f625bcf589491b2b59dbbf5f8c903..c3ee0170aa8d74a1f0089d73d9df7e6f049eb067 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -3366,4 +3366,11 @@ public final class CraftServer implements Server {
return photographerManager;
}
// Leaves end - replay mod api
+
+ // Fish start - Parallel World Ticking API
+ @Override
+ public boolean isParallelWorldTickingEnabled() {
+ return org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled;
+ }
+ // Fish end - Parallel World Ticking API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index ee5f342995a335593932a497c2bafd36d34cecb2..a16390fc13e1baf3cffbcfec5cc410a72ed47367 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2556,4 +2556,15 @@ public class CraftWorld extends CraftRegionAccessor implements World {
return POINTERS_SUPPLIER.view(this);
}
// Paper end
+
+ // Fish start - Parallel World Ticking API
+ @Override
+ public long @NotNull [] getTickTimes() {
+ return this.world.tickTimes5s.getTimes();
+ }
+ @Override
+ public double getAverageTickTime() {
+ return this.world.tickTimes5s.getAverage();
+ }
+ // Fish end - Parallel World Ticking API
}