9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-27 02:49:08 +00:00

Fixed packet sending

This commit is contained in:
Fisher2911
2022-03-29 20:17:28 -04:00
parent 4e3c0b1c6b
commit 7caeec3fd1
10 changed files with 155 additions and 169 deletions

View File

@@ -63,7 +63,6 @@ public class HMCCosmetics extends JavaPlugin {
@Override
public void onLoad() {
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
PacketEvents.getAPI().getSettings().debug(true);
PacketEvents.getAPI().load();
}

View File

@@ -15,14 +15,12 @@ import io.github.fisher2911.hmccosmetics.user.EntityIds;
import io.github.fisher2911.hmccosmetics.user.NPCUser;
import io.github.fisher2911.hmccosmetics.user.User;
import io.github.fisher2911.hmccosmetics.user.Wardrobe;
import io.github.retrooper.packetevents.util.SpigotDataHelper;
import io.github.retrooper.packetevents.util.SpigotReflectionUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import java.sql.SQLException;
import java.util.List;
import java.util.SplittableRandom;
import java.util.UUID;
import java.util.function.Consumer;

View File

@@ -39,7 +39,6 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -173,66 +172,6 @@ public class CosmeticFixListener implements Listener {
}
);
}
//
// int i = 0;
//
// private void updateIfDifferent(final Player player, final EntityEquipment previous) {
// i++;
// this.taskManager.submit(() -> {
// final int copy = i;
// final EntityEquipment equipment = player.getEquipment();
// if (equipment == null) return;
// if (this.equipmentEquals(equipment, previous)) {
// player.sendMessage("Same armor");
// return;
// }
// player.sendMessage("Different armor");
// final List<com.github.retrooper.packetevents.protocol.player.Equipment> equipmentList = new ArrayList<>();
// final Optional<User> optionalUser = this.userManager.get(player.getUniqueId());
// if (optionalUser.isEmpty()) return;
// final User user = optionalUser.get();
// final PlayerArmor playerArmor = user.getPlayerArmor();
// for (final ArmorItem item : playerArmor.getArmorItems()) {
// final EquipmentSlot slot = item.getType().getSlot();
// if (slot == null) continue;
// final ItemStack current = Utils.replaceIfNull(equipment.getItem(slot), new ItemStack(Material.AIR));
// equipmentList.add(
// PacketManager.getEquipment(
// this.userManager.getCosmeticItem(
// item,
// current,
// ArmorItem.Status.APPLIED,
// slot
// ),
// slot
// )
// );
// }
// this.userManager.sendUpdatePacket(
// user,
// equipmentList
// );
// });
// }
private boolean equipmentEquals(final EntityEquipment first, final EntityEquipment second) {
if (first == null && second == null) {
return true;
}
if (first == null) {
return false;
}
if (second == null) {
return false;
}
for (final EquipmentSlot slot : EquipmentSlot.values()) {
final ItemStack i = first.getItem(slot);
final ItemStack i2 = second.getItem(slot);
if (i == null && i2 == null) continue;
if (!Objects.equals(first.getItem(slot), second.getItem(slot))) return false;
}
return true;
}
private void updateOnClick(final Player player, final EquipmentSlot slot, final User user, final ArmorItem.Type type, final ItemStack current) {
taskManager.submit(() -> {
@@ -247,7 +186,7 @@ public class CosmeticFixListener implements Listener {
if (cosmetic != null && cosmetic.getType() != Material.AIR) equipment.setItem(slot, cosmetic);
final List<com.github.retrooper.packetevents.protocol.player.Equipment> items =
getItemList(user, equipment, Set.of(type));
userManager.getItemList(user, equipment, Set.of(type));
for (final Player other : Bukkit.getOnlinePlayers()) {
if (!settings.isInViewDistance(location, other.getLocation())) continue;
userManager.sendUpdatePacket(
@@ -391,33 +330,6 @@ public class CosmeticFixListener implements Listener {
), 1));
}
private List<com.github.retrooper.packetevents.protocol.player.Equipment> getItemList(
final User user,
final Equipment equipment,
final Set<ArmorItem.Type> ignored
) {
final PlayerArmor armor = user.getPlayerArmor();
final List<com.github.retrooper.packetevents.protocol.player.Equipment> items = new ArrayList<>();
for (final ArmorItem.Type type : ArmorItem.Type.values()) {
final EquipmentSlot slot = type.getSlot();
if (slot == null) continue;
if (ignored.contains(type)) {
items.add(PacketManager.getEquipment(equipment.getItem(slot), slot));
continue;
}
final ItemStack wearing = Utils.replaceIfNull(equipment.getItem(slot), new ItemStack(Material.AIR));
final ItemStack itemStack = this.userManager.getCosmeticItem(
armor.getItem(type),
wearing,
ArmorItem.Status.APPLIED,
slot
);
if (itemStack.getType() != Material.AIR) items.add(PacketManager.getEquipment(itemStack, slot));
}
return items;
}
@Nullable
private EquipmentSlot getArmorSlot(final Material material) {
for (final EquipmentSlot slot : EquipmentSlot.values()) {

View File

@@ -36,7 +36,8 @@ public class JoinListener implements Listener {
user -> new TaskChain(this.plugin).chain(
() -> this.userManager.add(user)
).chain(() -> {
this.userManager.resendCosmetics(player);
// this.userManager.resendCosmetics(player);
// this.userManager.updateCosmetics(user);
final WardrobeSettings settings = this.plugin.getSettings().getWardrobeSettings();
if (settings.isAlwaysDisplay() && settings.getWardrobeLocation() != null) {
final Wardrobe wardrobe = user.getWardrobe();

View File

@@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportListener implements Listener {
@@ -23,7 +24,17 @@ public class TeleportListener implements Listener {
final Player player = event.getPlayer();
this.userManager.get(player.getUniqueId()).ifPresent(user -> {
user.despawnAttached();
user.despawnBalloon();
});
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerDeath(final PlayerDeathEvent event) {
final Player player = event.getEntity();
this.userManager.get(player.getUniqueId()).ifPresent(user -> {
user.despawnAttached();
user.despawnBalloon();
});
}

View File

@@ -54,7 +54,7 @@ public class PacketManager {
public static void sendArmorStandMetaContainer(final int armorStandId, final Player... sendTo) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityMetadata(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityMetadata(
armorStandId,
List.of(
new EntityData(0, EntityDataTypes.BYTE, (byte) 0x20),
@@ -96,7 +96,7 @@ public class PacketManager {
final UUID uuid,
final Player... sendTo) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerSpawnLivingEntity(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerSpawnLivingEntity(
entityId,
uuid,
entityType,
@@ -116,7 +116,7 @@ public class PacketManager {
public static void sendInvisibilityPacket(final int entityId, final Player... sendTo) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityMetadata(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityMetadata(
entityId,
List.of(new EntityData(0, EntityDataTypes.BYTE, (byte) 0x20))
));
@@ -139,7 +139,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityTeleport(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityTeleport(
entityId,
new Vector3d(location.getX(), location.getY(), location.getZ()),
location.getYaw(),
@@ -167,7 +167,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityRelativeMove(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityRelativeMove(
entityId,
to.getX() - from.getX(),
to.getY() - from.getY(),
@@ -191,7 +191,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerAttachEntity(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerAttachEntity(
balloonId,
entityId,
true
@@ -216,7 +216,7 @@ public class PacketManager {
final ItemStack itemStack = SpigotDataHelper.toBukkitItemStack(equipment.getItem());
}
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityEquipment(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityEquipment(
entityId,
equipmentList
));
@@ -239,7 +239,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityRotation(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityRotation(
entityId,
location.getYaw(),
location.getPitch(),
@@ -262,7 +262,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityHeadLook(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityHeadLook(
entityId,
location.getYaw()
));
@@ -283,7 +283,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerSetPassengers(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerSetPassengers(
mountId,
new int[]{passengerId}
));
@@ -296,7 +296,7 @@ public class PacketManager {
public static void sendEntityDestroyPacket(final int entityId, final Player... sendTo) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerDestroyEntities(entityId));
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerDestroyEntities(entityId));
}
}
@@ -354,7 +354,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerSpawnPlayer(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerSpawnPlayer(
entityId,
uuid,
new com.github.retrooper.packetevents.protocol.world.Location(
@@ -382,7 +382,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerPlayerInfo(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerPlayerInfo(
WrapperPlayServerPlayerInfo.Action.ADD_PLAYER,
new WrapperPlayServerPlayerInfo.PlayerData(
Component.empty(),
@@ -410,7 +410,7 @@ public class PacketManager {
) {
final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40;
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerEntityMetadata(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerEntityMetadata(
playerId,
List.of(
new EntityData(17, EntityDataTypes.BYTE, mask),
@@ -434,7 +434,7 @@ public class PacketManager {
final Player... sendTo
) {
for (final Player p : sendTo) {
PacketEvents.getAPI().getPlayerManager().sendPacketAsync(p, new WrapperPlayServerPlayerInfo(
PacketEvents.getAPI().getPlayerManager().sendPacketSilentlyAsync(p, new WrapperPlayServerPlayerInfo(
WrapperPlayServerPlayerInfo.Action.REMOVE_PLAYER,
new WrapperPlayServerPlayerInfo.PlayerData(
Component.empty(),

View File

@@ -155,7 +155,6 @@ public abstract class BaseUser<T> {
if (vector != null) actual.add(this.getVelocity().multiply(-1));
this.balloon.setLocation(actual);
this.balloon.setVelocity(actual.clone().subtract(previous.clone()).toVector());
// hookManager.getModelEngineHook().updateModel(this.balloon);
this.balloon.updateModel();
final int balloonId = this.getBalloonId();
PacketManager.sendTeleportPacket(balloonId, actual, false, other);
@@ -163,6 +162,7 @@ public abstract class BaseUser<T> {
}
private void spawnArmorStand(final Player other, final Location location) {
// todo
PacketManager.sendEntitySpawnPacket(location, this.getArmorStandId(), EntityTypes.ARMOR_STAND, other);
}
@@ -179,7 +179,6 @@ public abstract class BaseUser<T> {
final boolean shouldShow = shouldShow(other);
final UUID otherUUID = other.getUniqueId();
final boolean hasBackpack = !this.playerArmor.getItem(ArmorItem.Type.BACKPACK).isEmpty();
other.sendMessage(this.viewingArmorStand.toString());
if (!this.viewingArmorStand.contains(otherUUID)) {
if (!inViewDistance || !shouldShow) {
if (this.viewingBalloon.contains(otherUUID)) {
@@ -219,7 +218,6 @@ public abstract class BaseUser<T> {
type(ItemTypes.AIR).
build()
));
other.sendMessage("Air");
} else {
final com.github.retrooper.packetevents.protocol.item.ItemStack itemStack =
SpigotDataHelper.fromBukkitItemStack(this.playerArmor.getBackpack().getItemStack(ArmorItem.Status.APPLIED));
@@ -227,15 +225,14 @@ public abstract class BaseUser<T> {
EquipmentSlot.HELMET,
itemStack
));
other.sendMessage("Added " + this.playerArmor.getBackpack().getItemStack(ArmorItem.Status.APPLIED).getType());
}
final int armorStandId = this.getArmorStandId();
PacketManager.sendEquipmentPacket(equipment, armorStandId, other);
PacketManager.sendRotationPacket(armorStandId, location, false, other);
PacketManager.sendLookPacket(armorStandId, location, other);
PacketManager.sendRidingPacket(this.getEntityId(), armorStandId, other);
PacketManager.sendArmorStandMetaContainer(armorStandId, other);
other.sendMessage("Spawned equipment: " + hidden + " : " + shouldShow);
if (hidden) return;
this.updateBalloon(other, location, settings.getCosmeticSettings());

View File

@@ -51,7 +51,7 @@ public class User extends BaseUser<UUID> {
public boolean shouldShow(final Player other) {
final Player player = this.getPlayer();
if (player == null) return false;
if (player == null || player.isDead()) return false;
if (player.getUniqueId().equals(other.getUniqueId()) && this.hidden) return false;
final ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack != null && itemStack.getType() == Material.TRIDENT) {

View File

@@ -13,9 +13,11 @@ import io.github.fisher2911.hmccosmetics.message.Placeholder;
import io.github.fisher2911.hmccosmetics.message.Translation;
import io.github.fisher2911.hmccosmetics.packet.PacketManager;
import io.github.fisher2911.hmccosmetics.task.InfiniteTask;
import io.github.fisher2911.hmccosmetics.util.Utils;
import io.github.fisher2911.hmccosmetics.util.builder.ItemBuilder;
import io.github.retrooper.packetevents.util.SpigotDataHelper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
@@ -23,9 +25,11 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -72,8 +76,6 @@ public class UserManager {
}
public void startTeleportTask() {
// throws an error on first load of registry if this isn't here
// WrappedDataWatcher.Registry.get(Byte.class);
this.plugin.getTaskManager().submit(new InfiniteTask(
() -> {
for (final User user : this.userMap.values()) {
@@ -83,59 +85,77 @@ public class UserManager {
));
}
public void resendCosmetics(final Player player) {
for (final User user : this.userMap.values()) {
final Player p = user.getPlayer();
if (p == null) continue;
// public void resendCosmetics(final Player player) {
// for (final User user : this.userMap.values()) {
// final Player p = user.getPlayer();
// if (p == null) continue;
// user.updateOutsideCosmetics(player, p.getLocation(), this.settings);
player.sendMessage("Resending cosmetics");
this.updateCosmetics(user, player);
}
}
// }
// }
public void updateCosmetics(final UUID uuid) {
this.get(uuid).ifPresent(this::updateCosmetics);
}
public void updateCosmetics(final BaseUser<?> user) {
for (final Player player : Bukkit.getOnlinePlayers()) {
this.updateCosmetics(user, player);
}
public void updateCosmetics(final UUID uuid, final Player other) {
this.get(uuid).ifPresent(user -> this.updateCosmetics(user, other));
}
public void updateCosmetics(final BaseUser<?> user, final Player other) {
final Equipment equipment = user.getEquipment();
for (final ArmorItem.Type type : ArmorItem.Type.values()) {
if (type.getSlot() == null) continue;
this.sendUpdatePacket(
user,
other,
equipment,
type
);
}
}
private void sendUpdatePacket(
final BaseUser<?> user,
final Player other,
final Equipment equipment,
final ArmorItem.Type type) {
final PlayerArmor playerArmor = user.getPlayerArmor();
final EquipmentSlot slot = type.getSlot();
final ItemStack itemStack = this.getCosmeticItem(playerArmor.getItem(type), equipment.getItem(type.getSlot()), ArmorItem.Status.APPLIED, slot);
if (itemStack != null && itemStack.equals(equipment.getItem(slot))) return;
final List<com.github.retrooper.packetevents.protocol.player.Equipment> itemList = new ArrayList<>();
itemList.add(new com.github.retrooper.packetevents.protocol.player.Equipment(
PacketManager.fromBukkitSlot(slot), SpigotDataHelper.fromBukkitItemStack(itemStack)
));
PacketManager.sendEquipmentPacket(
itemList,
user.getEntityId(),
other
this.sendUpdatePacket(
user,
other,
this.getItemList(
user,
user.getEquipment(),
Collections.emptySet()
)
);
}
public void updateCosmetics(final BaseUser<?> user) {
this.sendUpdatePacket(
user,
this.getItemList(user, user.getEquipment(), Collections.emptySet())
);
// for (final Player player : Bukkit.getOnlinePlayers()) {
// this.updateCosmetics(user, player);
// }
}
// public void updateCosmetics(final BaseUser<?> user, final Player other) {
// final Equipment equipment = user.getEquipment();
// for (final ArmorItem.Type type : ArmorItem.Type.values()) {
// if (type.getSlot() == null) continue;
// this.sendUpdatePacket(
// user,
// other,
// equipment,
// type
// );
// }
// }
// private void sendUpdatePacket(
// final BaseUser<?> user,
// final Player other,
// final Equipment equipment,
// final ArmorItem.Type type) {
// final PlayerArmor playerArmor = user.getPlayerArmor();
// final EquipmentSlot slot = type.getSlot();
// final ItemStack itemStack = this.getCosmeticItem(playerArmor.getItem(type), equipment.getItem(type.getSlot()), ArmorItem.Status.APPLIED, slot);
// if (itemStack != null && itemStack.equals(equipment.getItem(slot))) return;
// final List<com.github.retrooper.packetevents.protocol.player.Equipment> itemList = new ArrayList<>();
// itemList.add(new com.github.retrooper.packetevents.protocol.player.Equipment(
// PacketManager.fromBukkitSlot(slot), SpigotDataHelper.fromBukkitItemStack(itemStack)
// ));
// PacketManager.sendEquipmentPacket(
// itemList,
// user.getEntityId(),
// other
// );
// }
public ItemStack getCosmeticItem(
final ArmorItem armorItem,
final ItemStack wearing,
@@ -164,6 +184,32 @@ public class UserManager {
return itemStack;
}
public List<com.github.retrooper.packetevents.protocol.player.Equipment> getItemList(
final BaseUser<?> user,
final Equipment equipment,
final Set<ArmorItem.Type> ignored
) {
final PlayerArmor armor = user.getPlayerArmor();
final List<com.github.retrooper.packetevents.protocol.player.Equipment> items = new ArrayList<>();
for (final ArmorItem.Type type : ArmorItem.Type.values()) {
final EquipmentSlot slot = type.getSlot();
if (slot == null) continue;
if (ignored.contains(type)) {
items.add(PacketManager.getEquipment(equipment.getItem(slot), slot));
continue;
}
final ItemStack wearing = Utils.replaceIfNull(equipment.getItem(slot), new ItemStack(Material.AIR));
final ItemStack itemStack = this.getCosmeticItem(
armor.getItem(type),
wearing,
ArmorItem.Status.APPLIED,
slot
);
if (itemStack.getType() != Material.AIR) items.add(PacketManager.getEquipment(itemStack, slot));
}
return items;
}
public void setItem(final BaseUser<?> user, final ArmorItem armorItem) {
ArmorItem previous = user.getPlayerArmor().getItem(armorItem.getType());
@@ -257,30 +303,52 @@ public class UserManager {
final ArmorItem armorItem,
final ItemStack wearing,
final ArmorItem.Type type) {
final EquipmentSlot slot = type.getSlot();
final ItemStack itemStack = this.getCosmeticItem(armorItem, wearing, ArmorItem.Status.APPLIED, slot);
final List<com.github.retrooper.packetevents.protocol.player.Equipment> itemList = new ArrayList<>();
itemList.add(PacketManager.getEquipment(itemStack, slot));
this.sendUpdatePacket(user, itemList);
final EquipmentSlot slot = type.getSlot();
final ItemStack itemStack = this.getCosmeticItem(armorItem, wearing, ArmorItem.Status.APPLIED, slot);
final List<com.github.retrooper.packetevents.protocol.player.Equipment> itemList = new ArrayList<>();
itemList.add(PacketManager.getEquipment(itemStack, slot));
this.sendUpdatePacket(user, itemList);
}
public void sendUpdatePacket(
final User user,
List<com.github.retrooper.packetevents.protocol.player.Equipment> items) {
final Player player = user.getPlayer();
if (player == null) return;
final BaseUser<?> user,
List<com.github.retrooper.packetevents.protocol.player.Equipment> items
) {
// final Player player = user.getPlayer();
// if (player == null) return;
final Location location = user.getLocation();
if (location == null) return;
final int entityId = user.getEntityId();
for (final User otherUser : this.userMap.values()) {
final Player other = otherUser.getPlayer();
if (other == null) continue;
if (!user.shouldShow(other)) continue;
if (!this.settings.getCosmeticSettings().isInViewDistance(player.getLocation(), other.getLocation())) continue;
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) continue;
PacketManager.sendEquipmentPacket(
items,
entityId,
other
);
}
}
public void sendUpdatePacket(
final BaseUser<?> user,
final Player other,
List<com.github.retrooper.packetevents.protocol.player.Equipment> items
) {
// final Player player = user.getPlayer();
// if (player == null) return;
final Location location = user.getLocation();
if (location == null) return;
final int entityId = user.getEntityId();
if (other == null) return;
if (!user.shouldShow(other)) return;
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) return;
PacketManager.sendEquipmentPacket(
items,
entityId,
other
);
}
}