Skip to content

Commit 8d2f548

Browse files
committed
Make CustomItem implements Predicate<ItemStack>
1 parent 6d7d029 commit 8d2f548

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎src/main/java/io/github/kiber2009/plugin/contentapi/api/item/CustomItem.java‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
import org.jspecify.annotations.Nullable;
1616

1717
import java.util.Objects;
18+
import java.util.function.Predicate;
1819

19-
public abstract class CustomItem {
20+
public abstract class CustomItem implements Predicate<@Nullable ItemStack> {
2021
public static final NamespacedKey CUSTOM_ITEM_TAG =
2122
new NamespacedKey(ContentApiPlugin.getInstance(), "custom_item");
2223

@@ -28,7 +29,7 @@ protected CustomItem(final NamespacedKey id, final Properties properties) {
2829
this.properties = properties;
2930
}
3031

31-
@Contract(value = "_ -> new", pure = true)
32+
@Contract(value = "_ -> new", pure = true)
3233
public @NonNull ItemStack getItemStack(final int amount) {
3334
return properties.getItemStack(id, amount);
3435
}
@@ -38,8 +39,18 @@ protected CustomItem(final NamespacedKey id, final Properties properties) {
3839
return getItemStack(1);
3940
}
4041

42+
/**
43+
* @deprecated Use {@link #test(ItemStack)} instead.
44+
*/
45+
@Deprecated(since = "1.2.0", forRemoval = true)
4146
@Contract(value = "null -> false", pure = true)
4247
public boolean match(final @Nullable ItemStack stack) {
48+
return test(stack);
49+
}
50+
51+
@Override
52+
@Contract(value = "null -> false", pure = true)
53+
public boolean test(final @Nullable ItemStack stack) {
4354
if (stack == null)
4455
return false;
4556

‎src/main/java/io/github/kiber2009/plugin/contentapi/api/recipe/choice/CustomItemRecipeChoice.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.util.function.Predicate;
1010

11+
@Deprecated(forRemoval = true, since = "1.2.0")
1112
public class CustomItemRecipeChoice implements Predicate<@Nullable ItemStack> {
1213
private final CustomItem item;
1314

@@ -18,6 +19,6 @@ public CustomItemRecipeChoice(final @NonNull CustomItem item) {
1819
@Override
1920
@Contract(value = "null -> false", pure = true)
2021
public boolean test(final @Nullable ItemStack stack) {
21-
return item.match(stack);
22+
return item.test(stack);
2223
}
2324
}

0 commit comments

Comments
 (0)