Skip to content

I | Utility: CustomItemUtils

Sartaj Singh edited this page May 29, 2025 · 3 revisions

I | Utility: CustomItemUtils

CustomItemUtils helps you identify and work with your special items by material and display name.


1. isCustomItem(ItemStack stack, Material material, String displayName): boolean

What it does:
Checks if the ItemStack is both the correct material and has the specified display name.

Example:

if (CustomItemUtils.isCustomItem(item, Material.BLAZE_ROD, "§dMagic Wand")) {
    // This is the Magic Wand
}

2. getCustomItem(Player player, Material material, String displayName): ItemStack

What it does:
Searches a player's inventory for a custom item matching the material/display name.

Example:

ItemStack wand = CustomItemUtils.getCustomItem(player, Material.BLAZE_ROD, "§dMagic Wand");
if (wand != null) {
    // Player has the custom wand
}

Usage Patterns

  • Always use isCustomItem() before running custom behavior for your items.
  • Use getCustomItem() for inventory checks, e.g., quest logic.

Clone this wiki locally