Interface SpecialItem

public interface SpecialItem
Represents the type of a SpecialItem and not one for every given item to the player. Meaning there's only one global instance of every type.

Use GameAPI.registerSpecialItem(String, Plugin, String, ItemStack) to initiate a new one.

  • Method Details

    • getType

      SpecialItemType getType()
      Returns the type to make it easier for you to differentiate it
      The type of this special item
    • getId

      String getId()
      Returns the id that's being used in e.g. the shop config
      The id of this item
    • getName

      default String getName()
      Same as getName(CommandSender), but uses the default language
      The name of the item in the default language
    • getName

      String getName(@Nullable @Nullable CommandSender sender)
      Returns the name of this item in the language of the given sender.
      If sender is null then it'll use the default language instead
      sender - The person from which it should look up the language. Null if it should take the default language
      The name of the item in the language of the sender
    • getItemStack

      ItemStack getItemStack()
      Returns the item that the player will receive once he purchases the item.

      Keep in mind that this is not the original ItemStack. The plugin may add its own tags to make it unique and more identifiable from others. Use getOriginalItemStack() if you look to obtain the original one.

      The ItemStack of the item that's useable ingame
    • getOriginalItemStack

      ItemStack getOriginalItemStack()
      Returns the original ItemStack that's being passed during initiation.

      The returned ItemStack is not usable ingame. Use getItemStack() instead if that's what you're looking for.

      The original, non-modified ItemStack
    • isSpecialItem

      boolean isSpecialItem(ItemStack itemStack)
      Returns whether or not the given ItemStack is running this SpecialItem when used.
      true if it's the one for this SpecialItem. Otherwise false
    • getPlugin

      Plugin getPlugin()
      Returns the plugin that created the item
      The plugin that created this special item
    • getHandler

      SpecialItemUseHandler getHandler()
      Returns the handler that's been called whenever someone uses an item
      Uses DeadSpecialItemUseHandler as the default one
      The use handler of the special item
    • setHandler

      void setHandler(SpecialItemUseHandler handler)
      Set the handler that's been called whenever someone uses the item
      Plugins should use this rather than registerListener(SpecialItemListener) as it's providing a useful API
      handler - The new use handler
    • registerListener

      boolean registerListener(SpecialItemListener listener)
      Adds an listener to handle events of this special item
      You should use the SpecialItemAdapter as more things might get added in the future
      listener - The listener that shall be added
      false if the listener has already been registered
    • unregisterListener

      boolean unregisterListener(SpecialItemListener listener)
      Removes the listener and stops it from receiving any future events
      listener - The listener that shall be removed
      true if it has been successfully removed
    • getListeners

      Set<SpecialItemListener> getListeners()
      Returns a set with every listener that has been registered to this special item
      A set with all listeners
    • isRegistered

      default boolean isRegistered()
      Returns whether or not this item has been registered using GameAPI.registerSpecialItem(SpecialItem)
      Whether or not this item is registered