Class AbstractItemDb

java.lang.Object
com.earth2me.essentials.items.AbstractItemDb
All Implemented Interfaces:
IItemDb, IConf, IItemDb
Direct Known Subclasses:
FlatItemDb, LegacyItemDb

public abstract class AbstractItemDb extends Object implements IConf, IItemDb
  • Field Details

    • ess

      protected final IEssentials 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 interface IItemDb
      Parameters:
      plugin - The owning plugin
      name - The name of the resolver
      resolver - 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

      public void unregisterResolver(Plugin plugin, String name) throws Exception
      Description copied from interface: IItemDb
      Remove an item resolver from the given plugin with the given name.
      Specified by:
      unregisterResolver in interface IItemDb
      Parameters:
      plugin - The owning plugin
      name - The name of the resolver
      Throws:
      Exception - If no matching resolver was found
    • isResolverPresent

      public boolean isResolverPresent(Plugin plugin, String name)
      Description copied from interface: IItemDb
      Check whether a resolver with a given name from a given plugin has been registered.
      Specified by:
      isResolverPresent in interface IItemDb
      Parameters:
      plugin - The owning plugin
      name - The name of the resolver
      Returns:
      Whether the resolver could be found
    • getResolvers

      public Map<PluginKey,IItemDb.ItemResolver> getResolvers()
      Description copied from interface: IItemDb
      Get all registered resolvers.
      Specified by:
      getResolvers in interface IItemDb
      Returns:
      A map of all registered resolvers
    • getResolvers

      public Map<PluginKey,IItemDb.ItemResolver> getResolvers(Plugin plugin)
      Description copied from interface: IItemDb
      Get all registered resolvers from the given plugin.
      Specified by:
      getResolvers in interface IItemDb
      Parameters:
      plugin - The owning plugin
      Returns:
      A map of all matching resolvers
    • getResolver

      public IItemDb.ItemResolver getResolver(Plugin plugin, String name)
      Description copied from interface: IItemDb
      Get the resolver function with the given name from the given plugin.
      Specified by:
      getResolver in interface IItemDb
      Parameters:
      plugin - The owning plugin
      name - The name of the resolver
      Returns:
      The resolver function, or null if not found
    • get

      public ItemStack get(String id) throws Exception
      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).

      Specified by:
      get in interface IItemDb
      Parameters:
      id - Item name to look up in the database
      Returns:
      The requested item stack with the maximum stack size
      Throws:
      Exception - if the item stack cannot be created
    • getMatching

      public List<ItemStack> getMatching(User user, String[] args) throws Exception
      Description copied from interface: IItemDb
      Get all stacks in a given User's inventory that matches the given arguments.
      Specified by:
      getMatching in interface IItemDb
      Parameters:
      user - The user with the player inventory to search
      args - 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

      public String serialize(ItemStack is)
      Description copied from interface: IItemDb
      Converts the given ItemStack 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, use IItemDb.serialize(ItemStack, boolean) instead.
      Specified by:
      serialize in interface IItemDb
      Parameters:
      is - The stack to serialize
      Returns:
      A string representing the given stack
    • serialize

      public String serialize(ItemStack is, boolean useResolvers)
      Description copied from interface: IItemDb
      Converts the given ItemStack 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.
      Specified by:
      serialize in interface IItemDb
      Parameters:
      is - The stack to serialize
      useResolvers - Whether to call other plugins' item resolvers before looking the item up in the database
      Returns:
      A string representation of the given item stack
    • isReady

      public boolean isReady()
      Description copied from interface: IItemDb
      Check whether the item database is loaded and ready for use.
      Specified by:
      isReady in interface IItemDb
      Returns:
      Whether items have finished loading