9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/paper-patches/features/0047-Fish-Parallel-World-Ticking-API.patch
Dreeam 35ac5d48ed Cleanup PWT (#533)
* Unify comment format
* More configurable
* Remove one extra execute mid-tick task call in level tick when PWT is disabled

This may cause extremely rare, weird, strange, magic, mysterious issues with plugins, or potentially more.

One example is that it may cause boss mob duplication issue when `ONE MOB ONLY` was enabled in plugin SupremeBosses
2025-10-25 07:41:43 -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 efffc80a44f626718e6969850ac5dfc48aec4547..abbbfc2afba2a0580537c49d40bd8b044dcdbfa7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2552,4 +2552,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
}