3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Indicate ticking status in entity list command (#2856)

Dieser Commit ist enthalten in:
Spottedleaf 2020-03-18 05:38:24 -07:00 committet von GitHub
Ursprung 2ff7b4800b
Commit 26070a0e5c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 58 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From b6108d5414d5d24bb0d9a9aa9284e3f9c58ae743 Mon Sep 17 00:00:00 2001 From 8f849e950e96e48bf06a93f787265c4e66db48a1 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com> From: Zach Brown <zach.brown@destroystokyo.com>
Date: Mon, 29 Feb 2016 21:02:09 -0600 Date: Mon, 29 Feb 2016 21:02:09 -0600
Subject: [PATCH] Paper config files Subject: [PATCH] Paper config files
@ -6,10 +6,10 @@ Subject: [PATCH] Paper config files
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
new file mode 100644 new file mode 100644
index 000000000..db899937b index 000000000..41c79650b
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -0,0 +1,247 @@ @@ -0,0 +1,256 @@
+package com.destroystokyo.paper; +package com.destroystokyo.paper;
+ +
+import com.google.common.base.Functions; +import com.google.common.base.Functions;
@ -185,30 +185,34 @@ index 000000000..db899937b
+ } + }
+ WorldServer world = ((CraftWorld) Bukkit.getWorld(worldName)).getHandle(); + WorldServer world = ((CraftWorld) Bukkit.getWorld(worldName)).getHandle();
+ +
+ Map<MinecraftKey, Integer> nonEntityTicking = Maps.newHashMap();
+ ChunkProviderServer chunkProviderServer = world.getChunkProvider();
+
+ Collection<Entity> entities = world.entitiesById.values(); + Collection<Entity> entities = world.entitiesById.values();
+ entities.forEach(e -> { + entities.forEach(e -> {
+ if (!e.isChunkLoaded()) {
+ return;
+ }
+ MinecraftKey key = new MinecraftKey(""); // TODO: update in next patch + MinecraftKey key = new MinecraftKey(""); // TODO: update in next patch
+ +
+ MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); + MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
+ ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ()); + ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
+ info.left++; + info.left++;
+ info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1); + info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1);
+ if (!chunkProviderServer.isInEntityTickingChunk(e)) {
+ nonEntityTicking.merge(key, Integer.valueOf(1), Integer::sum);
+ }
+ }); + });
+ +
+ if (names.size() == 1) { + if (names.size() == 1) {
+ MinecraftKey name = names.iterator().next(); + MinecraftKey name = names.iterator().next();
+ Pair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.get(name); + Pair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.get(name);
+ int nonTicking = nonEntityTicking.getOrDefault(name, Integer.valueOf(0)).intValue();
+ if (info == null) { + if (info == null) {
+ sender.sendMessage(ChatColor.RED + "No entities found."); + sender.sendMessage(ChatColor.RED + "No entities found.");
+ return; + return;
+ } + }
+ sender.sendMessage("Entity: " + name + " Total: " + info.getLeft()); + sender.sendMessage("Entity: " + name + " Total Ticking: " + (info.getLeft() - nonTicking) + ", Total Non-Ticking: " + nonTicking);
+ info.getRight().entrySet().stream() + info.getRight().entrySet().stream()
+ .sorted((a, b) -> !a.getValue().equals(b.getValue()) ? b.getValue() - a.getValue() : a.getKey().toString().compareTo(b.getKey().toString())) + .sorted((a, b) -> !a.getValue().equals(b.getValue()) ? b.getValue() - a.getValue() : a.getKey().toString().compareTo(b.getKey().toString()))
+ .limit(10).forEach(e -> sender.sendMessage(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z)); + .limit(10).forEach(e -> sender.sendMessage(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z + (chunkProviderServer.isEntityTickingChunk(e.getKey()) ? " (Ticking)" : " (Non-Ticking)")));
+ } else { + } else {
+ List<Pair<MinecraftKey, Integer>> info = list.entrySet().stream() + List<Pair<MinecraftKey, Integer>> info = list.entrySet().stream()
+ .filter(e -> names.contains(e.getKey())) + .filter(e -> names.contains(e.getKey()))
@ -222,8 +226,13 @@ index 000000000..db899937b
+ } + }
+ +
+ int count = info.stream().mapToInt(Pair::getRight).sum(); + int count = info.stream().mapToInt(Pair::getRight).sum();
+ sender.sendMessage("Total: " + count); + int nonTickingCount = nonEntityTicking.values().stream().mapToInt(Integer::intValue).sum();
+ info.forEach(e -> sender.sendMessage(" " + e.getValue() + ": " + e.getKey())); + sender.sendMessage("Total Ticking: " + (count - nonTickingCount) + ", Total Non-Ticking: " + nonTickingCount);
+ info.forEach(e -> {
+ int nonTicking = nonEntityTicking.getOrDefault(e.getKey(), Integer.valueOf(0)).intValue();
+ sender.sendMessage(" " + (e.getValue() - nonTicking) + " (" + nonTicking + ") " + ": " + e.getKey());
+ });
+ sender.sendMessage("* First number is ticking entities, second number is non-ticking entities");
+ } + }
+ break; + break;
+ } + }
@ -520,6 +529,30 @@ index 000000000..a73865739
+ return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path)); + return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 41eac3588..32c496fa8 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -260,15 +260,15 @@ public class ChunkProviderServer extends IChunkProvider {
}
}
- @Override
- public boolean a(Entity entity) {
+ public final boolean isInEntityTickingChunk(Entity entity) { return this.a(entity); } // Paper - OBFHELPER
+ @Override public boolean a(Entity entity) {
long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
return this.a(i, PlayerChunk::b);
}
- @Override
- public boolean a(ChunkCoordIntPair chunkcoordintpair) {
+ public final boolean isEntityTickingChunk(ChunkCoordIntPair chunkcoordintpair) { return this.a(chunkcoordintpair); } // Paper - OBFHELPER
+ @Override public boolean a(ChunkCoordIntPair chunkcoordintpair) {
return this.a(chunkcoordintpair.pair(), PlayerChunk::b);
}
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 136d1b50f..9eed98e37 100644 index 136d1b50f..9eed98e37 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java --- a/src/main/java/net/minecraft/server/DedicatedServer.java
@ -732,5 +765,5 @@ index 5597d4100..4965a48c3 100644
config.addDefault( "world-settings.default." + path, def ); config.addDefault( "world-settings.default." + path, def );
return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) ); return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
-- --
2.25.0 2.25.1

Datei anzeigen

@ -1,4 +1,4 @@
From 0ee183d069ba046f8fe24a3f2d8f402a9c7f3a79 Mon Sep 17 00:00:00 2001 From 67f22b9c0a3cfa5f35bbefd0634acb29759cb809 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Wed, 4 Jul 2018 01:40:13 -0400 Date: Wed, 4 Jul 2018 01:40:13 -0400
Subject: [PATCH] Add MinecraftKey Information to Objects Subject: [PATCH] Add MinecraftKey Information to Objects
@ -6,20 +6,20 @@ Subject: [PATCH] Add MinecraftKey Information to Objects
Stores the reference to the objects respective MinecraftKey Stores the reference to the objects respective MinecraftKey
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index db899937be..eecf27370b 100644 index 3392ed13f..d2c325050 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -178,7 +178,7 @@ public class PaperCommand extends Command { @@ -178,7 +178,7 @@ public class PaperCommand extends Command {
if (!e.isChunkLoaded()) {
return; Collection<Entity> entities = world.entitiesById.values();
} entities.forEach(e -> {
- MinecraftKey key = new MinecraftKey(""); // TODO: update in next patch - MinecraftKey key = new MinecraftKey(""); // TODO: update in next patch
+ MinecraftKey key = e.getMinecraftKey(); + MinecraftKey key = e.getMinecraftKey();
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ()); ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 8789191fe6..7899fd6d88 100644 index 8789191fe..7899fd6d8 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -49,7 +49,7 @@ import org.bukkit.event.player.PlayerTeleportEvent; @@ -49,7 +49,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
@ -65,7 +65,7 @@ index 8789191fe6..7899fd6d88 100644
protected abstract void a(NBTTagCompound nbttagcompound); protected abstract void a(NBTTagCompound nbttagcompound);
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
index cbf0c2f25d..79f8549660 100644 index cbf0c2f25..79f854966 100644
--- a/src/main/java/net/minecraft/server/EntityTypes.java --- a/src/main/java/net/minecraft/server/EntityTypes.java
+++ b/src/main/java/net/minecraft/server/EntityTypes.java +++ b/src/main/java/net/minecraft/server/EntityTypes.java
@@ -237,6 +237,7 @@ public class EntityTypes<T extends Entity> { @@ -237,6 +237,7 @@ public class EntityTypes<T extends Entity> {
@ -78,7 +78,7 @@ index cbf0c2f25d..79f8549660 100644
} }
diff --git a/src/main/java/net/minecraft/server/KeyedObject.java b/src/main/java/net/minecraft/server/KeyedObject.java diff --git a/src/main/java/net/minecraft/server/KeyedObject.java b/src/main/java/net/minecraft/server/KeyedObject.java
new file mode 100644 new file mode 100644
index 0000000000..743142d030 index 000000000..743142d03
--- /dev/null --- /dev/null
+++ b/src/main/java/net/minecraft/server/KeyedObject.java +++ b/src/main/java/net/minecraft/server/KeyedObject.java
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
@ -92,7 +92,7 @@ index 0000000000..743142d030
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
index 40752f7617..9071bb7ece 100644 index 40752f761..9071bb7ec 100644
--- a/src/main/java/net/minecraft/server/TileEntity.java --- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java
@@ -11,7 +11,7 @@ import org.bukkit.inventory.InventoryHolder; @@ -11,7 +11,7 @@ import org.bukkit.inventory.InventoryHolder;
@ -141,5 +141,5 @@ index 40752f7617..9071bb7ece 100644
public World getWorld() { public World getWorld() {
return this.world; return this.world;
-- --
2.25.0 2.25.1

Datei anzeigen

@ -1,4 +1,4 @@
From 100a6d3800f83f2af6d7200bebf89e5fc12c5262 Mon Sep 17 00:00:00 2001 From 8ff60cdb29e29f95f5c7a65ae6affe3ab202086a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sat, 28 Jul 2018 12:18:27 -0400 Date: Sat, 28 Jul 2018 12:18:27 -0400
Subject: [PATCH] Ignore Dead Entities in entityList iteration Subject: [PATCH] Ignore Dead Entities in entityList iteration
@ -11,12 +11,12 @@ This will ensure that dead entities are skipped from iteration since
they shouldn't of been in the list in the first place. they shouldn't of been in the list in the first place.
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index eecf27370..d704fc79c 100644 index d2c325050..ec7c9ad4b 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -179,6 +179,7 @@ public class PaperCommand extends Command { @@ -179,6 +179,7 @@ public class PaperCommand extends Command {
return; Collection<Entity> entities = world.entitiesById.values();
} entities.forEach(e -> {
MinecraftKey key = e.getMinecraftKey(); MinecraftKey key = e.getMinecraftKey();
+ if (e.shouldBeRemoved) return; // Paper + if (e.shouldBeRemoved) return; // Paper