diff --git a/patches/api/0006-Add-TPS-From-Region.patch b/patches/api/0006-Add-TPS-From-Region.patch new file mode 100644 index 000000000..fd0c3db28 --- /dev/null +++ b/patches/api/0006-Add-TPS-From-Region.patch @@ -0,0 +1,68 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Euphyllia Bierque +Date: Mon, 3 Jun 2024 11:01:06 +0200 +Subject: [PATCH] Add TPS From Region + + +diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java +index 67c021f6d5d2afed92c7ceb4f511e3a43bbe2417..f85b6efd4d2982acfa173920c9fd601d1ff47cc2 100644 +--- a/src/main/java/org/bukkit/Bukkit.java ++++ b/src/main/java/org/bukkit/Bukkit.java +@@ -2397,6 +2397,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 d4c5b06fe4be177442ef1abaf1b223c6c2845930..4d65b05931dff6420c4da45a3f8ab99f12a31980 100644 +--- a/src/main/java/org/bukkit/Server.java ++++ b/src/main/java/org/bukkit/Server.java +@@ -2050,6 +2050,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} diff --git a/patches/server/0019-Add-TPS-From-Region.patch b/patches/server/0019-Add-TPS-From-Region.patch new file mode 100644 index 000000000..698af48c4 --- /dev/null +++ b/patches/server/0019-Add-TPS-From-Region.patch @@ -0,0 +1,53 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Euphyllia Bierque +Date: Mon, 3 Jun 2024 11:01:19 +0200 +Subject: [PATCH] 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 273c37b63df3f14488586f9217c7b19a8f3d8ad5..e9156358bb42cb2e2e43029da1c2fa7e8e00f2f8 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -3114,6 +3114,42 @@ public final class CraftServer implements Server { + }; + } + ++ // 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 ++ 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) {