public class ItemFactory extends Object
Constructor and Description |
---|
ItemFactory()
Creates a default factory for an Air item.
|
ItemFactory(@NotNull ItemStack itemStack)
Creates an item factory based on the given item.
|
ItemFactory(@NotNull Material material)
Creates an item factory for the given material.
|
ItemFactory(@NotNull Material material,
@NotNull Consumer<ItemMeta> consumer)
Creates an item factory for the given material.
|
ItemFactory(@NotNull Material material,
int amount)
Creates an item factory for the given material.
|
ItemFactory(@NotNull Material material,
int amount,
@NotNull Consumer<ItemMeta> consumer)
Creates an item factory for the given material.
|
Modifier and Type | Method and Description |
---|---|
ItemFactory |
addConsumer(Consumer<ItemMeta> consumer)
Adds a consumer that can be run on the meta upon creation or application.
|
ItemFactory |
apply(ItemStack itemStack)
Applies this factory to an existing item.
|
@NotNull ItemStack |
create()
This creates a new item given the provided material and amounts.
|
@NotNull ItemMeta |
getItemMeta() |
@NotNull Material |
getMaterial() |
ItemFactory |
setAmount(int i)
Set the final amount.
|
ItemFactory |
setMaterial(@NotNull Material material)
Re-sets the material.
|
public ItemFactory()
public ItemFactory(@NotNull @NotNull Material material)
material
- Materialpublic ItemFactory(@NotNull @NotNull Material material, int amount)
material
- Materialamount
- Amountpublic ItemFactory(@NotNull @NotNull Material material, @NotNull @NotNull Consumer<ItemMeta> consumer)
material
- Materialconsumer
- A consumer to be performed on the item when create()
is used.public ItemFactory(@NotNull @NotNull Material material, int amount, @NotNull @NotNull Consumer<ItemMeta> consumer)
material
- Materialamount
- Amountconsumer
- A consumer to be performed on the item's meta when create()
is used.public ItemFactory(@NotNull @NotNull ItemStack itemStack)
You can use apply(ItemStack)
to apply the edits to an item.
itemStack
- The template item stack to use.public ItemFactory setAmount(int i)
i
- Amountpublic ItemFactory addConsumer(Consumer<ItemMeta> consumer)
consumer
- A consumer to be run on the item metapublic ItemFactory apply(ItemStack itemStack)
The material of an existing item cannot be changed.
itemStack
- An item@NotNull public @NotNull Material getMaterial()
public ItemFactory setMaterial(@NotNull @NotNull Material material)
material
- A material@NotNull public @NotNull ItemMeta getItemMeta()
@NotNull public @NotNull ItemStack create()
Where possible, any invalid meta edits will be skipped to preserve the process.
Copyright © 2020. All rights reserved.