mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-22 16:11:44 +01:00
Make ItemStack.Builder extends Taggable
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
917302cbbb
commit
3c0abb0409
@ -6,6 +6,7 @@ import net.kyori.adventure.text.event.HoverEventSource;
|
|||||||
import net.minestom.server.tag.Tag;
|
import net.minestom.server.tag.Tag;
|
||||||
import net.minestom.server.tag.TagHandler;
|
import net.minestom.server.tag.TagHandler;
|
||||||
import net.minestom.server.tag.TagReadable;
|
import net.minestom.server.tag.TagReadable;
|
||||||
|
import net.minestom.server.tag.Taggable;
|
||||||
import net.minestom.server.utils.NBTUtils;
|
import net.minestom.server.utils.NBTUtils;
|
||||||
import net.minestom.server.utils.validate.Check;
|
import net.minestom.server.utils.validate.Check;
|
||||||
import org.jetbrains.annotations.*;
|
import org.jetbrains.annotations.*;
|
||||||
@ -203,7 +204,7 @@ public sealed interface ItemStack extends TagReadable, HoverEventSource<HoverEve
|
|||||||
return meta();
|
return meta();
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed interface Builder permits ItemStackImpl.Builder {
|
sealed interface Builder extends Taggable permits ItemStackImpl.Builder {
|
||||||
@Contract(value = "_ -> this")
|
@Contract(value = "_ -> this")
|
||||||
@NotNull Builder amount(int amount);
|
@NotNull Builder amount(int amount);
|
||||||
|
|
||||||
@ -225,6 +226,12 @@ public sealed interface ItemStack extends TagReadable, HoverEventSource<HoverEve
|
|||||||
@Contract(value = "-> new", pure = true)
|
@Contract(value = "-> new", pure = true)
|
||||||
@NotNull ItemStack build();
|
@NotNull ItemStack build();
|
||||||
|
|
||||||
|
@Contract(value = "_, _ -> this")
|
||||||
|
default <T> @NotNull Builder set(@NotNull Tag<T> tag, @Nullable T value) {
|
||||||
|
setTag(tag, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Contract(value = "_ -> this")
|
@Contract(value = "_ -> this")
|
||||||
default @NotNull Builder displayName(@Nullable Component displayName) {
|
default @NotNull Builder displayName(@Nullable Component displayName) {
|
||||||
return meta(builder -> builder.displayName(displayName));
|
return meta(builder -> builder.displayName(displayName));
|
||||||
|
@ -137,6 +137,11 @@ record ItemStackImpl(Material material, int amount, ItemMetaImpl meta) implement
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull TagHandler tagHandler() {
|
||||||
|
return metaBuilder.tagHandler();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ItemStack build() {
|
public @NotNull ItemStack build() {
|
||||||
return ItemStackImpl.create(material, amount, metaBuilder.build());
|
return ItemStackImpl.create(material, amount, metaBuilder.build());
|
||||||
|
Loading…
Reference in New Issue
Block a user