Refactor ItemStackBuilder#meta to use ItemStack#editMeta method
This commit is contained in:
parent
c5e59537a0
commit
721175f965
@ -92,19 +92,14 @@ public class ItemStackBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackBuilder meta(Consumer<ItemMeta> metaUpdater) {
|
public ItemStackBuilder meta(Consumer<ItemMeta> metaUpdater) {
|
||||||
metaUpdater.accept(getOrInitMeta());
|
return meta(metaUpdater, ItemMeta.class);
|
||||||
updateMeta();
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends ItemMeta> ItemStackBuilder meta(Consumer<T> metaUpdater, Class<T> metaType) {
|
public <T extends ItemMeta> ItemStackBuilder meta(Consumer<T> metaUpdater, Class<T> metaType) {
|
||||||
ItemMeta m = getOrInitMeta();
|
stack.editMeta(metaType, m -> {
|
||||||
if (!metaType.isInstance(m)) {
|
metaUpdater.accept(m);
|
||||||
Log.warning("Item meta of " + stack.getType() + " is not of type " + metaType.getSimpleName(), new Throwable());
|
cachedMeta = m;
|
||||||
return this;
|
});
|
||||||
}
|
|
||||||
metaUpdater.accept(metaType.cast(m));
|
|
||||||
updateMeta();
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user