Fix equipment slot and group API
Adds the following: - Add missing 'body' slot group - Expose LivingEntity#canUseSlot Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
This commit is contained in:
@@ -15,6 +15,8 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param slot the slot to put the ItemStack
|
||||
* @param item the ItemStack to set
|
||||
* @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
* @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot)
|
||||
*/
|
||||
public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item);
|
||||
|
||||
@@ -23,7 +25,9 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param slot the slot to put the ItemStack
|
||||
* @param item the ItemStack to set
|
||||
* @param silent whether or not the equip sound should be silenced
|
||||
* @param silent whether the equip sound should be silenced
|
||||
* @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
* @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot)
|
||||
*/
|
||||
public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item, boolean silent);
|
||||
|
||||
@@ -32,6 +36,8 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param slot the slot to get the ItemStack
|
||||
* @return the ItemStack in the given slot
|
||||
* @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
* @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot)
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItem(@NotNull EquipmentSlot slot);
|
||||
|
||||
@@ -15,7 +15,7 @@ public enum EquipmentSlot {
|
||||
/**
|
||||
* Only for certain entities such as horses and wolves.
|
||||
*/
|
||||
BODY(() -> EquipmentSlotGroup.ARMOR);
|
||||
BODY(() -> EquipmentSlotGroup.BODY); // Paper - add missing slot type
|
||||
|
||||
private final Supplier<EquipmentSlotGroup> group; // Supplier because of class loading order, since EquipmentSlot and EquipmentSlotGroup reference each other on class init
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ public final class EquipmentSlotGroup implements Predicate<EquipmentSlot> {
|
||||
public static final EquipmentSlotGroup LEGS = get("legs", EquipmentSlot.LEGS);
|
||||
public static final EquipmentSlotGroup CHEST = get("chest", EquipmentSlot.CHEST);
|
||||
public static final EquipmentSlotGroup HEAD = get("head", EquipmentSlot.HEAD);
|
||||
public static final EquipmentSlotGroup ARMOR = get("armor", (test) -> test == EquipmentSlot.FEET || test == EquipmentSlot.LEGS || test == EquipmentSlot.CHEST || test == EquipmentSlot.HEAD, EquipmentSlot.CHEST);
|
||||
public static final EquipmentSlotGroup ARMOR = get("armor", (test) -> test == EquipmentSlot.FEET || test == EquipmentSlot.LEGS || test == EquipmentSlot.CHEST || test == EquipmentSlot.HEAD || test == EquipmentSlot.BODY, EquipmentSlot.CHEST); // Paper - add missing slot type
|
||||
public static final EquipmentSlotGroup BODY = get("body", EquipmentSlot.BODY); // Paper - add missing slot group
|
||||
//
|
||||
private final String key;
|
||||
private final Predicate<EquipmentSlot> predicate;
|
||||
|
||||
@@ -95,6 +95,8 @@ public interface PlayerInventory extends Inventory {
|
||||
* @param slot the slot to put the ItemStack
|
||||
* @param item the ItemStack to set
|
||||
*
|
||||
* @throws IllegalArgumentException if the slot is invalid for the player
|
||||
* @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot)
|
||||
* @see #setItem(int, ItemStack)
|
||||
*/
|
||||
public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item);
|
||||
@@ -105,6 +107,8 @@ public interface PlayerInventory extends Inventory {
|
||||
* @param slot the slot to get the ItemStack
|
||||
*
|
||||
* @return the ItemStack in the given slot
|
||||
* @throws IllegalArgumentException if the slot is invalid for the player
|
||||
* @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot)
|
||||
*/
|
||||
@NotNull // Paper
|
||||
public ItemStack getItem(@NotNull EquipmentSlot slot);
|
||||
|
||||
Reference in New Issue
Block a user