mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2026-01-03 14:22:14 +00:00
fix: 1.20.6 shooting error illegal arguments on equipment slot update
This commit is contained in:
@@ -11,6 +11,9 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class HMCCInventoryUtils {
|
||||
|
||||
/**
|
||||
@@ -189,4 +192,12 @@ public class HMCCInventoryUtils {
|
||||
public static NamespacedKey getCosmeticKey() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns all the slots a player can have on them. In 1.20.6+, the enum includes BODY, which is not a valid slot for a player.
|
||||
* @return A list of all the slots a player can have on them
|
||||
*/
|
||||
public static List<EquipmentSlot> getPlayerArmorSlots() {
|
||||
return Arrays.asList(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET, EquipmentSlot.OFF_HAND, EquipmentSlot.HAND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
List<Player> sendTo
|
||||
) {
|
||||
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
for (EquipmentSlot slot : HMCCInventoryUtils.getPlayerArmorSlots()) {
|
||||
ItemStack item = player.getInventory().getItem(slot);
|
||||
if (empty) item = new ItemStack(Material.AIR);
|
||||
items.put(slot, item);
|
||||
|
||||
Reference in New Issue
Block a user