Dropped duplicated patches

This commit is contained in:
MrHua269
2025-01-29 10:31:34 +08:00
parent a3b9a862ee
commit 818dfeede1
2 changed files with 0 additions and 121 deletions

View File

@@ -1,68 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Sun, 12 Jan 2025 15:39:43 +0800
Subject: [PATCH] FoliaPR Add TPS From Region
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 9196b1e62b328b1e9790b966600aba9681dd0ddc..c4ebe5b9c27277dcc984aa582af2a5e5e12ca936 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2441,6 +2441,28 @@ public final class Bukkit {
}
// Paper end
+ // Folia start
+ /**
+ * Gets the current location TPS.
+ *
+ * @param location the location for which to get the TPS
+ * @return current location TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
+ */
+ public double @Nullable [] getTPS(Location location) {
+ return server.getTPS(location);
+ }
+
+ /**
+ * Gets the current chunk TPS.
+ *
+ * @param chunk the chunk for which to get the TPS
+ * @return current chunk TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
+ */
+ public double @Nullable [] getTPS(Chunk chunk){
+ return server.getTPS(chunk);
+ }
+ // Folia end
+
/**
* Get the advancement specified by this key.
*
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 11923ef0ea75f702273ba5481ac6d46cc0f17697..6bba6c555e8873057693f60ac1a4b6281b299258 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2123,6 +2123,24 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
double getAverageTickTime();
// Paper end
+ // Folia start
+ /**
+ * Gets the current location TPS.
+ *
+ * @param location the location for which to get the TPS
+ * @return current location TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
+ */
+ public double @Nullable [] getTPS(Location location);
+
+ /**
+ * Gets the current chunk TPS.
+ *
+ * @param chunk the chunk for which to get the TPS
+ * @return current chunk TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
+ */
+ public double @Nullable [] getTPS(Chunk chunk);
+ // Folia end
+
// Paper start
/**
* Gets the active {@link org.bukkit.command.CommandMap}

View File

@@ -1,53 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Sun, 12 Jan 2025 15:38:13 +0800
Subject: [PATCH] FoliaPR Add TPS From Region
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d34502a826b1582dd13c6983ed1060373837353f..a089ee426a27325289a0740276997b9e8c9e3fe2 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -3149,6 +3149,42 @@ public final class CraftServer implements Server {
// Folia end - region threading
}
+ // Folia start
+ @Override
+ public double[] getTPS(org.bukkit.Location location) {
+ final int x = location.blockX() >> 4;
+ final int z = location.blockZ() >> 4;
+ final ServerLevel world = ((CraftWorld) location.getWorld()).getHandle();
+ return getTPSFromRegion(world, x, z);
+ }
+
+ @Override
+ public double[] getTPS(org.bukkit.Chunk chunk) {
+ final int x = chunk.getX();
+ final int z = chunk.getZ();
+ final ServerLevel world = ((CraftWorld) chunk.getWorld()).getHandle();
+ return getTPSFromRegion(world, x, z);
+ }
+
+ private double[] getTPSFromRegion(ServerLevel world, int x, int z) {
+ io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData, io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData>
+ region = world.regioniser.getRegionAtSynchronised(x, z);
+ if (region == null) {
+ return null;
+ } else {
+ io.papermc.paper.threadedregions.TickRegions.TickRegionData regionData = region.getData();
+ final long currTime = System.nanoTime();
+ return new double[] {
+ regionData.getRegionSchedulingHandle().getTickReport5s(currTime).tpsData().segmentAll().average(),
+ regionData.getRegionSchedulingHandle().getTickReport15s(currTime).tpsData().segmentAll().average(),
+ regionData.getRegionSchedulingHandle().getTickReport1m(currTime).tpsData().segmentAll().average(),
+ regionData.getRegionSchedulingHandle().getTickReport5m(currTime).tpsData().segmentAll().average(),
+ regionData.getRegionSchedulingHandle().getTickReport15m(currTime).tpsData().segmentAll().average(),
+ };
+ }
+ }
+ // Folia end
+
// Paper start - adventure sounds
@Override
public void playSound(final net.kyori.adventure.sound.Sound sound) {