Paper/Spigot-Server-Patches/0679-Expose-Tracked-Players.patch
Josh Roy 4c9bdf53ac
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5299)
Upstream has released updates that appear 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:
9d0ad318 Fix javadoc errors in previous commits
9501daa2 #578: Add methods to modify the rate of regeneration and starvation
197d8f3d #577: Add EntityExhaustionEvent

CraftBukkit Changes:
a021e334 #795: Add methods to modify the rate of regeneration and starvation
509e523c #792: Add EntityExhaustionEvent

Spigot Changes:
db99f821 Rebuild patches
2021-03-03 14:43:45 -08:00

54 Zeilen
2.3 KiB
Diff

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/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index d8787985ab4c94e9808332c15b3d16d4b52ba195..e87e1b04e13593f1efa4d1c59cb9e433f2b3c694 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -80,7 +80,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
private CraftEntity bukkitEntity;
- PlayerChunkMap.EntityTracker tracker; // Paper
+ public PlayerChunkMap.EntityTracker tracker; // Paper package private -> public
boolean collisionLoadChunks = false; // Paper
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
index 4b214783ad4fabf5c2dc4c6c45635dc6e75f2113..fc761a3bd87004f16ff9b0a3b0add52f7938f566 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;
@@ -2296,6 +2297,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()
{