mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Move getTrackedPlayers
up from Player to Entity (#6569)
This commit is contained in:
parent
c23b1138fb
commit
1f7df1832f
2 changed files with 28 additions and 41 deletions
|
@ -4,30 +4,20 @@ Date: Fri, 26 Feb 2021 16:24:25 -0600
|
||||||
Subject: [PATCH] Expose Tracked Players
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||||
package org.bukkit.entity;
|
* Check if entity is inside a ticking chunk
|
||||||
|
*/
|
||||||
import java.net.InetSocketAddress;
|
public boolean isTicking();
|
||||||
+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<Player> getTrackedPlayers();
|
|
||||||
+ // Paper end
|
|
||||||
+
|
+
|
||||||
// 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<Player> getTrackedPlayers();
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
|
|
@ -4,29 +4,26 @@ Date: Fri, 26 Feb 2021 16:24:25 -0600
|
||||||
Subject: [PATCH] Expose Tracked Players
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||||
|
public boolean isTicking() {
|
||||||
|
return getHandle().isTicking();
|
||||||
}
|
}
|
||||||
// Paper end
|
+
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Set<Player> getTrackedPlayers() {
|
+ public Set<org.bukkit.entity.Player> getTrackedPlayers() {
|
||||||
+ if (entity.tracker == null) {
|
+ if (this.entity.tracker == null) {
|
||||||
+ return java.util.Collections.emptySet();
|
+ return java.util.Collections.emptySet();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ Set<Player> set = new HashSet<>(entity.tracker.seenBy.size());
|
+ Set<org.bukkit.entity.Player> set = new java.util.HashSet<>(this.entity.tracker.seenBy.size());
|
||||||
+ for (net.minecraft.server.network.ServerPlayerConnection connection : entity.tracker.seenBy) {
|
+ for (net.minecraft.server.network.ServerPlayerConnection connection : this.entity.tracker.seenBy) {
|
||||||
+ set.add(connection.getPlayer().getBukkitEntity().getPlayer());
|
+ set.add(connection.getPlayer().getBukkitEntity().getPlayer());
|
||||||
+ }
|
+ }
|
||||||
+ return set;
|
+ return set;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
// Paper end
|
||||||
+
|
}
|
||||||
// Spigot start
|
|
||||||
private final Player.Spigot spigot = new Player.Spigot()
|
|
||||||
{
|
|
||||||
|
|
Loading…
Reference in a new issue