Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
Provide E/TE/Chunk count stat methods
Provides counts without the ineffeciency of using .getEntities().size() which creates copy of the collections.
Dieser Commit ist enthalten in:
Ursprung
63130fd2aa
Commit
7e06f2145e
29
Spigot-API-Patches/0048-Provide-E-TE-Chunk-count-stat-methods.patch
Normale Datei
29
Spigot-API-Patches/0048-Provide-E-TE-Chunk-count-stat-methods.patch
Normale Datei
@ -0,0 +1,29 @@
|
||||
From 604dc8e444593ab84281c94ca4eb334164c96ea8 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 7 Jan 2017 15:23:03 -0500
|
||||
Subject: [PATCH] Provide E/TE/Chunk count stat methods
|
||||
|
||||
Provides counts without the ineffeciency of using .getEntities().size()
|
||||
which creates copy of the collections.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 56f50296..63cdcdb8 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -24,6 +24,13 @@ import org.bukkit.util.Vector;
|
||||
*/
|
||||
public interface World extends PluginMessageRecipient, Metadatable {
|
||||
|
||||
+ // Paper start
|
||||
+ int getEntityCount();
|
||||
+ int getTileEntityCount();
|
||||
+ int getTickableTileEntityCount();
|
||||
+ int getChunkCount();
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the {@link Block} at the given coordinates
|
||||
*
|
||||
--
|
||||
2.11.0
|
||||
|
@ -0,0 +1,42 @@
|
||||
From 533659e46d866b93a8dc20fd6b027351964e4da4 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 7 Jan 2017 15:24:46 -0500
|
||||
Subject: [PATCH] Provide E/TE/Chunk count stat methods
|
||||
|
||||
Provides counts without the ineffeciency of using .getEntities().size()
|
||||
which creates copy of the collections.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 5a44a9f38..1c4040760 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -78,6 +78,26 @@ public class CraftWorld implements World {
|
||||
private int chunkLoadCount = 0;
|
||||
private int chunkGCTickCount;
|
||||
|
||||
+ // Paper start - Provide fast information methods
|
||||
+ public int getEntityCount() {
|
||||
+ return world.entityList.size();
|
||||
+ }
|
||||
+ public int getTileEntityCount() {
|
||||
+ // We don't use the full world tile entity list, so we must iterate chunks
|
||||
+ int size = 0;
|
||||
+ for (net.minecraft.server.Chunk chunk : ((ChunkProviderServer) world.getChunkProvider()).chunks.values()) {
|
||||
+ size += chunk.tileEntities.size();
|
||||
+ }
|
||||
+ return size;
|
||||
+ }
|
||||
+ public int getTickableTileEntityCount() {
|
||||
+ return world.tileEntityListTick.size();
|
||||
+ }
|
||||
+ public int getChunkCount() {
|
||||
+ return world.getChunkProviderServer().chunks.size();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
private static final Random rand = new Random();
|
||||
|
||||
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) {
|
||||
--
|
||||
2.11.0
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren