mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@c1b4899 Fix dupe uuid check on entity add (#6735) PaperMC/Paper@3f043f7 Async catch modifications to critical entity state PaperMC/Paper@bc43f40 Update jline and TCA (#6829) PaperMC/Paper@d9e2817 Update paperweight to 1.1.13 (#6866) PaperMC/Paper@3e310e0 Remove redundant and unneeded repos, reorder repos (#6867) PaperMC/Paper@485d15f Update paperweight to 1.1.14 (#6868) PaperMC/Paper@09d50a9 Added missing mappings (#6810) PaperMC/Paper@0968cdd Move async catches back to where they were (#6869) PaperMC/Paper@6f71b7c Deduplicate strings in ObfHelper (#6841) PaperMC/Paper@ada930b Updated Upstream (Bukkit/CraftBukkit) (#6872) PaperMC/Paper@06d82e0 Cache palette array (#6767) PaperMC/Paper@70fe58d Expose the potential player cause of a lightning (#6782) PaperMC/Paper@c20c9d3 Fix CraftNamespacedKey shenanigans (#6825) PaperMC/Paper@29bb5a9 Add PlayerDeathEvent#getPlayer for clarity (#6859) PaperMC/Paper@124d079 Fix issues with mob conversion (#6831) PaperMC/Paper@22b0238 Add API for checking if a zombie has the option to break doors (#6855) PaperMC/Paper@5af80b0 Add isCollidable methods to various places (#6870) PaperMC/Paper@32ba088 Fix setPatternColor on tropical fish bucket meta (#6877) PaperMC/Paper@87121ce Move `getTrackedPlayers` up from Player to Entity (#6569) PaperMC/Paper@a923e33 Make despawn distance configs per-category, improve per category spawn limit config (#6717) PaperMC/Paper@3f17694 Goat ram API (#6336) PaperMC/Paper@cc2ecbc Add Raw Byte Entity Serialization (#6826) Airplane Changes: TECHNOVE/Airplane@e47949b Ty Penple <3 TECHNOVE/Airplane@86fee6b Update upstream
81 lines
5.3 KiB
Diff
81 lines
5.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Thu, 13 May 2021 16:18:29 -0500
|
|
Subject: [PATCH] Hide hidden players from entity selector
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
index 0fb8f32427843f4bfd90ab88ecb3ab3e4a4fda31..f99f1ba7f912a2fd503e12c446b342a8d04356a0 100644
|
|
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
@@ -184,10 +184,10 @@ public class EntitySelector {
|
|
|
|
if (this.playerName != null) {
|
|
entityplayer = commandlistenerwrapper.getServer().getPlayerList().getPlayerByName(this.playerName);
|
|
- return (List) (entityplayer == null ? Collections.emptyList() : Lists.newArrayList(new ServerPlayer[]{entityplayer}));
|
|
+ return entityplayer == null || !canSee(commandlistenerwrapper, entityplayer) ? Collections.emptyList() : Lists.newArrayList(entityplayer); // Purpur
|
|
} else if (this.entityUUID != null) {
|
|
entityplayer = commandlistenerwrapper.getServer().getPlayerList().getPlayer(this.entityUUID);
|
|
- return (List) (entityplayer == null ? Collections.emptyList() : Lists.newArrayList(new ServerPlayer[]{entityplayer}));
|
|
+ return entityplayer == null || !canSee(commandlistenerwrapper, entityplayer) ? Collections.emptyList() : Lists.newArrayList(entityplayer); // Purpur
|
|
} else {
|
|
Vec3 vec3d = (Vec3) this.position.apply(commandlistenerwrapper.getPosition());
|
|
Predicate<Entity> predicate = this.getPredicate(vec3d);
|
|
@@ -197,7 +197,7 @@ public class EntitySelector {
|
|
ServerPlayer entityplayer1 = (ServerPlayer) commandlistenerwrapper.getEntity();
|
|
|
|
if (predicate.test(entityplayer1)) {
|
|
- return Lists.newArrayList(new ServerPlayer[]{entityplayer1});
|
|
+ return !canSee(commandlistenerwrapper, entityplayer1) ? Collections.emptyList() : Lists.newArrayList(entityplayer1); // Purpur
|
|
}
|
|
}
|
|
|
|
@@ -207,6 +207,7 @@ public class EntitySelector {
|
|
|
|
if (this.isWorldLimited()) {
|
|
object = commandlistenerwrapper.getLevel().getPlayers(predicate);
|
|
+ ((List) object).removeIf(entityplayer3 -> !canSee(commandlistenerwrapper, (ServerPlayer) entityplayer3)); // Purpur
|
|
} else {
|
|
object = Lists.newArrayList();
|
|
Iterator iterator = commandlistenerwrapper.getServer().getPlayerList().getPlayers().iterator();
|
|
@@ -214,7 +215,7 @@ public class EntitySelector {
|
|
while (iterator.hasNext()) {
|
|
ServerPlayer entityplayer2 = (ServerPlayer) iterator.next();
|
|
|
|
- if (predicate.test(entityplayer2)) {
|
|
+ if (predicate.test(entityplayer2) && canSee(commandlistenerwrapper, entityplayer2)) { // Purpur
|
|
((List) object).add(entityplayer2);
|
|
}
|
|
}
|
|
@@ -256,4 +257,10 @@ public class EntitySelector {
|
|
public static Component joinNames(List<? extends Entity> list) {
|
|
return ComponentUtils.formatList(list, Entity::getDisplayName);
|
|
}
|
|
+
|
|
+ // Purpur start
|
|
+ private boolean canSee(CommandSourceStack sender, ServerPlayer target) {
|
|
+ return !net.pl3x.purpur.PurpurConfig.hideHiddenPlayersFromEntitySelector || !(sender.getEntity() instanceof ServerPlayer player) || player.getBukkitEntity().canSee(target.getBukkitEntity());
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index 4d09b8eb877954537abe5ba165a1e35194443341..d9a818087f56237e0f31cf801c421ccc8dd6147e 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -234,6 +234,7 @@ public class PurpurConfig {
|
|
public static String commandTPSBarTextColorLow = "<gradient:#ff5555:#aa0000><text></gradient>";
|
|
public static int commandTPSBarTickInterval = 20;
|
|
public static boolean commandGamemodeRequiresPermission = false;
|
|
+ public static boolean hideHiddenPlayersFromEntitySelector = false;
|
|
private static void commandSettings() {
|
|
commandTPSBarTitle = getString("settings.command.tpsbar.title", commandTPSBarTitle);
|
|
commandTPSBarProgressOverlay = BossBar.Overlay.valueOf(getString("settings.command.tpsbar.overlay", commandTPSBarProgressOverlay.name()));
|
|
@@ -246,6 +247,7 @@ public class PurpurConfig {
|
|
commandTPSBarTextColorLow = getString("settings.command.tpsbar.text-color.low", commandTPSBarTextColorLow);
|
|
commandTPSBarTickInterval = getInt("settings.command.tpsbar.tick-interval", commandTPSBarTickInterval);
|
|
commandGamemodeRequiresPermission = getBoolean("settings.command.gamemode.requires-specific-permission", commandGamemodeRequiresPermission);
|
|
+ hideHiddenPlayersFromEntitySelector = getBoolean("settings.command.hide-hidden-players-from-entity-selector", hideHiddenPlayersFromEntitySelector);
|
|
}
|
|
|
|
public static int barrelRows = 3;
|