Cleanup, change packet tracker removal method (needs checking for geyser debug message)

This commit is contained in:
fullwall 2024-02-29 13:10:44 +08:00
parent 3869e310a2
commit 3a5b13c170
34 changed files with 123 additions and 284 deletions

View File

@ -493,7 +493,7 @@ public class EventListen implements Listener {
boolean resetYaw = event.getNPC().data().get(NPC.Metadata.RESET_YAW_ON_SPAWN,
Setting.RESET_YAW_ON_SPAWN.asBoolean());
boolean sendTabRemove = NMS.sendTabListAdd(event.getPlayer(), (Player) tracker);
if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean()) {
if (!sendTabRemove || !event.getNPC().shouldRemoveFromTabList()) {
if (resetYaw) {
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
() -> PlayerAnimation.ARM_SWING.play((Player) tracker, event.getPlayer()));

View File

@ -197,7 +197,6 @@ public class Settings {
MAX_NPC_SKIN_RETRIES(
"How many times to try load NPC skins (due to Minecraft rate-limiting skin requests, should rarely be less than 5",
"npc.skins.max-retries", -1),
MAX_PACKET_ENTRIES("npc.limits.max-packet-entries", 15),
MAX_TEXT_RANGE("The maximum range in blocks for chatting", "npc.chat.options.max-text-range", 500),
MAXIMUM_ASTAR_ITERATIONS("The maximum number of blocks to check when pathfinding",
"npc.pathfinding.maximum-new-pathfinder-iterations", "npc.pathfinding.new-finder.maximum-iterations",

View File

@ -55,6 +55,7 @@ import net.citizensnpcs.trait.SitTrait;
import net.citizensnpcs.trait.SkinLayers;
import net.citizensnpcs.trait.SneakTrait;
import net.citizensnpcs.util.ChunkCoord;
import net.citizensnpcs.util.EntityPacketTracker;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.PlayerAnimation;
@ -275,11 +276,22 @@ public class CitizensNPC extends AbstractNPC {
}
}
@Override
protected void setNameInternal(String name) {
super.setNameInternal(name);
updateCustomName();
}
@Override
public void setSneaking(boolean sneaking) {
getOrAddTrait(SneakTrait.class).setSneaking(sneaking);
}
@Override
public boolean shouldRemoveFromTabList() {
return data().get(NPC.Metadata.REMOVE_FROM_TABLIST, Setting.DISABLE_TABLIST.asBoolean());
}
@Override
public boolean spawn(Location at) {
return spawn(at, SpawnReason.PLUGIN);
@ -308,16 +320,10 @@ public class CitizensNPC extends AbstractNPC {
getEntity().setMetadata("NPC-ID", new FixedMetadataValue(CitizensAPI.getPlugin(), getId()));
// Spawning the entity will create an entity tracker that is not controlled by Citizens. This is fixed later in
// spawning; to avoid sending packets twice, try to hide the entity initially
if (SUPPORT_VISIBLE_BY_DEFAULT) {
try {
getEntity().setVisibleByDefault(false);
} catch (NoSuchMethodError err) {
SUPPORT_VISIBLE_BY_DEFAULT = false;
}
}
if (!SUPPORT_VISIBLE_BY_DEFAULT && getEntity().getType() == EntityType.PLAYER) {
EntityPacketTracker tracker = NMS.getPacketTracker(getEntity());
if (tracker != null) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
player.hidePlayer((Player) getEntity());
tracker.unlink(player);
}
}
if (getEntity() instanceof SkinnableEntity && !hasTrait(SkinLayers.class)) {
@ -389,15 +395,8 @@ public class CitizensNPC extends AbstractNPC {
ex.printStackTrace();
}
}
// Replace the entity tracker and attempt to show the entity
// Replace the entity tracker
NMS.replaceTracker(getEntity());
if (SUPPORT_VISIBLE_BY_DEFAULT) {
getEntity().setVisibleByDefault(true);
} else if (getEntity().getType() == EntityType.PLAYER) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
player.showPlayer((Player) getEntity());
}
}
EntityType type = getEntity().getType();
if (type.isAlive()) {
LivingEntity entity = (LivingEntity) getEntity();
@ -565,12 +564,13 @@ public class CitizensNPC extends AbstractNPC {
}
}
@Override
public void updateCustomName() {
private void updateCustomName() {
if (getEntity() == null)
return;
if (coloredNameComponentCache != null) {
NMS.setCustomName(getEntity(), coloredNameComponentCache, coloredNameStringCache);
} else {
super.updateCustomName();
getEntity().setCustomName(getFullName());
}
}
@ -633,5 +633,4 @@ public class CitizensNPC extends AbstractNPC {
private static boolean SUPPORT_PICKUP_ITEMS = true;
private static boolean SUPPORT_SILENT = true;
private static boolean SUPPORT_USE_ITEM = true;
private static boolean SUPPORT_VISIBLE_BY_DEFAULT = true;
}

View File

@ -108,9 +108,9 @@ public class SkinPacketTracker {
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
for (Player player : players) {
if (player.hasMetadata("NPC")) {
if (player.hasMetadata("NPC"))
continue;
}
// send packet now and later to ensure removal from player list
NMS.sendTabListRemove(player, entity.getBukkitEntity());
TAB_LIST_REMOVER.sendPacket(player, entity);
@ -136,7 +136,7 @@ public class SkinPacketTracker {
private void scheduleRemovePacket(PlayerEntry entry) {
if (isRemoved || !CitizensAPI.hasImplementation() || !CitizensAPI.getPlugin().isEnabled()
|| !shouldRemoveFromTabList())
|| !entity.getNPC().shouldRemoveFromTabList())
return;
entry.removeTask = Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(),
@ -148,10 +148,6 @@ public class SkinPacketTracker {
scheduleRemovePacket(entry);
}
private boolean shouldRemoveFromTabList() {
return entity.getNPC().data().get("removefromtablist", Setting.DISABLE_TABLIST.asBoolean());
}
/**
* Send skin related packets to all nearby players within the specified block radius.
*

View File

@ -14,7 +14,6 @@ import org.bukkit.entity.Player;
import com.google.common.base.Preconditions;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.util.NMS;
@ -113,38 +112,33 @@ public class TabListRemover {
private class Sender implements Runnable {
@Override
public void run() {
int maxPacketEntries = Setting.MAX_PACKET_ENTRIES.asInt();
int maxPacketEntries = 15;
Iterator<Map.Entry<UUID, PlayerEntry>> entryIterator = pending.entrySet().iterator();
while (entryIterator.hasNext()) {
Map.Entry<UUID, PlayerEntry> mapEntry = entryIterator.next();
PlayerEntry entry = mapEntry.getValue();
if (!entry.player.isOnline()) {
entryIterator.remove();
continue;
}
int listSize = Math.min(maxPacketEntries, entry.toRemove.size());
boolean sendAll = listSize == entry.toRemove.size();
List<SkinnableEntity> skinnableList = new ArrayList<>(listSize);
List<Player> skinnableList = new ArrayList<>(listSize);
int i = 0;
Iterator<SkinnableEntity> skinIterator = entry.toRemove.iterator();
while (skinIterator.hasNext()) {
if (i >= maxPacketEntries) {
for (Iterator<SkinnableEntity> skinIterator = entry.toRemove.iterator(); skinIterator.hasNext();) {
if (i >= maxPacketEntries)
break;
}
SkinnableEntity skinnable = skinIterator.next();
skinnableList.add(skinnable);
SkinnableEntity next = skinIterator.next();
skinnableList.add(next.getBukkitEntity());
next.getSkinTracker().notifyRemovePacketSent(entry.player.getUniqueId());
skinIterator.remove();
i++;
}
if (entry.player.isOnline()) {
NMS.sendTabListRemove(entry.player, skinnableList);
}
// notify skin trackers that a remove packet has been sent to a player
for (SkinnableEntity entity : skinnableList) {
entity.getSkinTracker().notifyRemovePacketSent(entry.player.getUniqueId());
}
if (sendAll) {
NMS.sendTabListRemove(entry.player, skinnableList);
if (entry.toRemove.isEmpty()) {
entryIterator.remove();
}
}

View File

@ -37,6 +37,7 @@ import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.ProfileLookupCallback;
@ -58,7 +59,6 @@ import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.MirrorTrait;
import net.citizensnpcs.trait.PacketNPC;
import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose;
@ -779,12 +779,12 @@ public class NMS {
return BRIDGE.sendTabListAdd(recipient, listPlayer);
}
public static void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
BRIDGE.sendTabListRemove(recipient, skinnableNPCs);
public static void sendTabListRemove(Player recipient, Collection<Player> players) {
BRIDGE.sendTabListRemove(recipient, players);
}
public static void sendTabListRemove(Player recipient, Player listPlayer) {
BRIDGE.sendTabListRemove(recipient, listPlayer);
sendTabListRemove(recipient, ImmutableList.of(listPlayer));
}
public static void sendTeamPacket(Player recipient, Team team, int mode) {

View File

@ -40,7 +40,6 @@ import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.api.util.EntityDim;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.MirrorTrait;
import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose;
import net.citizensnpcs.trait.versioned.SnifferTrait.SnifferState;
@ -174,9 +173,7 @@ public interface NMSBridge {
public boolean sendTabListAdd(Player recipient, Player listPlayer);
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs);
public void sendTabListRemove(Player recipient, Player listPlayer);
public void sendTabListRemove(Player recipient, Collection<Player> players);
public void sendTeamPacket(Player recipient, Team team, int mode);

View File

@ -148,14 +148,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
if (dead)
return;
super.die(damagesource);
Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(), () -> world.removeEntity(EntityHumanNPC.this), 15); // give
// enough
// time
// for
// death
// and
// smoke
// animation
Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(), () -> world.removeEntity(EntityHumanNPC.this), 15);
// give enough time for death and smoke animation
}
@Override

View File

@ -170,7 +170,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
@ -1129,28 +1128,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -223,7 +223,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
@Override
public IChatBaseComponent getPlayerListName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
}

View File

@ -185,7 +185,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
@ -1182,28 +1181,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -232,7 +232,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
@Override
public IChatBaseComponent getPlayerListName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
}

View File

@ -187,7 +187,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
@ -1189,28 +1188,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -217,7 +217,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
@Override
public IChatBaseComponent getPlayerListName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
}

View File

@ -197,7 +197,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
@ -1226,28 +1225,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -207,7 +207,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
@Override
public IChatBaseComponent getPlayerListName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
}

View File

@ -201,7 +201,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.CatTrait;
@ -1244,28 +1243,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -199,7 +199,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
@Override
public IChatBaseComponent getPlayerListName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
}

View File

@ -202,7 +202,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BeeTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
@ -1261,28 +1260,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -18,7 +18,6 @@ import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
@ -180,7 +179,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
@Override
public IChatBaseComponent getPlayerListName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
}

View File

@ -209,7 +209,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.BeeTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
@ -1297,28 +1296,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -15,7 +15,6 @@ import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
@ -213,7 +212,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
@Override
public Component getTabListDisplayName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new TextComponent("");
return super.getTabListDisplayName();
}

View File

@ -210,7 +210,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.AxolotlTrait;
import net.citizensnpcs.trait.versioned.BeeTrait;
@ -658,7 +657,7 @@ public class NMSImpl implements NMSBridge {
entry.broadcastRemoved();
}
};
}
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
@ -1290,28 +1289,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
ServerPlayer[] entities = new ServerPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (ServerPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (ServerPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
ServerPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -31,7 +31,7 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
map.super(entity, i, j, flag);
this.tracker = entity;
try {
Set<ServerPlayerConnection> set = (Set<ServerPlayerConnection>) TRACKING_SET_GETTER.invoke(this);
Set<ServerPlayerConnection> set = seenBy;
TRACKING_SET_SETTER.invoke(this, new ForwardingSet<ServerPlayerConnection>() {
@Override
public boolean add(ServerPlayerConnection conn) {
@ -153,6 +153,5 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
private static final MethodHandle TRACKER_ENTRY = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class);
private static final MethodHandle TRACKING_RANGE = NMS.getFirstGetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_RANGE_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_SET_GETTER = NMS.getFirstGetter(TrackedEntity.class, Set.class);
private static final MethodHandle TRACKING_SET_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, Set.class);
}

View File

@ -16,7 +16,6 @@ import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
@ -214,7 +213,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
@Override
public Component getTabListDisplayName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return new TextComponent("");
return super.getTabListDisplayName();
}

View File

@ -211,7 +211,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.AxolotlTrait;
import net.citizensnpcs.trait.versioned.BeeTrait;
@ -1299,28 +1298,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
ServerPlayer[] entities = new ServerPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (ServerPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (ServerPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
ServerPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);

View File

@ -31,7 +31,7 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
map.super(entity, i, j, flag);
this.tracker = entity;
try {
Set<ServerPlayerConnection> set = (Set<ServerPlayerConnection>) TRACKING_SET_GETTER.invoke(this);
Set<ServerPlayerConnection> set = seenBy;
TRACKING_SET_SETTER.invoke(this, new ForwardingSet<ServerPlayerConnection>() {
@Override
public boolean add(ServerPlayerConnection conn) {
@ -153,6 +153,5 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
private static final MethodHandle TRACKER_ENTRY = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class);
private static final MethodHandle TRACKING_RANGE = NMS.getFirstGetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_RANGE_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_SET_GETTER = NMS.getFirstGetter(TrackedEntity.class, Set.class);
private static final MethodHandle TRACKING_SET_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, Set.class);
}

View File

@ -15,7 +15,6 @@ import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
@ -208,7 +207,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
@Override
public Component getTabListDisplayName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return MutableComponent.create(new LiteralContents(""));
return super.getTabListDisplayName();
}

View File

@ -31,7 +31,7 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
map.super(entity, i, j, flag);
this.tracker = entity;
try {
Set<ServerPlayerConnection> set = (Set<ServerPlayerConnection>) TRACKING_SET_GETTER.invoke(this);
Set<ServerPlayerConnection> set = seenBy;
TRACKING_SET_SETTER.invoke(this, new ForwardingSet<ServerPlayerConnection>() {
@Override
public boolean add(ServerPlayerConnection conn) {
@ -153,6 +153,5 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
private static final MethodHandle TRACKER_ENTRY = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class);
private static final MethodHandle TRACKING_RANGE = NMS.getFirstGetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_RANGE_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_SET_GETTER = NMS.getFirstGetter(TrackedEntity.class, Set.class);
private static final MethodHandle TRACKING_SET_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, Set.class);
}

View File

@ -227,7 +227,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.MirrorTrait;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.AllayTrait;
@ -1204,19 +1203,19 @@ public class NMSImpl implements NMSBridge {
GameProfile playerProfile = null;
for (int i = 0; i < list.size(); i++) {
ClientboundPlayerInfoUpdatePacket.Entry npcInfo = list.get(i);
if (npcInfo == null) {
if (npcInfo == null)
continue;
}
MirrorTrait trait = mirrorTraits.apply(npcInfo.profileId());
if (trait == null || !trait.isMirroring(player)) {
if (trait == null || !trait.isMirroring(player))
continue;
}
if (Setting.DISABLE_TABLIST.asBoolean() != npcInfo.listed()) {
boolean disableTablist = trait.getNPC().shouldRemoveFromTabList();
if (disableTablist != npcInfo.listed()) {
list.set(i,
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(),
!Setting.DISABLE_TABLIST.asBoolean(), npcInfo.latency(), npcInfo.gameMode(),
!Setting.DISABLE_TABLIST.asBoolean() ? npcInfo.displayName() : Component.empty(),
npcInfo.chatSession()));
!disableTablist, npcInfo.latency(), npcInfo.gameMode(),
!disableTablist ? npcInfo.displayName() : Component.empty(), npcInfo.chatSession()));
changed = true;
}
if (playerProfile == null) {
@ -1224,16 +1223,16 @@ public class NMSImpl implements NMSBridge {
}
if (trait.mirrorName()) {
list.set(i,
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile,
!Setting.DISABLE_TABLIST.asBoolean(), npcInfo.latency(), npcInfo.gameMode(),
Component.literal(playerProfile.getName()), npcInfo.chatSession()));
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile, !disableTablist,
npcInfo.latency(), npcInfo.gameMode(), Component.literal(playerProfile.getName()),
npcInfo.chatSession()));
changed = true;
continue;
}
Collection<Property> textures = playerProfile.getProperties().get("textures");
if (textures == null || textures.size() == 0) {
if (textures == null || textures.size() == 0)
continue;
}
npcInfo.profile().getProperties().clear();
for (String key : playerProfile.getProperties().keySet()) {
npcInfo.profile().getProperties().putAll(key, playerProfile.getProperties().get(key));
@ -1392,9 +1391,7 @@ public class NMSImpl implements NMSBridge {
ServerPlayer from = ((CraftPlayer) listPlayer).getHandle();
ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket
.createPlayerInitializing(Arrays.asList(from));
boolean list = from instanceof NPCHolder
? !((NPCHolder) from).getNPC().data().get("removefromtablist", Setting.DISABLE_TABLIST.asBoolean())
: false;
boolean list = from instanceof NPCHolder ? !((NPCHolder) from).getNPC().shouldRemoveFromTabList() : true;
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(from.getUUID(),
from.getGameProfile(), list, from.latency, from.gameMode.getGameModeForPlayer(),
list ? from.getTabListDisplayName() : Component.empty(),
@ -1409,24 +1406,11 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
ServerPlayer[] entities = new ServerPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (ServerPlayer) skinnable;
i++;
}
sendPacket(recipient, new ClientboundPlayerInfoRemovePacket(
skinnableNPCs.stream().map(e -> ((ServerPlayer) e).getUUID()).collect(Collectors.toList())));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
sendPacket(recipient, new ClientboundPlayerInfoRemovePacket(Arrays.asList(getHandle(listPlayer).getUUID())));
skinnableNPCs.stream().map(e -> e.getUniqueId()).collect(Collectors.toList())));
}
@Override

View File

@ -14,7 +14,6 @@ import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
@ -211,7 +210,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
@Override
public Component getTabListDisplayName() {
if (Setting.DISABLE_TABLIST.asBoolean())
if (npc != null && npc.shouldRemoveFromTabList())
return MutableComponent.create(new LiteralContents(""));
return super.getTabListDisplayName();
}

View File

@ -31,7 +31,7 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
map.super(entity, i, j, flag);
this.tracker = entity;
try {
Set<ServerPlayerConnection> set = (Set<ServerPlayerConnection>) TRACKING_SET_GETTER.invoke(this);
Set<ServerPlayerConnection> set = seenBy;
TRACKING_SET_SETTER.invoke(this, new ForwardingSet<ServerPlayerConnection>() {
@Override
public boolean add(ServerPlayerConnection conn) {
@ -153,7 +153,6 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
private static final MethodHandle TRACKER_ENTRY = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class);
private static final MethodHandle TRACKING_RANGE = NMS.getFirstGetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_RANGE_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, int.class);
private static final MethodHandle TRACKING_SET_GETTER = NMS.getFirstGetter(TrackedEntity.class, Set.class);
private static final MethodHandle TRACKING_SET_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, Set.class);
private static final MethodHandle UPDATE_INTERVAL = NMS.getGetter(ServerEntity.class, "h");
}

View File

@ -219,7 +219,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.MirrorTrait;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.trait.versioned.AllayTrait;
@ -1175,19 +1174,20 @@ public class NMSImpl implements NMSBridge {
GameProfile playerProfile = null;
for (int i = 0; i < list.size(); i++) {
ClientboundPlayerInfoUpdatePacket.Entry npcInfo = list.get(i);
if (npcInfo == null) {
if (npcInfo == null)
continue;
}
MirrorTrait trait = mirrorTraits.apply(npcInfo.profileId());
if (trait == null || !trait.isMirroring(player)) {
if (trait == null || !trait.isMirroring(player))
continue;
}
if (Setting.DISABLE_TABLIST.asBoolean() != npcInfo.listed()) {
boolean disableTablist = trait.getNPC().shouldRemoveFromTabList();
if (disableTablist != npcInfo.listed()) {
list.set(i,
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(),
!Setting.DISABLE_TABLIST.asBoolean(), npcInfo.latency(), npcInfo.gameMode(),
!Setting.DISABLE_TABLIST.asBoolean() ? npcInfo.displayName() : Component.empty(),
npcInfo.chatSession()));
!disableTablist, npcInfo.latency(), npcInfo.gameMode(),
!disableTablist ? npcInfo.displayName() : Component.empty(), npcInfo.chatSession()));
changed = true;
}
if (playerProfile == null) {
@ -1195,16 +1195,16 @@ public class NMSImpl implements NMSBridge {
}
if (trait.mirrorName()) {
list.set(i,
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile,
!Setting.DISABLE_TABLIST.asBoolean(), npcInfo.latency(), npcInfo.gameMode(),
Component.literal(playerProfile.getName()), npcInfo.chatSession()));
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile, !disableTablist,
npcInfo.latency(), npcInfo.gameMode(), Component.literal(playerProfile.getName()),
npcInfo.chatSession()));
changed = true;
continue;
}
Collection<Property> textures = playerProfile.getProperties().get("textures");
if (textures == null || textures.size() == 0) {
if (textures == null || textures.size() == 0)
continue;
}
npcInfo.profile().getProperties().clear();
for (String key : playerProfile.getProperties().keySet()) {
npcInfo.profile().getProperties().putAll(key, playerProfile.getProperties().get(key));
@ -1363,9 +1363,7 @@ public class NMSImpl implements NMSBridge {
ServerPlayer from = ((CraftPlayer) listPlayer).getHandle();
ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket
.createPlayerInitializing(Arrays.asList(from));
boolean list = from instanceof NPCHolder
? !((NPCHolder) from).getNPC().data().get("removefromtablist", Setting.DISABLE_TABLIST.asBoolean())
: false;
boolean list = from instanceof NPCHolder ? !((NPCHolder) from).getNPC().shouldRemoveFromTabList() : true;
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(from.getUUID(),
from.getGameProfile(), list, from.connection.latency(), from.gameMode.getGameModeForPlayer(),
list ? from.getTabListDisplayName() : Component.empty(),
@ -1380,24 +1378,11 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> players) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
ServerPlayer[] entities = new ServerPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (ServerPlayer) skinnable;
i++;
}
Preconditions.checkNotNull(players);
sendPacket(recipient, new ClientboundPlayerInfoRemovePacket(
skinnableNPCs.stream().map(e -> ((ServerPlayer) e).getUUID()).collect(Collectors.toList())));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
sendPacket(recipient, new ClientboundPlayerInfoRemovePacket(Arrays.asList(getHandle(listPlayer).getUUID())));
players.stream().map(e -> e.getUniqueId()).collect(Collectors.toList())));
}
@Override

View File

@ -159,7 +159,6 @@ import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.RotationTrait;
import net.citizensnpcs.util.EmptyChannel;
import net.citizensnpcs.util.EntityPacketTracker;
@ -1047,28 +1046,19 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
public void sendTabListRemove(Player recipient, Collection<Player> skinnableNPCs) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(skinnableNPCs);
EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
int i = 0;
for (SkinnableEntity skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) skinnable;
for (Player skinnable : skinnableNPCs) {
entities[i] = (EntityPlayer) getHandle(skinnable);
i++;
}
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);
EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);