Paper/Spigot-Server-Patches/0143-Provide-E-TE-Chunk-count-stat-methods.patch
Shane Freeder 73983e4c16
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
3dc4cdcd Update to Minecraft 1.14.3-pre4
88b25a8c SPIGOT-5098: Add a method to allow colored sign changes
6d913552 Update to Minecraft 1.14.3-pre4

CraftBukkit Changes:
f1f33559 Update to Minecraft 1.14.3
8a3d3f49 SPIGOT-5098: Add a method to allow colored sign changes
533290e2 SPIGOT-5100: Console warning from pig zombie targeting
6dde4b9f SPIGOT-5094: Allow opening merchant for wandering traders and hide the xp bar for custom merchants
9af90077 SPIGOT-5097: Bukkit.clearRecipes() no longer working
38fa220f Fix setting game rules via the API
fe3930ce Update to Minecraft 1.14.3-pre4
da071ec5 Remove outdated build delay.

Spigot Changes:
4d2f30f1 Update to Minecraft 1.14.3
f16400e3 Update to Minecraft 1.14.3-pre4
2019-06-25 03:46:54 +01:00

52 lines
1.9 KiB
Diff

From c4c9bd77113a059d54e10603eb602a8454310e36 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 7c2eba8aa4..b8e16e1870 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -264,6 +264,35 @@ public class CraftWorld implements World {
private int waterAnimalSpawn = -1;
private int ambientSpawn = -1;
+ // Paper start - Provide fast information methods
+ // TODO review these changes
+ public int getEntityCount() {
+ return world.entitiesById.size();
+ }
+ public int getTileEntityCount() {
+ // We don't use the full world tile entity list, so we must iterate chunks
+ Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkProvider().playerChunkMap.visibleChunks;
+ int size = 0;
+ for (net.minecraft.server.PlayerChunk playerchunk : chunks.values()) {
+ net.minecraft.server.Chunk chunk = playerchunk.getChunk();
+ if (chunk == null) {
+ continue;
+ }
+ size += chunk.tileEntities.size();
+ }
+ return size;
+ }
+ public int getTickableTileEntityCount() {
+ return world.tileEntityListTick.size();
+ }
+ public int getChunkCount() {
+ return world.getChunkProvider().playerChunkMap.visibleChunks.size();
+ }
+ public int getPlayerCount() {
+ return world.players.size();
+ }
+ // Paper end
+
private static final Random rand = new Random();
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) {
--
2.22.0