Item Creator - C00kier/CookiersLib GitHub Wiki
The ItemCreator class simplifies creating customized ItemStack instances with various optional properties such as display names, lore, enchantments, persistent data, and custom model data.
This class depends on ItemManager for applying enchantments and handling persistent data (namespaced keys). It provides a single powerful method to build ItemStacks with many customizable options.
Creates a customized ItemStack with optional display name, amount, lore, enchantments, persistent data, and custom model data.
createCustomItem(...)
Parameter | Type | Description |
---|---|---|
material |
Material |
The material type of the item. |
name |
String (nullable) |
The display name of the item. |
amount |
Integer (nullable) |
The stack size of the item. |
lore |
List<String> (nullable) |
The lore text displayed on the item. |
enchantmentsWithLevels |
Map<Enchantment, Integer> (nullable) |
Enchantments to apply with their levels. |
namespacedKey |
String (nullable) |
Key for custom persistent data . |
namespacedValue |
Z (nullable) |
Value for persistent data (type based on PersistentDataType ). |
dataType |
PersistentDataType<T, Z> (nullable) |
The data type handler for the persistent data . |
customModelId |
Integer (nullable) |
The custom model ID for resource packs. |
yourPlugin |
JavaPlugin (nullable) |
Plugin instance, required for namespaced keys . |
Returns:
- A fully configured ItemStack based on the provided parameters.
Example:
ItemStack customSword = CookiersLib.getInstance().getItemCreator().createCustomItem(
Material.DIAMOND_SWORD,
"§6Epic Sword",
1,
List.of("§7A powerful enchanted sword."),
Map.of(Enchantment.DAMAGE_ALL, 5),
"custom_sword_id",
12345,
PersistentDataType.INTEGER,
100,
myPluginInstance);