CustomItemTag is now an abstract class

This commit is contained in:
Auxilor
2024-07-20 15:09:26 +01:00
parent 1f460d7a00
commit 0f11f9846c
2 changed files with 3 additions and 50 deletions

View File

@@ -1,60 +1,24 @@
package com.willfp.eco.core.items.tag;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.function.Predicate;
import java.util.function.Supplier;
/**
* A custom item tag.
*/
public final class CustomItemTag implements ItemTag {
public abstract class CustomItemTag implements ItemTag {
/**
* The key.
*/
private final NamespacedKey key;
/**
* The test.
*/
private final Predicate<@NotNull ItemStack> test;
/**
* The example item.
*/
private final Supplier<@NotNull ItemStack> exampleItem;
/**
* Create a new custom item tag.
*
* @param key The key.
* @param test The test.
*/
public CustomItemTag(@NotNull final NamespacedKey key,
@NotNull final Predicate<@NotNull ItemStack> test) {
this(
key,
test,
() -> new ItemStack(Material.STONE)
);
}
/**
* Create a new custom item tag with an example item.
*
* @param key The key.
* @param test The test.
* @param exampleItem The example item.
*/
public CustomItemTag(@NotNull final NamespacedKey key,
@NotNull final Predicate<@NotNull ItemStack> test,
@NotNull final Supplier<@NotNull ItemStack> exampleItem) {
public CustomItemTag(@NotNull final NamespacedKey key) {
this.key = key;
this.test = test;
this.exampleItem = exampleItem;
}
@Override
@@ -62,15 +26,4 @@ public final class CustomItemTag implements ItemTag {
public String getIdentifier() {
return key.toString();
}
@Override
public boolean matches(@NotNull final ItemStack itemStack) {
return test.test(itemStack);
}
@Override
@NotNull
public ItemStack getExampleItem() {
return exampleItem.get();
}
}

View File

@@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
/**
* A group of items that share a common trait.
*/
public sealed interface ItemTag permits CustomItemTag, VanillaItemTag {
public interface ItemTag {
/**
* Get the identifier of the tag.
*