From 1f7df1832fdb0fe9f265bd9f65cc992a3c189cca Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Mon, 8 Nov 2021 16:39:42 -0500 Subject: [PATCH] Move `getTrackedPlayers` up from Player to Entity (#6569) --- patches/api/Expose-Tracked-Players.patch | 40 ++++++++------------- patches/server/Expose-Tracked-Players.patch | 29 +++++++-------- 2 files changed, 28 insertions(+), 41 deletions(-) diff --git a/patches/api/Expose-Tracked-Players.patch b/patches/api/Expose-Tracked-Players.patch index a667005325..f8ed1b1d3f 100644 --- a/patches/api/Expose-Tracked-Players.patch +++ b/patches/api/Expose-Tracked-Players.patch @@ -4,30 +4,20 @@ Date: Fri, 26 Feb 2021 16:24:25 -0600 Subject: [PATCH] Expose Tracked Players -diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java +diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/entity/Player.java -+++ b/src/main/java/org/bukkit/entity/Player.java -@@ -0,0 +0,0 @@ - package org.bukkit.entity; - - import java.net.InetSocketAddress; -+import java.util.Set; // Paper - import java.util.UUID; - import com.destroystokyo.paper.ClientOption; // Paper - import com.destroystokyo.paper.Title; // Paper -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - void sendOpLevel(byte level); - // Paper end - -+ // Paper start -+ /** -+ * @return Returns a set of Players within this player's tracking range (that the player's client can "see") -+ */ -+ @NotNull -+ Set getTrackedPlayers(); -+ // Paper end +--- a/src/main/java/org/bukkit/entity/Entity.java ++++ b/src/main/java/org/bukkit/entity/Entity.java +@@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent + * Check if entity is inside a ticking chunk + */ + public boolean isTicking(); + - // Spigot start - public class Spigot extends Entity.Spigot { - ++ /** ++ * Returns a set of {@link Player Players} within this entity's tracking range (players that can "see" this entity). ++ * ++ * @return players in tracking range ++ */ ++ @NotNull Set getTrackedPlayers(); + // Paper end + } diff --git a/patches/server/Expose-Tracked-Players.patch b/patches/server/Expose-Tracked-Players.patch index da89eb153d..951defaccf 100644 --- a/patches/server/Expose-Tracked-Players.patch +++ b/patches/server/Expose-Tracked-Players.patch @@ -4,29 +4,26 @@ Date: Fri, 26 Feb 2021 16:24:25 -0600 Subject: [PATCH] Expose Tracked Players -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { + public boolean isTicking() { + return getHandle().isTicking(); } - // Paper end - -+ // Paper start ++ + @Override -+ public Set getTrackedPlayers() { -+ if (entity.tracker == null) { ++ public Set getTrackedPlayers() { ++ if (this.entity.tracker == null) { + return java.util.Collections.emptySet(); + } + -+ Set set = new HashSet<>(entity.tracker.seenBy.size()); -+ for (net.minecraft.server.network.ServerPlayerConnection connection : entity.tracker.seenBy) { ++ Set set = new java.util.HashSet<>(this.entity.tracker.seenBy.size()); ++ for (net.minecraft.server.network.ServerPlayerConnection connection : this.entity.tracker.seenBy) { + set.add(connection.getPlayer().getBukkitEntity().getPlayer()); + } + return set; + } -+ // Paper end -+ - // Spigot start - private final Player.Spigot spigot = new Player.Spigot() - { + // Paper end + }