Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: handle null lore properly #281

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
Expand All @@ -24,19 +25,17 @@ public static ItemStack create(Material material, Consumer<ItemMeta> metaConsume
return new ItemStackEditor(material).andMetaConsumer(metaConsumer).create();
}

public static ItemStack create(ItemStack item, @Nullable String name, String... lore) {
return new ItemStackEditor(item)
.setDisplayName(name)
.setLore(lore)
.create();
public static ItemStack create(ItemStack item, @Nullable String name, @Nullable String... lore) {
ItemStackEditor editor = new ItemStackEditor(item).setDisplayName(name);
return (lore != null) ? editor.setLore(lore).create() : editor.create();
}

public static ItemStack create(Material material, @Nullable String name, String... lore) {
public static ItemStack create(Material material, @Nullable String name, @Nullable String... lore) {
return create(new ItemStack(material), name, lore);
}

public static ItemStack create(Material type, @Nullable String name, List<String> lore) {
return create(new ItemStack(type), name, lore.toArray(String[]::new));
public static ItemStack create(Material type, @Nullable String name, @Nullable List<String> lore) {
return create(new ItemStack(type), name, (lore != null) ? lore.toArray(String[]::new): null);
}


Expand Down