Package studio.magemonkey.codex.items
Class CodexItemManager
java.lang.Object
studio.magemonkey.codex.items.CodexItemManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstudio.magemonkey.codex.api.items.ItemTypegetItemType(String key) Get an item type from the provider.studio.magemonkey.codex.api.items.ItemTypegetItemType(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.ItemTypegetMainItemType(org.bukkit.inventory.ItemStack itemStack) Get the main ItemType associated to the provided ItemStack.Collection<studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?>> voidinit()booleanisCustomItem(org.bukkit.inventory.ItemStack item) booleanisCustomItemOfId(org.bukkit.inventory.ItemStack item, String id) voidregisterProvider(String namespace, studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?> provider) static StringstripPrefix(String id) Removes any prefixes corresponding to the currently registered Item Providers, if there is any.voidunregisterProvider(Class<? extends studio.magemonkey.codex.api.items.providers.ICodexItemProvider<?>> providerClass)
-
Constructor Details
-
CodexItemManager
-
-
Method Details
-
stripPrefix
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 theEnum.ordinal()value of the provider'sICodexItemProvider.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
-
getProviders
-