Package com.earth2me.essentials.items
Class AbstractItemDb
java.lang.Object
com.earth2me.essentials.items.AbstractItemDb
- Direct Known Subclasses:
FlatItemDb
,LegacyItemDb
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.ess3.api.IItemDb
IItemDb.ItemResolver
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate a stack from the given name with the maximum stack size for that material.getMatching
(User user, String[] args) Get all stacks in a given User's inventory that matches the given arguments.getResolver
(Plugin plugin, String name) Get the resolver function with the given name from the given plugin.Get all registered resolvers.getResolvers
(Plugin plugin) Get all registered resolvers from the given plugin.boolean
isReady()
Check whether the item database is loaded and ready for use.boolean
isResolverPresent
(Plugin plugin, String name) Check whether a resolver with a given name from a given plugin has been registered.void
registerResolver
(Plugin plugin, String name, IItemDb.ItemResolver resolver) Add an item resolver that is called before looking up the item in the item database.Converts the givenItemStack
to a string representation that can be saved.Converts the givenItemStack
to a string representation that can be saved.void
unregisterResolver
(Plugin plugin, String name) Remove an item resolver from the given plugin with the given name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.earth2me.essentials.IConf
reloadConfig
Methods inherited from interface com.earth2me.essentials.api.IItemDb
get, getFromLegacy, getFromLegacy, getFromLegacyId, getLegacyId, listNames, name, nameList, names
-
Field Details
-
ess
-
ready
protected boolean ready
-
-
Method Details
-
registerResolver
public void registerResolver(Plugin plugin, String name, IItemDb.ItemResolver resolver) throws Exception Description copied from interface:IItemDb
Add an item resolver that is called before looking up the item in the item database.- Specified by:
registerResolver
in interfaceIItemDb
- Parameters:
plugin
- The owning pluginname
- The name of the resolverresolver
- The resolver accepting a String and returning an ItemStack, or null if none was found- Throws:
Exception
- If a resolver with a conflicting name is found
-
unregisterResolver
Description copied from interface:IItemDb
Remove an item resolver from the given plugin with the given name.- Specified by:
unregisterResolver
in interfaceIItemDb
- Parameters:
plugin
- The owning pluginname
- The name of the resolver- Throws:
Exception
- If no matching resolver was found
-
isResolverPresent
Description copied from interface:IItemDb
Check whether a resolver with a given name from a given plugin has been registered.- Specified by:
isResolverPresent
in interfaceIItemDb
- Parameters:
plugin
- The owning pluginname
- The name of the resolver- Returns:
- Whether the resolver could be found
-
getResolvers
Description copied from interface:IItemDb
Get all registered resolvers.- Specified by:
getResolvers
in interfaceIItemDb
- Returns:
- A map of all registered resolvers
-
getResolvers
Description copied from interface:IItemDb
Get all registered resolvers from the given plugin.- Specified by:
getResolvers
in interfaceIItemDb
- Parameters:
plugin
- The owning plugin- Returns:
- A map of all matching resolvers
-
getResolver
Description copied from interface:IItemDb
Get the resolver function with the given name from the given plugin.- Specified by:
getResolver
in interfaceIItemDb
- Parameters:
plugin
- The owning pluginname
- The name of the resolver- Returns:
- The resolver function, or null if not found
-
get
Description copied from interface:IItemDb
Create a stack from the given name with the maximum stack size for that material.Note that this will always check against resolver functions from other plugins as well. To avoid this behaviour, use net.ess3.api.IItemDb#get(String name, boolean useResolvers).
-
getMatching
Description copied from interface:IItemDb
Get all stacks in a given User's inventory that matches the given arguments.- Specified by:
getMatching
in interfaceIItemDb
- Parameters:
user
- The user with the player inventory to searchargs
- Either an item name, or one of the following: hand (default), inventory/invent/all, blocks- Returns:
- A List of all matching ItemStacks
- Throws:
Exception
- if the given args are invalid or no blocks are found
-
serialize
Description copied from interface:IItemDb
Converts the givenItemStack
to a string representation that can be saved. This is typically used for /createkit but can be used by other plugins for various purposes too. Note that this will try registered resolvers first - to avoid this, useIItemDb.serialize(ItemStack, boolean)
instead. -
serialize
Description copied from interface:IItemDb
Converts the givenItemStack
to a string representation that can be saved. This is typically used for /createkit but may be used by other plugins for various purposes too. -
isReady
public boolean isReady()Description copied from interface:IItemDb
Check whether the item database is loaded and ready for use.
-