Package dev.oumaimaa.kawaiiapi.items
Class ItemUtils
java.lang.Object
dev.oumaimaa.kawaiiapi.items.ItemUtils
Modern utility class for creating and manipulating Minecraft items using Paper's Adventure API.
Provides builder-style methods for creating items with custom properties without deprecated methods.
- Version:
- 1.0
- Author:
- KawaiiDevelopment
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder class for creating complex items with a fluent API. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull org.bukkit.inventory.ItemStackaddGlow(@NotNull org.bukkit.inventory.ItemStack item) Adds an enchantment glow effect to an item without showing actual enchantments.static @Nullable net.kyori.adventure.text.ComponentgetDisplayName(@Nullable org.bukkit.inventory.ItemStack item) Gets the display name of an item as a Component.static @Nullable List<net.kyori.adventure.text.Component> getLore(@Nullable org.bukkit.inventory.ItemStack item) Gets the lore of an item as a list of Components.static booleanhasCustomModelData(@Nullable org.bukkit.inventory.ItemStack item) Checks if an item has custom model data set.static booleanhasDisplayName(@Nullable org.bukkit.inventory.ItemStack item) Checks if an item has a display name.static booleanhasLore(@Nullable org.bukkit.inventory.ItemStack item) Checks if an item has lore.static @NotNull org.bukkit.inventory.ItemStackhideAllFlags(@NotNull org.bukkit.inventory.ItemStack item) Hides all item flags (enchants, attributes, unbreakable, etc.).static @NotNull org.bukkit.inventory.ItemStackmakeItem(@NotNull org.bukkit.Material material, int amount, @NotNull String displayName, @NotNull String... lore) Creates an ItemStack with a specific amount.static @NotNull org.bukkit.inventory.ItemStackmakeItem(@NotNull org.bukkit.Material material, @NotNull String displayName, @NotNull String... lore) Creates an ItemStack with display name and lore using modern Component API.static @NotNull org.bukkit.inventory.ItemStackmakeItemWithComponents(@NotNull org.bukkit.Material material, @NotNull net.kyori.adventure.text.Component displayName, @NotNull net.kyori.adventure.text.Component... lore) Creates an ItemStack using Adventure Components directly.static @NotNull org.bukkit.inventory.ItemStackmakeUnbreakable(@NotNull org.bukkit.inventory.ItemStack item) Makes an item unbreakable and hides the unbreakable tag from the tooltip.static @NotNull org.bukkit.inventory.ItemStacksetAmount(@NotNull org.bukkit.inventory.ItemStack item, int amount) Sets the amount of an item, clamping to valid stack size.static @NotNull org.bukkit.inventory.ItemStacksetCustomModelData(@NotNull org.bukkit.inventory.ItemStack item, int customModelData) Sets custom model data on an item for resource pack support.
-
Method Details
-
makeItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack makeItem(@NotNull @NotNull org.bukkit.Material material, @NotNull @NotNull String displayName, @NotNull @NotNull String... lore) Creates an ItemStack with display name and lore using modern Component API. Supports legacy color codes (&) and hex colors (invalid input: '&#'RRGGBB).- Parameters:
material- The material type for the itemdisplayName- The display name (supports color codes)lore- The lore lines (supports color codes)- Returns:
- The constructed ItemStack
-
makeItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack makeItem(@NotNull @NotNull org.bukkit.Material material, int amount, @NotNull @NotNull String displayName, @NotNull @NotNull String... lore) Creates an ItemStack with a specific amount.- Parameters:
material- The material type for the itemamount- The stack size (1-64, clamped automatically)displayName- The display name (supports color codes)lore- The lore lines (supports color codes)- Returns:
- The constructed ItemStack
-
makeItemWithComponents
@NotNull public static @NotNull org.bukkit.inventory.ItemStack makeItemWithComponents(@NotNull @NotNull org.bukkit.Material material, @NotNull @NotNull net.kyori.adventure.text.Component displayName, @NotNull @NotNull net.kyori.adventure.text.Component... lore) Creates an ItemStack using Adventure Components directly. Provides full control over text styling without string parsing.- Parameters:
material- The material type for the itemdisplayName- The display name as Componentlore- The lore lines as Components- Returns:
- The constructed ItemStack
-
addGlow
@NotNull public static @NotNull org.bukkit.inventory.ItemStack addGlow(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Adds an enchantment glow effect to an item without showing actual enchantments. Uses UNBREAKABLE enchantment which is widely compatible.- Parameters:
item- The item to add glow to- Returns:
- The modified ItemStack
-
makeUnbreakable
@NotNull public static @NotNull org.bukkit.inventory.ItemStack makeUnbreakable(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Makes an item unbreakable and hides the unbreakable tag from the tooltip.- Parameters:
item- The item to make unbreakable- Returns:
- The modified ItemStack
-
hideAllFlags
@NotNull public static @NotNull org.bukkit.inventory.ItemStack hideAllFlags(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Hides all item flags (enchants, attributes, unbreakable, etc.). Useful for creating clean-looking custom items.- Parameters:
item- The item to hide flags on- Returns:
- The modified ItemStack
-
setCustomModelData
@NotNull public static @NotNull org.bukkit.inventory.ItemStack setCustomModelData(@NotNull @NotNull org.bukkit.inventory.ItemStack item, int customModelData) Sets custom model data on an item for resource pack support.- Parameters:
item- The item to modifycustomModelData- The custom model data value- Returns:
- The modified ItemStack
-
setAmount
@NotNull public static @NotNull org.bukkit.inventory.ItemStack setAmount(@NotNull @NotNull org.bukkit.inventory.ItemStack item, int amount) Sets the amount of an item, clamping to valid stack size.- Parameters:
item- The item to modifyamount- The desired amount- Returns:
- The modified ItemStack
-
hasDisplayName
public static boolean hasDisplayName(@Nullable @Nullable org.bukkit.inventory.ItemStack item) Checks if an item has a display name.- Parameters:
item- The item to check- Returns:
- true if the item has a custom display name
-
hasLore
public static boolean hasLore(@Nullable @Nullable org.bukkit.inventory.ItemStack item) Checks if an item has lore.- Parameters:
item- The item to check- Returns:
- true if the item has lore
-
hasCustomModelData
public static boolean hasCustomModelData(@Nullable @Nullable org.bukkit.inventory.ItemStack item) Checks if an item has custom model data set.- Parameters:
item- The item to check- Returns:
- true if the item has custom model data
-
getDisplayName
@Nullable public static @Nullable net.kyori.adventure.text.Component getDisplayName(@Nullable @Nullable org.bukkit.inventory.ItemStack item) Gets the display name of an item as a Component.- Parameters:
item- The item to get the name from- Returns:
- The display name Component, or null if not set
-
getLore
@Nullable public static @Nullable List<net.kyori.adventure.text.Component> getLore(@Nullable @Nullable org.bukkit.inventory.ItemStack item) Gets the lore of an item as a list of Components.- Parameters:
item- The item to get lore from- Returns:
- The lore list, or null if not set
-