3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20: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>
Date: Mon, 29 Feb 2016 21:02:09 -0600
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
new file mode 100644
index 000000000..db899937b
index 000000000..41c79650b
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -0,0 +1,247 @@
@@ -0,0 +1,256 @@
+package com.destroystokyo.paper;
+
+import com.google.common.base.Functions;
@ -185,30 +185,34 @@ index 000000000..db899937b
+ }
+ WorldServer world = ((CraftWorld) Bukkit.getWorld(worldName)).getHandle();
+
+ Map<MinecraftKey, Integer> nonEntityTicking = Maps.newHashMap();
+ ChunkProviderServer chunkProviderServer = world.getChunkProvider();
+
+ Collection<Entity> entities = world.entitiesById.values();
+ entities.forEach(e -> {
+ if (!e.isChunkLoaded()) {
+ return;
+ }
+ MinecraftKey key = new MinecraftKey(""); // TODO: update in next patch
+
+ MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
+ ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
+ info.left++;
+ 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) {
+ MinecraftKey name = names.iterator().next();
+ Pair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.get(name);
+ int nonTicking = nonEntityTicking.getOrDefault(name, Integer.valueOf(0)).intValue();
+ if (info == null) {
+ sender.sendMessage(ChatColor.RED + "No entities found.");
+ 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()
+ .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 {
+ List<Pair<MinecraftKey, Integer>> info = list.entrySet().stream()
+ .filter(e -> names.contains(e.getKey()))
@ -222,8 +226,13 @@ index 000000000..db899937b
+ }
+
+ int count = info.stream().mapToInt(Pair::getRight).sum();
+ sender.sendMessage("Total: " + count);
+ info.forEach(e -> sender.sendMessage(" " + e.getValue() + ": " + e.getKey()));
+ int nonTickingCount = nonEntityTicking.values().stream().mapToInt(Integer::intValue).sum();
+ 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;
+ }
@ -520,6 +529,30 @@ index 000000000..a73865739
+ 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
index 136d1b50f..9eed98e37 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
@ -732,5 +765,5 @@ index 5597d4100..4965a48c3 100644
config.addDefault( "world-settings.default." + path, def );
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>
Date: Wed, 4 Jul 2018 01:40:13 -0400
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
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
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -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 = e.getMinecraftKey();
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
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
index 8789191fe6..7899fd6d88 100644
index 8789191fe..7899fd6d8 100644
--- a/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;
@ -65,7 +65,7 @@ index 8789191fe6..7899fd6d88 100644
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
index cbf0c2f25d..79f8549660 100644
index cbf0c2f25..79f854966 100644
--- a/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> {
@ -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
new file mode 100644
index 0000000000..743142d030
index 000000000..743142d03
--- /dev/null
+++ b/src/main/java/net/minecraft/server/KeyedObject.java
@@ -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
index 40752f7617..9071bb7ece 100644
index 40752f761..9071bb7ec 100644
--- a/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;
@ -141,5 +141,5 @@ index 40752f7617..9071bb7ece 100644
public World getWorld() {
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>
Date: Sat, 28 Jul 2018 12:18:27 -0400
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.
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
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -179,6 +179,7 @@ public class PaperCommand extends Command {
return;
}
Collection<Entity> entities = world.entitiesById.values();
entities.forEach(e -> {
MinecraftKey key = e.getMinecraftKey();
+ if (e.shouldBeRemoved) return; // Paper