mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 22:13:42 +01:00
Add World.getPlayerCount
This commit is contained in:
parent
e3070b32a7
commit
9606774ee6
@ -1,4 +1,4 @@
|
|||||||
From 20f93fadc1651fc03cbd926370d79d191a3fe1f1 Mon Sep 17 00:00:00 2001
|
From 47bfe6afa93cf0a7068911d1789256f8f7159f5c Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Sat, 7 Jan 2017 15:23:03 -0500
|
Date: Sat, 7 Jan 2017 15:23:03 -0500
|
||||||
Subject: [PATCH] Provide E/TE/Chunk count stat methods
|
Subject: [PATCH] Provide E/TE/Chunk count stat methods
|
||||||
@ -7,10 +7,10 @@ Provides counts without the ineffeciency of using .getEntities().size()
|
|||||||
which creates copy of the collections.
|
which creates copy of the collections.
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||||
index 56f50296..2b6136fd 100644
|
index 56f5029..12146dd 100644
|
||||||
--- a/src/main/java/org/bukkit/World.java
|
--- a/src/main/java/org/bukkit/World.java
|
||||||
+++ b/src/main/java/org/bukkit/World.java
|
+++ b/src/main/java/org/bukkit/World.java
|
||||||
@@ -24,6 +24,28 @@ import org.bukkit.util.Vector;
|
@@ -24,6 +24,33 @@ import org.bukkit.util.Vector;
|
||||||
*/
|
*/
|
||||||
public interface World extends PluginMessageRecipient, Metadatable {
|
public interface World extends PluginMessageRecipient, Metadatable {
|
||||||
|
|
||||||
@ -34,11 +34,16 @@ index 56f50296..2b6136fd 100644
|
|||||||
+ * @return The amount of Chunks in this world
|
+ * @return The amount of Chunks in this world
|
||||||
+ */
|
+ */
|
||||||
+ int getChunkCount();
|
+ int getChunkCount();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * @return The amount of Players in this world
|
||||||
|
+ */
|
||||||
|
+ int getPlayerCount();
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
/**
|
/**
|
||||||
* Gets the {@link Block} at the given coordinates
|
* Gets the {@link Block} at the given coordinates
|
||||||
*
|
*
|
||||||
--
|
--
|
||||||
2.11.0
|
2.9.2.windows.1
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From 533659e46d866b93a8dc20fd6b027351964e4da4 Mon Sep 17 00:00:00 2001
|
From a5f641a75dc0b2c006fd1c401171ef3d291a8567 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Sat, 7 Jan 2017 15:24:46 -0500
|
Date: Sat, 7 Jan 2017 15:24:46 -0500
|
||||||
Subject: [PATCH] Provide E/TE/Chunk count stat methods
|
Subject: [PATCH] Provide E/TE/Chunk count stat methods
|
||||||
@ -7,10 +7,10 @@ Provides counts without the ineffeciency of using .getEntities().size()
|
|||||||
which creates copy of the collections.
|
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
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
index 5a44a9f38..1c4040760 100644
|
index 5a44a9f..da478ef 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
+++ b/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 {
|
@@ -78,6 +78,29 @@ public class CraftWorld implements World {
|
||||||
private int chunkLoadCount = 0;
|
private int chunkLoadCount = 0;
|
||||||
private int chunkGCTickCount;
|
private int chunkGCTickCount;
|
||||||
|
|
||||||
@ -32,11 +32,14 @@ index 5a44a9f38..1c4040760 100644
|
|||||||
+ public int getChunkCount() {
|
+ public int getChunkCount() {
|
||||||
+ return world.getChunkProviderServer().chunks.size();
|
+ return world.getChunkProviderServer().chunks.size();
|
||||||
+ }
|
+ }
|
||||||
|
+ public int getPlayerCount() {
|
||||||
|
+ return world.players.size();
|
||||||
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
private static final Random rand = new Random();
|
private static final Random rand = new Random();
|
||||||
|
|
||||||
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) {
|
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) {
|
||||||
--
|
--
|
||||||
2.11.0
|
2.9.2.windows.1
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From e8a422782bf1466348b1dcd40c75e8576b52c233 Mon Sep 17 00:00:00 2001
|
From 28cd2c20257447d30c493e2b0761dab0285ab10f Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Sat, 7 Jan 2017 16:06:44 -0500
|
Date: Sat, 7 Jan 2017 16:06:44 -0500
|
||||||
Subject: [PATCH] Enforce Sync Chunk Unloads
|
Subject: [PATCH] Enforce Sync Chunk Unloads
|
||||||
@ -7,10 +7,10 @@ Unloading Chunks async is extremely dangerous. This will force it to main
|
|||||||
the same way we handle async chunk loads.
|
the same way we handle async chunk loads.
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
index 1c4040760..c678718b7 100644
|
index da478ef..95dcb9f 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
@@ -235,6 +235,7 @@ public class CraftWorld implements World {
|
@@ -238,6 +238,7 @@ public class CraftWorld implements World {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean unloadChunk0(int x, int z, boolean save) {
|
private boolean unloadChunk0(int x, int z, boolean save) {
|
||||||
@ -18,7 +18,7 @@ index 1c4040760..c678718b7 100644
|
|||||||
net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkIfLoaded(x, z);
|
net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkIfLoaded(x, z);
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
return true;
|
return true;
|
||||||
@@ -242,6 +243,7 @@ public class CraftWorld implements World {
|
@@ -245,6 +246,7 @@ public class CraftWorld implements World {
|
||||||
|
|
||||||
// If chunk had previously been queued to save, must do save to avoid loss of that data
|
// If chunk had previously been queued to save, must do save to avoid loss of that data
|
||||||
return world.getChunkProviderServer().unloadChunk(chunk, chunk.mustSave || save);
|
return world.getChunkProviderServer().unloadChunk(chunk, chunk.mustSave || save);
|
||||||
@ -27,5 +27,5 @@ index 1c4040760..c678718b7 100644
|
|||||||
|
|
||||||
public boolean regenerateChunk(int x, int z) {
|
public boolean regenerateChunk(int x, int z) {
|
||||||
--
|
--
|
||||||
2.11.0
|
2.9.2.windows.1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user