From ad516e80d1b1c6bf02f2055794d18a4679b43ae7 Mon Sep 17 00:00:00 2001 From: LoJoSho Date: Wed, 23 Aug 2023 11:15:01 -0500 Subject: [PATCH] feat: improve handling of removing armor cosmetic --- .../com/hibiscusmc/hmccosmetics/user/CosmeticUser.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java index 494a6069..7f03b27f 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java @@ -29,6 +29,7 @@ import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.*; import org.bukkit.persistence.PersistentDataType; @@ -397,7 +398,13 @@ public class CosmeticUser { } public void removeArmor(CosmeticSlot slot) { - PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation())); + EquipmentSlot equipmentSlot = InventoryUtils.getEquipmentSlot(slot); + if (equipmentSlot == null) return; + if (getPlayer() != null) { + NMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation())); + } else { + PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation())); + } } /**