filter out null equipment (fixes #25)

This commit is contained in:
Pyrbu 2023-04-24 14:18:49 +01:00
parent 9b71d532f6
commit cf34ddc32e

@ -244,7 +244,7 @@ public class NPC {
PacketEvents.getAPI().getPlayerManager().sendPacket(player, new WrapperPlayServerSpawnPlayer(entityID, PacketEvents.getAPI().getPlayerManager().sendPacket(player, new WrapperPlayServerSpawnPlayer(entityID,
this.gameProfile.getId(), SpigotConversionUtil.fromBukkitLocation(location.toBukkitLocation()))); this.gameProfile.getId(), SpigotConversionUtil.fromBukkitLocation(location.toBukkitLocation())));
PacketEvents.getAPI().getPlayerManager().sendPacket(player, new WrapperPlayServerEntityMetadata(entityID, PacketEvents.getAPI().getPlayerManager().sendPacket(player, new WrapperPlayServerEntityMetadata(entityID,
List.of(new EntityData(17, EntityDataTypes.BYTE, Byte.MAX_VALUE)))); List.of(new EntityData(17, EntityDataTypes.BYTE, Byte.MAX_VALUE)))); // 17 only works on ~1.19, this will need to be fixed in the entity rewrite
PacketEvents.getAPI().getPlayerManager().sendPacket(player, new WrapperPlayServerEntityHeadLook(entityID, location.getYaw())); PacketEvents.getAPI().getPlayerManager().sendPacket(player, new WrapperPlayServerEntityHeadLook(entityID, location.getYaw()));
}); });
} }
@ -337,6 +337,8 @@ public class NPC {
public void sendEquipPackets(ZUser zUser) { public void sendEquipPackets(ZUser zUser) {
if (this.npcPojo.getNpcEquip().isEmpty()) return; if (this.npcPojo.getNpcEquip().isEmpty()) return;
List<Equipment> equipment = npcPojo.getNpcEquip().entrySet().stream() List<Equipment> equipment = npcPojo.getNpcEquip().entrySet().stream()
.filter(entry -> Objects.nonNull(entry.getKey()))
.filter(entry -> Objects.nonNull(entry.getValue()))
.map(entry -> new Equipment(entry.getKey(), SpigotConversionUtil.fromBukkitItemStack(entry.getValue()))) .map(entry -> new Equipment(entry.getKey(), SpigotConversionUtil.fromBukkitItemStack(entry.getValue())))
.toList(); .toList();