Skip to content

Commit 3ca7e5a

Browse files
committed
Migrate Equipable
1 parent ffd4e09 commit 3ca7e5a

File tree

3 files changed

+107
-10
lines changed

3 files changed

+107
-10
lines changed

src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,20 @@ public interface ArmorEquipable extends Equipable {
4646
*/
4747
ItemStack head();
4848

49+
/**
50+
* @deprecated Use {@link #setHead(ItemStackLike)} instead.
51+
*/
52+
@Deprecated(forRemoval = true)
53+
default void setHead(ItemStack head) {
54+
this.setHead((ItemStackLike) head);
55+
}
56+
4957
/**
5058
* Sets the head.
5159
*
5260
* @param head The head
5361
*/
54-
void setHead(ItemStack head);
62+
void setHead(ItemStackLike head);
5563

5664
/**
5765
* Gets the chest.
@@ -60,12 +68,20 @@ public interface ArmorEquipable extends Equipable {
6068
*/
6169
ItemStack chest();
6270

71+
/**
72+
* @deprecated Use {@link #setChest(ItemStackLike)} instead.
73+
*/
74+
@Deprecated(forRemoval = true)
75+
default void setChest(ItemStack chest) {
76+
this.setChest((ItemStackLike) chest);
77+
}
78+
6379
/**
6480
* Sets the chest.
6581
*
6682
* @param chest The chest
6783
*/
68-
void setChest(ItemStack chest);
84+
void setChest(ItemStackLike chest);
6985

7086
/**
7187
* Gets the legs.
@@ -74,12 +90,20 @@ public interface ArmorEquipable extends Equipable {
7490
*/
7591
ItemStack legs();
7692

93+
/**
94+
* @deprecated Use {@link #setLegs(ItemStackLike)} instead.
95+
*/
96+
@Deprecated(forRemoval = true)
97+
default void setLegs(ItemStack legs) {
98+
this.setLegs((ItemStackLike) legs);
99+
}
100+
77101
/**
78102
* Sets the legs.
79103
*
80104
* @param legs The legs
81105
*/
82-
void setLegs(ItemStack legs);
106+
void setLegs(ItemStackLike legs);
83107

84108
/**
85109
* Gets the feet.
@@ -88,12 +112,20 @@ public interface ArmorEquipable extends Equipable {
88112
*/
89113
ItemStack feet();
90114

115+
/**
116+
* @deprecated Use {@link #setFeet(ItemStackLike)} instead.
117+
*/
118+
@Deprecated(forRemoval = true)
119+
default void setFeet(ItemStack feet) {
120+
this.setFeet((ItemStackLike) feet);
121+
}
122+
91123
/**
92124
* Sets the feet.
93125
*
94126
* @param feet The feet
95127
*/
96-
void setFeet(ItemStack feet);
128+
void setFeet(ItemStackLike feet);
97129

98130
/**
99131
* Gets the equipped item in hand.
@@ -113,21 +145,37 @@ default ItemStack itemInHand(Supplier<? extends HandType> handType) {
113145
*/
114146
ItemStack itemInHand(HandType handType);
115147

148+
/**
149+
* @deprecated Use {@link #setItemInHand(Supplier, ItemStackLike)} instead.
150+
*/
151+
@Deprecated(forRemoval = true)
152+
default void setItemInHand(Supplier<? extends HandType> handType, ItemStack itemInHand) {
153+
this.setItemInHand(handType, (ItemStackLike) itemInHand);
154+
}
155+
116156
/**
117157
* Sets the equipped item in hand.
118158
*
119159
* @param handType The hand type to set to
120160
* @param itemInHand The item in hand
121161
*/
122-
default void setItemInHand(Supplier<? extends HandType> handType, ItemStack itemInHand) {
162+
default void setItemInHand(Supplier<? extends HandType> handType, ItemStackLike itemInHand) {
123163
this.setItemInHand(handType.get(), itemInHand);
124164
}
125165

166+
/**
167+
* @deprecated Use {@link #setItemInHand(HandType, ItemStackLike)} instead.
168+
*/
169+
@Deprecated(forRemoval = true)
170+
default void setItemInHand(HandType handType, ItemStack itemInHand) {
171+
this.setItemInHand(handType, (ItemStackLike) itemInHand);
172+
}
173+
126174
/**
127175
* Sets the equipped item in hand.
128176
*
129177
* @param handType The hand type to set to
130178
* @param itemInHand The item in hand
131179
*/
132-
void setItemInHand(HandType handType, ItemStack itemInHand);
180+
void setItemInHand(HandType handType, ItemStackLike itemInHand);
133181
}

src/main/java/org/spongepowered/api/item/inventory/Equipable.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ default boolean canEquip(final Supplier<? extends EquipmentType> type) {
5656
return this.canEquip(type.get());
5757
}
5858

59+
/**
60+
* @deprecated Use {@link #canEquip(EquipmentType, ItemStackLike)} instead.
61+
*/
62+
@Deprecated(forRemoval = true)
63+
default boolean canEquip(EquipmentType type, ItemStack equipment) {
64+
return this.canEquip(type, (ItemStackLike) equipment);
65+
}
66+
5967
/**
6068
* Gets whether this {@link Equipable} can equip the supplied equipment in its slot of
6169
* the specified type (eg. whether calling {@link #equip} with the specified
@@ -65,9 +73,17 @@ default boolean canEquip(final Supplier<? extends EquipmentType> type) {
6573
* @param equipment The equipment to check for
6674
* @return true if can equip the supplied equipment
6775
*/
68-
boolean canEquip(EquipmentType type, ItemStack equipment);
76+
boolean canEquip(EquipmentType type, ItemStackLike equipment);
6977

78+
/**
79+
* @deprecated Use {@link #canEquip(Supplier, ItemStackLike)} instead.
80+
*/
81+
@Deprecated(forRemoval = true)
7082
default boolean canEquip(final Supplier<? extends EquipmentType> type, final ItemStack equipment) {
83+
return this.canEquip(type, (ItemStackLike) equipment);
84+
}
85+
86+
default boolean canEquip(final Supplier<? extends EquipmentType> type, final ItemStackLike equipment) {
7187
return this.canEquip(type.get(), equipment);
7288
}
7389

@@ -84,6 +100,14 @@ default Optional<ItemStack> equipped(final Supplier<? extends EquipmentType> typ
84100
return this.equipped(type.get());
85101
}
86102

103+
/**
104+
* @deprecated Use {@link #equip(EquipmentType, ItemStackLike)} instead.
105+
*/
106+
@Deprecated(forRemoval = true)
107+
default boolean equip(EquipmentType type, ItemStack equipment) {
108+
return this.equip(type, (ItemStackLike) equipment);
109+
}
110+
87111
/**
88112
* Sets the item currently equipped by the {@link Equipable} in the specified slot, if
89113
* the equipable has such a slot.
@@ -95,9 +119,17 @@ default Optional<ItemStack> equipped(final Supplier<? extends EquipmentType> typ
95119
* specified equipment type or because the item was incompatible with
96120
* the specified slot.
97121
*/
98-
boolean equip(EquipmentType type, ItemStack equipment);
122+
boolean equip(EquipmentType type, ItemStackLike equipment);
99123

124+
/**
125+
* @deprecated Use {@link #equip(Supplier, ItemStackLike)} instead.
126+
*/
127+
@Deprecated(forRemoval = true)
100128
default boolean equip(final Supplier<? extends EquipmentType> type, final ItemStack equipment) {
129+
return this.equip(type, (ItemStackLike) equipment);
130+
}
131+
132+
default boolean equip(final Supplier<? extends EquipmentType> type, final ItemStackLike equipment) {
101133
return this.equip(type.get(), equipment);
102134
}
103135
}

src/main/java/org/spongepowered/api/item/inventory/equipment/EquipmentInventory.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.item.inventory.Equipable;
2828
import org.spongepowered.api.item.inventory.Inventory;
2929
import org.spongepowered.api.item.inventory.ItemStack;
30+
import org.spongepowered.api.item.inventory.ItemStackLike;
3031
import org.spongepowered.api.item.inventory.Slot;
3132
import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult;
3233

@@ -88,17 +89,33 @@ default Optional<ItemStack> peek(final Supplier<? extends EquipmentType> equipme
8889
return this.peek(equipmentType.get());
8990
}
9091

92+
/**
93+
* @deprecated Use {@link #set(EquipmentType, ItemStackLike)} instead.
94+
*/
95+
@Deprecated(forRemoval = true)
96+
default InventoryTransactionResult set(EquipmentType equipmentType, ItemStack stack) {
97+
return this.set(equipmentType, (ItemStackLike) stack);
98+
}
99+
91100
/**
92101
* Sets the item for the specified equipment type.
93102
*
94-
* @see Slot#set(ItemStack)
103+
* @see Slot#set(ItemStackLike)
95104
* @param equipmentType Type of equipment slot to set
96105
* @param stack stack to insert
97106
* @return operation result, for details see {@link Inventory#set}
98107
*/
99-
InventoryTransactionResult set(EquipmentType equipmentType, ItemStack stack);
108+
InventoryTransactionResult set(EquipmentType equipmentType, ItemStackLike stack);
100109

110+
/**
111+
* @deprecated Use {@link #set(Supplier, ItemStackLike)} instead.
112+
*/
113+
@Deprecated(forRemoval = true)
101114
default InventoryTransactionResult set(final Supplier<? extends EquipmentType> equipmentType, final ItemStack stack) {
115+
return this.set(equipmentType, (ItemStackLike) stack);
116+
}
117+
118+
default InventoryTransactionResult set(final Supplier<? extends EquipmentType> equipmentType, final ItemStackLike stack) {
102119
return this.set(equipmentType.get(), stack);
103120
}
104121

0 commit comments

Comments
 (0)