From 7c349a588c28768aa1c3663489b37c6bba4bb82a Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 16 Sep 2024 00:45:09 +0300 Subject: [PATCH] Migrate Equipable --- .../api/item/inventory/ArmorEquipable.java | 60 +++++++++++++++++-- .../api/item/inventory/Equipable.java | 36 ++++++++++- 2 files changed, 88 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java b/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java index aa82af57250..964fd3e6d8d 100644 --- a/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java +++ b/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java @@ -46,12 +46,20 @@ public interface ArmorEquipable extends Equipable { */ ItemStack head(); + /** + * @deprecated Use {@link #setHead(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default void setHead(ItemStack head) { + this.setHead((ItemStackLike) head); + } + /** * Sets the head. * * @param head The head */ - void setHead(ItemStack head); + void setHead(ItemStackLike head); /** * Gets the chest. @@ -60,12 +68,20 @@ public interface ArmorEquipable extends Equipable { */ ItemStack chest(); + /** + * @deprecated Use {@link #setChest(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default void setChest(ItemStack chest) { + this.setChest((ItemStackLike) chest); + } + /** * Sets the chest. * * @param chest The chest */ - void setChest(ItemStack chest); + void setChest(ItemStackLike chest); /** * Gets the legs. @@ -74,12 +90,20 @@ public interface ArmorEquipable extends Equipable { */ ItemStack legs(); + /** + * @deprecated Use {@link #setLegs(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default void setLegs(ItemStack legs) { + this.setLegs((ItemStackLike) legs); + } + /** * Sets the legs. * * @param legs The legs */ - void setLegs(ItemStack legs); + void setLegs(ItemStackLike legs); /** * Gets the feet. @@ -88,12 +112,20 @@ public interface ArmorEquipable extends Equipable { */ ItemStack feet(); + /** + * @deprecated Use {@link #setFeet(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default void setFeet(ItemStack feet) { + this.setFeet((ItemStackLike) feet); + } + /** * Sets the feet. * * @param feet The feet */ - void setFeet(ItemStack feet); + void setFeet(ItemStackLike feet); /** * Gets the equipped item in hand. @@ -113,21 +145,37 @@ default ItemStack itemInHand(Supplier handType) { */ ItemStack itemInHand(HandType handType); + /** + * @deprecated Use {@link #setItemInHand(Supplier, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default void setItemInHand(Supplier handType, ItemStack itemInHand) { + this.setItemInHand(handType, (ItemStackLike) itemInHand); + } + /** * Sets the equipped item in hand. * * @param handType The hand type to set to * @param itemInHand The item in hand */ - default void setItemInHand(Supplier handType, ItemStack itemInHand) { + default void setItemInHand(Supplier handType, ItemStackLike itemInHand) { this.setItemInHand(handType.get(), itemInHand); } + /** + * @deprecated Use {@link #setItemInHand(HandType, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default void setItemInHand(HandType handType, ItemStack itemInHand) { + this.setItemInHand(handType, (ItemStackLike) itemInHand); + } + /** * Sets the equipped item in hand. * * @param handType The hand type to set to * @param itemInHand The item in hand */ - void setItemInHand(HandType handType, ItemStack itemInHand); + void setItemInHand(HandType handType, ItemStackLike itemInHand); } diff --git a/src/main/java/org/spongepowered/api/item/inventory/Equipable.java b/src/main/java/org/spongepowered/api/item/inventory/Equipable.java index 686f50a6333..974c5c16d29 100644 --- a/src/main/java/org/spongepowered/api/item/inventory/Equipable.java +++ b/src/main/java/org/spongepowered/api/item/inventory/Equipable.java @@ -56,6 +56,14 @@ default boolean canEquip(final Supplier type) { return this.canEquip(type.get()); } + /** + * @deprecated Use {@link #canEquip(EquipmentType, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default boolean canEquip(EquipmentType type, ItemStack equipment) { + return this.canEquip(type, (ItemStackLike) equipment); + } + /** * Gets whether this {@link Equipable} can equip the supplied equipment in its slot of * the specified type (eg. whether calling {@link #equip} with the specified @@ -65,9 +73,17 @@ default boolean canEquip(final Supplier type) { * @param equipment The equipment to check for * @return true if can equip the supplied equipment */ - boolean canEquip(EquipmentType type, ItemStack equipment); + boolean canEquip(EquipmentType type, ItemStackLike equipment); + /** + * @deprecated Use {@link #canEquip(Supplier, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) default boolean canEquip(final Supplier type, final ItemStack equipment) { + return this.canEquip(type, (ItemStackLike) equipment); + } + + default boolean canEquip(final Supplier type, final ItemStackLike equipment) { return this.canEquip(type.get(), equipment); } @@ -84,6 +100,14 @@ default Optional equipped(final Supplier typ return this.equipped(type.get()); } + /** + * @deprecated Use {@link #equip(EquipmentType, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default boolean equip(EquipmentType type, ItemStack equipment) { + return this.equip(type, (ItemStackLike) equipment); + } + /** * Sets the item currently equipped by the {@link Equipable} in the specified slot, if * the equipable has such a slot. @@ -95,9 +119,17 @@ default Optional equipped(final Supplier typ * specified equipment type or because the item was incompatible with * the specified slot. */ - boolean equip(EquipmentType type, ItemStack equipment); + boolean equip(EquipmentType type, ItemStackLike equipment); + /** + * @deprecated Use {@link #equip(Supplier, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) default boolean equip(final Supplier type, final ItemStack equipment) { + return this.equip(type, (ItemStackLike) equipment); + } + + default boolean equip(final Supplier type, final ItemStackLike equipment) { return this.equip(type.get(), equipment); } }