Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Builder (Entity, Item)

Florian Fülling edited this page Jan 4, 2021 · 2 revisions

EldoUtilities provides some Builder Pattern to wrap and chain calls on objects. Not much to say here.
The method names are similar to the one which are used on the object themself

EntityBuilder

The EntityBuilder allows you to spawn and customize an living entity.

ItemStackBuilder

The ItemStackBuilder allows you to create a item stack and customize it.

When editing the meta you may want to use the ItemStackBuilder#withMetaValue(Consumer<@NotNull ItemMeta>).
This allows you to modify the meta, which will be applied afterwards on the item stack again. This avoids creating a new meta object everytime you change a meta value.
However all meta setters are also available in the builder.

If you need to change a specific meta type you can use the <T extends ItemMeta> ItemStackBuilder#withMetaValue(Consumer<@NotNull T> method.
This will cast your meta to the specified type if possible and pass it to your consumer.

Clone this wiki locally