mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Make ItemStack TagReadable
This commit is contained in:
parent
9a1062b028
commit
d4fc6a094a
@ -4,6 +4,8 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.event.HoverEventSource;
|
||||
import net.minestom.server.item.rule.VanillaStackingRule;
|
||||
import net.minestom.server.tag.Tag;
|
||||
import net.minestom.server.tag.TagReadable;
|
||||
import net.minestom.server.utils.NBTUtils;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -22,7 +24,7 @@ import java.util.function.UnaryOperator;
|
||||
* <p>
|
||||
* An item stack cannot be null, {@link ItemStack#AIR} should be used instead.
|
||||
*/
|
||||
public final class ItemStack implements HoverEventSource<HoverEvent.ShowItem> {
|
||||
public final class ItemStack implements TagReadable, HoverEventSource<HoverEvent.ShowItem> {
|
||||
|
||||
/**
|
||||
* Constant AIR item. Should be used instead of 'null'.
|
||||
@ -191,6 +193,16 @@ public final class ItemStack implements HoverEventSource<HoverEvent.ShowItem> {
|
||||
.stackingRule(stackingRule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
|
||||
return meta.getTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTag(@NotNull Tag<?> tag) {
|
||||
return meta.hasTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull UnaryOperator<HoverEvent.ShowItem> op) {
|
||||
return HoverEvent.showItem(op.apply(HoverEvent.ShowItem.of(this.material,
|
||||
|
Loading…
Reference in New Issue
Block a user