Skip to content

Commit

Permalink
Migrate enchantments and trade offers
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHell228 committed Sep 14, 2024
1 parent 6ddddd4 commit ffd4e09
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.kyori.adventure.text.ComponentLike;
import org.spongepowered.api.block.entity.EnchantmentTable;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.registry.DefaultedRegistryValue;
import org.spongepowered.api.tag.EnchantmenTypeTags;
import org.spongepowered.api.tag.Taggable;
Expand Down Expand Up @@ -82,22 +83,38 @@ public interface EnchantmentType extends DefaultedRegistryValue, ComponentLike,
int maximumEnchantabilityForLevel(int level);

/**
* Test if this enchantment type can be applied to an {@link ItemStack}.
* @deprecated Use {@link #canBeAppliedToStack(ItemStackLike)} instead,
*/
@Deprecated(forRemoval = true)
default boolean canBeAppliedToStack(ItemStack stack) {
return this.canBeAppliedToStack((ItemStackLike) stack);
}

/**
* Test if this enchantment type can be applied to an {@link ItemStackLike}.
*
* @param stack The item stack to check
* @return Whether this enchantment type can be applied
*/
boolean canBeAppliedToStack(ItemStack stack);
boolean canBeAppliedToStack(ItemStackLike stack);

/**
* @deprecated Use {@link #canBeAppliedToStack(ItemStackLike)} instead,
*/
@Deprecated(forRemoval = true)
default boolean canBeAppliedByTable(ItemStack stack) {
return this.canBeAppliedByTable((ItemStackLike) stack);
}

/**
* Test if this enchantment type can be applied to an {@link ItemStack} by
* Test if this enchantment type can be applied to an {@link ItemStackLike} by
* the {@link EnchantmentTable}.
*
* @param stack Te item stack to check
* @return Whether this enchantment type can be applied by the
* enchantment table
*/
boolean canBeAppliedByTable(ItemStack stack);
boolean canBeAppliedByTable(ItemStackLike stack);

/**
* Test if this enchantment type can be applied along with
Expand Down
31 changes: 28 additions & 3 deletions src/main/java/org/spongepowered/api/item/merchant/TradeOffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.spongepowered.api.data.persistence.DataSerializable;
import org.spongepowered.api.entity.living.Humanoid;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.util.CopyableBuilder;

Expand Down Expand Up @@ -164,6 +165,14 @@ static Builder builder() {
*/
interface Builder extends org.spongepowered.api.util.Builder<TradeOffer, Builder>, CopyableBuilder<TradeOffer, Builder>, DataBuilder<TradeOffer> {

/**
* @deprecated Use {@link #firstBuyingItem(ItemStackLike)} instead.
*/
@Deprecated(forRemoval = true)
default Builder firstBuyingItem(ItemStack item) {
return this.firstBuyingItem((ItemStackLike) item);
}

/**
* <p>Sets the first selling item of the trade offer to be
* generated.</p>
Expand All @@ -173,23 +182,39 @@ interface Builder extends org.spongepowered.api.util.Builder<TradeOffer, Builder
* @param item The first item to buy
* @return This builder
*/
Builder firstBuyingItem(ItemStack item);
Builder firstBuyingItem(ItemStackLike item);

/**
* @deprecated Use {@link #secondBuyingItem(ItemStackLike)} instead.
*/
@Deprecated(forRemoval = true)
default Builder secondBuyingItem(ItemStack item) {
return this.secondBuyingItem((ItemStackLike) item);
}

/**
* Sets the second selling item of the trade offer to be generated.
*
* @param item The second item to buy
* @return This builder
*/
Builder secondBuyingItem(ItemStack item);
Builder secondBuyingItem(ItemStackLike item);

/**
* @deprecated Use {@link #sellingItem(ItemStackLike)} instead.
*/
@Deprecated(forRemoval = true)
default Builder sellingItem(ItemStack item) {
return this.sellingItem((ItemStackLike) item);
}

/**
* Sets the selling item of the trade offer to be generated.
*
* @param item The item to sell
* @return This builder
*/
Builder sellingItem(ItemStack item);
Builder sellingItem(ItemStackLike item);

/**
* Sets the existing uses of the trade offer to be generated. A trade
Expand Down

0 comments on commit ffd4e09

Please sign in to comment.