All Implemented Interfaces:
Placeable
Direct Known Subclasses:
StormStaff

public abstract class LimitedUseItem extends SimpleSlimefunItem<ItemUseHandler>
This class represents an item with a limited number of uses. When the item runs out of "uses", it breaks.
Author:
Linox, Walshy, TheBusyBiscuit, martinbrom
See Also:
  • Constructor Details

  • Method Details

    • getMaxUseCount

      public final int getMaxUseCount()
      Returns the number of times this item can be used.
      Returns:
      The number of times this item can be used.
    • setMaxUseCount

      @Nonnull public final LimitedUseItem setMaxUseCount(int count)
      Sets the maximum number of times this item can be used. The number must be greater than zero.
      Parameters:
      count - The maximum number of times this item can be used.
      Returns:
      The LimitedUseItem for chaining of setters
    • getStorageKey

      @Nonnull protected NamespacedKey getStorageKey()
      Returns the NamespacedKey under which will the amount of uses left stored.
      Returns:
      The NamespacedKey to store/load the amount of uses
    • register

      public void register(@Nonnull SlimefunAddon addon)
      Description copied from class: SlimefunItem
      This method registers this SlimefunItem. Always call this method after your SlimefunItem has been initialized. Never call it more than once!
      Overrides:
      register in class SlimefunItem
      Parameters:
      addon - The SlimefunAddon that this SlimefunItem belongs to.
    • damageItem

      @ParametersAreNonnullByDefault protected void damageItem(Player p, ItemStack item)