Package me.efekos.simpler.items
Class CustomItem
java.lang.Object
me.efekos.simpler.items.CustomItem
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
ConstructorDescriptionCustomItem
(org.bukkit.NamespacedKey key, Consumer<org.bukkit.inventory.ItemStack> appearance) Creates an instance of this custom item. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.NamespacedKey
getKey()
Returns the identifier of this custom item.org.bukkit.inventory.ItemStack
makeAppearance
(org.bukkit.inventory.ItemStack stack) Applies theAbstractCustomItem.appearance
consumer to a clone of theItemStack
given.protected void
setAppearance
(Consumer<org.bukkit.inventory.ItemStack> appearance) Changes the appearance.
-
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
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 theAbstractCustomItem.appearance
consumer to a clone of theItemStack
given.- Parameters:
stack
- AnItemStack
you want to apply the consumer.- Returns:
- Changed and cloned
ItemStack
.
-