mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +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.HoverEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEventSource;
|
import net.kyori.adventure.text.event.HoverEventSource;
|
||||||
import net.minestom.server.item.rule.VanillaStackingRule;
|
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 net.minestom.server.utils.NBTUtils;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -22,7 +24,7 @@ import java.util.function.UnaryOperator;
|
|||||||
* <p>
|
* <p>
|
||||||
* An item stack cannot be null, {@link ItemStack#AIR} should be used instead.
|
* 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'.
|
* Constant AIR item. Should be used instead of 'null'.
|
||||||
@ -191,6 +193,16 @@ public final class ItemStack implements HoverEventSource<HoverEvent.ShowItem> {
|
|||||||
.stackingRule(stackingRule);
|
.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
|
@Override
|
||||||
public @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull UnaryOperator<HoverEvent.ShowItem> op) {
|
public @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull UnaryOperator<HoverEvent.ShowItem> op) {
|
||||||
return HoverEvent.showItem(op.apply(HoverEvent.ShowItem.of(this.material,
|
return HoverEvent.showItem(op.apply(HoverEvent.ShowItem.of(this.material,
|
||||||
|
Loading…
Reference in New Issue
Block a user