Class O2Items

java.lang.Object
net.pottercraft.ollivanders2.item.O2Items

public class O2Items extends Object
Manager for all items in Ollivanders
  • Field Details

    • enchantedItems

      public EnchantedItems enchantedItems
      The enchanted items manager - handles all enchantments on items
    • o2ItemTypeKey

      public static org.bukkit.NamespacedKey o2ItemTypeKey
      Namespace key for NTB flags
  • Constructor Details

    • O2Items

      public O2Items(@NotNull @NotNull Ollivanders2 plugin)
      Constructor
      Parameters:
      plugin - a reference to the plugin
  • Method Details

    • onEnable

      public void onEnable()
      Load all items and enchantments
    • onDisable

      public void onDisable()
      Cleanup when the plugin disables.

      Called when the Ollivanders2 plugin is being shut down. The O2Items manager performs no cleanup on disable because item data is read-only and loaded from configuration on startup. No persistent state needs to be saved.

    • getItemByType

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getItemByType(@NotNull @NotNull O2ItemType itemType, int amount)
      Get an item by type
      Parameters:
      itemType - the type of item to get
      amount - the amount of the item to get
      Returns:
      an item stack of the item and amount, null if item not found
    • getItemByName

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getItemByName(@NotNull @NotNull String name, int amount)
      Get an item by name
      Parameters:
      name - the name of the item
      amount - the amount of the item to get
      Returns:
      an item stack of the item and amount, null if item not found
    • getItemByNameStartsWith

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getItemByNameStartsWith(@NotNull @NotNull String name, int amount)
      Get an item that name starts with a substring
      Parameters:
      name - the substring of the name starts with
      amount - the amount of the item to get
      Returns:
      an item stack of the item and amount, null if item not found
    • getItemTypeByName

      @Nullable public @Nullable O2ItemType getItemTypeByName(@NotNull @NotNull String name)
      Get item type by display name - set in the metadata of the item
      Parameters:
      name - the display name for the item
      Returns:
      the item type if found, null otherwise
    • getItemNameByType

      @Nullable public @Nullable String getItemNameByType(@NotNull @NotNull O2ItemType itemType)
      Get the name of an item by type.
      Parameters:
      itemType - the item type
      Returns:
      the name of this item or null if not found
    • getItemTypeByNameStartsWith

      @Nullable public @Nullable O2ItemType getItemTypeByNameStartsWith(@NotNull @NotNull String name)
      Get an item where the name starts with this string
      Parameters:
      name - the substring of the name starts with
      Returns:
      the item type if found, null otherwise
    • getItemMaterialByType

      @Nullable public @Nullable org.bukkit.Material getItemMaterialByType(@NotNull @NotNull O2ItemType itemType)
      Get the material type for an item type
      Parameters:
      itemType - the item type to get the material for
      Returns:
      the material type if found, null otherwise
    • getO2ItemNameFromItemStack

      @Nullable public @Nullable String getO2ItemNameFromItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Get an O2Item name from the NBT o2ItemTypeKey tag in the item metadata
      Parameters:
      itemStack - the item stack to check
      Returns:
      the O2Item name if found, null otherwise
    • getAllItemNames

      @NotNull public @NotNull ArrayList<String> getAllItemNames()
      Get the names of all items.
      Returns:
      an array of the item names
    • getItemTypeByItem

      @Nullable public @Nullable O2ItemType getItemTypeByItem(@NotNull @NotNull org.bukkit.entity.Item item)
      Get the O2ItemType of an Item
      Parameters:
      item - the item to check
      Returns:
      the O2ItemType if it is an O2Item, null otherwise
    • getItemTypeByItemStack

      @Nullable public @Nullable O2ItemType getItemTypeByItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Get the O2ItemType of an Item
      Parameters:
      itemStack - the ItemStack to check
      Returns:
      the O2ItemType if it is an O2Item, null otherwise
    • getWands

      public O2Wands getWands()
      Get wands management class
      Returns:
      wands