Class CodexItemManager

java.lang.Object
studio.magemonkey.codex.items.CodexItemManager

public class CodexItemManager extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    studio.magemonkey.codex.api.items.ItemType
    Get an item type from the provider.
    studio.magemonkey.codex.api.items.ItemType
    getItemType(String namespace, String id)
    Get an item type from the provider.
    Set<studio.magemonkey.codex.api.items.ItemType>
    getItemTypes(org.bukkit.inventory.ItemStack itemStack)
    Get the ItemTypes associated to the provided ItemStack.
    studio.magemonkey.codex.api.items.ItemType
    getMainItemType(org.bukkit.inventory.ItemStack itemStack)
    Get the main ItemType associated to the provided ItemStack.
    Collection<studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?>>
     
    void
     
    boolean
    isCustomItem(org.bukkit.inventory.ItemStack item)
     
    boolean
    isCustomItemOfId(org.bukkit.inventory.ItemStack item, String id)
     
    void
    registerProvider(String namespace, studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?> provider)
     
    static String
    Removes any prefixes corresponding to the currently registered Item Providers, if there is any.
    void
    unregisterProvider(Class<? extends studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?>> providerClass)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CodexItemManager

      public CodexItemManager(CodexEngine plugin)
  • Method Details

    • stripPrefix

      public static String stripPrefix(String id)
      Removes any prefixes corresponding to the currently registered Item Providers, if there is any.
      Parameters:
      id - the item id, prefixed or not
      Returns:
      the stripped id
    • init

      public void init()
    • registerProvider

      public void registerProvider(String namespace, studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?> provider)
    • unregisterProvider

      public void unregisterProvider(Class<? extends studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?>> providerClass)
    • getItemType

      public studio.magemonkey.codex.api.items.ItemType getItemType(String key) throws studio.magemonkey.codex.api.items.exception.MissingProviderException, studio.magemonkey.codex.api.items.exception.MissingItemException
      Get an item type from the provider. The key is in the format "namespace_id", e.g. "ORAXEN_MY_ITEM".
      Parameters:
      key - The key of the item.
      Returns:
      The item type as retrieved from the provider
      Throws:
      studio.magemonkey.codex.api.items.exception.MissingProviderException - If the provider for the given namespace is not enabled/missing.
      studio.magemonkey.codex.api.items.exception.MissingItemException - If the item with the given id does not exist.
    • getItemType

      public studio.magemonkey.codex.api.items.ItemType getItemType(String namespace, String id) throws studio.magemonkey.codex.api.items.exception.MissingProviderException, studio.magemonkey.codex.api.items.exception.MissingItemException
      Get an item type from the provider.
      Parameters:
      namespace - The namespace of the provider.
      id - The id of the item.
      Returns:
      The item type as retrieved from the provider.
      Throws:
      studio.magemonkey.codex.api.items.exception.MissingProviderException - If the provider for the given namespace is not enabled/missing.
      studio.magemonkey.codex.api.items.exception.MissingItemException - If the item with the given id does not exist.
    • getItemTypes

      @NotNull public Set<studio.magemonkey.codex.api.items.ItemType> getItemTypes(@Nullable org.bukkit.inventory.ItemStack itemStack)
      Get the ItemTypes associated to the provided ItemStack.
      Parameters:
      itemStack - The item to get the ItemTypes from
      Returns:
      a Set containing the ItemTypes the provided item corresponds to. May be empty.
    • getMainItemType

      @Nullable public studio.magemonkey.codex.api.items.ItemType getMainItemType(@Nullable org.bukkit.inventory.ItemStack itemStack)
      Get the main ItemType associated to the provided ItemStack. Importance is ranked according to the Enum.ordinal() value of the provider's ICodexItemProvider.getCategory(), with higher values meaning more importance.
      Parameters:
      itemStack - The item to get the ItemType from
      Returns:
      the ItemType of more importance corresponding to the item, or null if none was found.
    • isCustomItem

      public boolean isCustomItem(org.bukkit.inventory.ItemStack item)
    • isCustomItemOfId

      public boolean isCustomItemOfId(org.bukkit.inventory.ItemStack item, String id)
    • getProviders

      public Collection<studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?>> getProviders()