Class CustomItem

java.lang.Object
me.efekos.simpler.items.CustomItem

public class CustomItem extends Object
Main class you will use for custom item systems. When making a custom item, always use primitive types and SaveField annotation in your fields. Annotate handling methods with HandleEvent annotation, or Simpler won't run them.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomItem(org.bukkit.NamespacedKey key, Consumer<org.bukkit.inventory.ItemStack> appearance)
    Creates an instance of this custom item.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.NamespacedKey
    Returns the identifier of this custom item.
    org.bukkit.inventory.ItemStack
    makeAppearance(org.bukkit.inventory.ItemStack stack)
    Applies the AbstractCustomItem.appearance consumer to a clone of the ItemStack given.
    protected void
    setAppearance(Consumer<org.bukkit.inventory.ItemStack> appearance)
    Changes the appearance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomItem

      public CustomItem(org.bukkit.NamespacedKey key, Consumer<org.bukkit.inventory.ItemStack> appearance)
      Creates an instance of this custom item. NOTE TO SUB-CLASSES: Do NOT override this constructor in your class. Make a constructor with no parameters that calls this constructor instead.
      Parameters:
      key - Identifier of this item.
      appearance - A consumer that will be applied to every instance of this item.
  • Method Details

    • getKey

      public org.bukkit.NamespacedKey getKey()
      Returns the identifier of this custom item.
      Returns:
      Identifier of this custom item.
    • setAppearance

      protected void setAppearance(Consumer<org.bukkit.inventory.ItemStack> appearance)
      Changes the appearance. Useful if you want to use class fields in your item.
      Parameters:
      appearance - New appearance.
    • makeAppearance

      public org.bukkit.inventory.ItemStack makeAppearance(org.bukkit.inventory.ItemStack stack)
      Applies the AbstractCustomItem.appearance consumer to a clone of the ItemStack given.
      Parameters:
      stack - An ItemStack you want to apply the consumer.
      Returns:
      Changed and cloned ItemStack.