mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
Allow to directly pass an ItemMeta
This commit is contained in:
parent
cbfeb4e15b
commit
066b041bba
@ -18,7 +18,7 @@ public class ItemBuilder {
|
|||||||
protected ItemBuilder(@NotNull Material material, @NotNull ItemMetaBuilder metaBuilder) {
|
protected ItemBuilder(@NotNull Material material, @NotNull ItemMetaBuilder metaBuilder) {
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.amount = 0;
|
this.amount = 0;
|
||||||
this.metaBuilder=metaBuilder;
|
this.metaBuilder = metaBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemBuilder(@NotNull Material material) {
|
protected ItemBuilder(@NotNull Material material) {
|
||||||
@ -32,6 +32,12 @@ public class ItemBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract(value = "_ -> this")
|
||||||
|
public @NotNull ItemBuilder meta(@NotNull ItemMeta itemMeta) {
|
||||||
|
this.metaBuilder = itemMeta.builder();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Contract(value = "_, _ -> this")
|
@Contract(value = "_, _ -> this")
|
||||||
public <T extends ItemMetaBuilder> @NotNull ItemBuilder meta(Class<T> metaType, Consumer<T> itemMetaConsumer) {
|
public <T extends ItemMetaBuilder> @NotNull ItemBuilder meta(Class<T> metaType, Consumer<T> itemMetaConsumer) {
|
||||||
itemMetaConsumer.accept((T) metaBuilder);
|
itemMetaConsumer.accept((T) metaBuilder);
|
||||||
|
@ -66,8 +66,14 @@ public class PlayerInit {
|
|||||||
//inventory.setItemStack(3, new ItemStack(Material.DIAMOND, (byte) 34));
|
//inventory.setItemStack(3, new ItemStack(Material.DIAMOND, (byte) 34));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CompassMeta compassMeta = new CompassMeta.Builder()
|
||||||
|
.lodestonePosition(new Position(0, 0, 0))
|
||||||
|
.build();
|
||||||
|
|
||||||
Item item = Item.builder(Material.COMPASS)
|
Item item = Item.builder(Material.COMPASS)
|
||||||
.amount(5)
|
.amount(5)
|
||||||
|
.meta(compassMeta)
|
||||||
.meta(CompassMeta.Builder.class, builder -> {
|
.meta(CompassMeta.Builder.class, builder -> {
|
||||||
builder.lodestonePosition(new Position(0, 0, 0));
|
builder.lodestonePosition(new Position(0, 0, 0));
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user