testserver/Spigot-Server-Patches/0679-Expose-Tracked-Players...

54 lines
2.3 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 26 Feb 2021 16:24:25 -0600
Subject: [PATCH] Expose Tracked Players
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
2021-03-16 15:50:45 +00:00
index f7223f214f911dd25abcf3a52745588ec630241d..7abeeefeb579a43bc9ee85fd4150afacfb11c802 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2021-03-16 13:04:28 +00:00
@@ -172,7 +172,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
private CraftEntity bukkitEntity;
- PlayerChunkMap.EntityTracker tracker; // Paper
+ public PlayerChunkMap.EntityTracker tracker; // Paper package private -> public
2021-03-16 13:04:28 +00:00
public boolean collisionLoadChunks = false; // Paper
public Throwable addedToWorldStack; // Paper - entity debug
public CraftEntity getBukkitEntity() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2021-03-16 15:50:45 +00:00
index e97ad53eb8bdc4c71d8014d060710cb3a29ab7f8..e5549439b3d4d608cf37dd33b6c8c9e10dfe9328 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -16,6 +16,7 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections; // Paper
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
2021-03-16 15:50:45 +00:00
@@ -2306,6 +2307,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end
+ // Paper start
+ @Override
+ public Set<Player> getTrackedPlayers() {
+ if (entity.tracker == null) {
+ return Collections.emptySet();
+ }
+
+ Set<Player> set = new HashSet<>(entity.tracker.trackedPlayers.size());
+ for (EntityPlayer entityPlayer : entity.tracker.trackedPlayers) {
+ set.add(entityPlayer.getBukkitEntity().getPlayer());
+ }
+ return set;
+ }
+ // Paper end
+
// Spigot start
private final Player.Spigot spigot = new Player.Spigot()
{