Package net.ess3.api

Interface IItemDb.ItemResolver

All Superinterfaces:
Function<String,ItemStack>
All Known Implementing Classes:
CustomItemResolver
Enclosing interface:
IItemDb
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface IItemDb.ItemResolver extends Function<String,ItemStack>
A service capable of resolving custom item names to items and vice versa, as well as adding extra item names to tab complete suggestions.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(String name)
    Creates an item stack from the given name, if the given name is recognised by this resolver.
    Get all possible names that are recognised by this item resolver.
    default String
    Get a name recognised by this resolver for the given ItemStack, and return null if none was found.

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Method Details

    • apply

      ItemStack apply(String name)
      Creates an item stack from the given name, if the given name is recognised by this resolver.
      Specified by:
      apply in interface Function<String,ItemStack>
      Parameters:
      name - The name of the item to resolve
      Returns:
      A default stack of the item, or null if not recognised by this resolver.
    • getNames

      default Collection<String> getNames()
      Get all possible names that are recognised by this item resolver.

      Implementing this method is optional but recommended, since it enables custom items to be seen in tab complete.

      Returns:
      A collection of all the possible names for items that this resolver recognises.
    • serialize

      default String serialize(ItemStack stack)
      Get a name recognised by this resolver for the given ItemStack, and return null if none was found. The implementation of apply(String) must recognise any string returned here. Note that if you return a string here, no extra meta will be added - if you want to add extra meta, you need to return it with your serialized string.

      Implementing this method is optional but recommended, since it enables custom items to be saved by /createkit.

      Parameters:
      stack - The stack to serialize
      Returns:
      The name of the item if a suitable name was found, else null