Class ItemManager

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

public class ItemManager extends Object
Static manager for CustomItems. You can register your CustomItems using this class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.bukkit.NamespacedKey
    Key that is used to save item ids of CustomItems on ItemStacks.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance if you somehow need one.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.inventory.ItemStack
    Creates an item stack using the custom item instance given.
    static CustomItem
    getItem(org.bukkit.inventory.ItemStack stack)
    Finds the CustomItem instance of the ItemStack given.
    static void
    giveItem(@NotNull org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item)
    Adds an ItemStack to someone's inventory.
    static void
    giveItem(@NotNull org.bukkit.entity.Player player, org.bukkit.Material type)
    Gives someone an ItemStack of the Material given.
    static void
    giveItem(org.bukkit.entity.Player player, CustomItem item)
    Creates an ItemStack for the item given, and gives it to the player.
    static void
    giveSkull(@NotNull org.bukkit.entity.Player player, org.bukkit.entity.Player skullOwner)
    Gives someone the skull of the Player given.
    static void
    giveSkull(@NotNull org.bukkit.entity.Player player, org.bukkit.OfflinePlayer skullOwner)
    Gives someone the skull of the OfflinePlayer given.
    static boolean
    isCustom(org.bukkit.inventory.ItemStack stack)
    Checks the stack to validate that it is a custom item instance.
    static void
    Loads the custom item data from the plugin given before using setPlugin(JavaPlugin)
    static void
    registerItem(org.bukkit.NamespacedKey key, Class<? extends CustomItem> item)
    Registers a custom item.
    static void
    Saves the custom item data to the plugin given before using setPlugin(JavaPlugin)
    static void
    setPlugin(org.bukkit.plugin.java.JavaPlugin plugin)
    Registers the event listeners using the plugin given.

    Methods inherited from class java.lang.Object

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

    • ITEM_UUID_KEY

      public static final org.bukkit.NamespacedKey ITEM_UUID_KEY
      Key that is used to save item ids of CustomItems on ItemStacks.
  • Constructor Details

    • ItemManager

      public ItemManager()
      Creates a new instance if you somehow need one.
  • Method Details

    • saveCustomItems

      public static void saveCustomItems()
      Saves the custom item data to the plugin given before using setPlugin(JavaPlugin)
    • loadCustomItems

      public static void loadCustomItems()
      Loads the custom item data from the plugin given before using setPlugin(JavaPlugin)
    • setPlugin

      public static void setPlugin(org.bukkit.plugin.java.JavaPlugin plugin)
      Registers the event listeners using the plugin given.
      Parameters:
      plugin - An instance of the plugin that will use this manager.
    • registerItem

      public static void registerItem(org.bukkit.NamespacedKey key, Class<? extends CustomItem> item)
      Registers a custom item.
      Parameters:
      key - Identifier of this custom item type.
      item - Class of the custom item.
    • createStack

      public static org.bukkit.inventory.ItemStack createStack(CustomItem item)
      Creates an item stack using the custom item instance given.
      Parameters:
      item - An instance of a custom item.
      Returns:
      The stack created.
      Throws:
      IllegalStateException - If a plugin isn't set
    • isCustom

      public static boolean isCustom(org.bukkit.inventory.ItemStack stack)
      Checks the stack to validate that it is a custom item instance.
      Parameters:
      stack - An item stack.
      Returns:
      Whether the stack given is a custom item instance.
    • getItem

      public static CustomItem getItem(org.bukkit.inventory.ItemStack stack)
      Finds the CustomItem instance of the ItemStack given.
      Parameters:
      stack - A stack.
      Returns:
      A CustomItem instance if found, null otherwise.
    • giveItem

      public static void giveItem(org.bukkit.entity.Player player, CustomItem item)
      Creates an ItemStack for the item given, and gives it to the player.
      Parameters:
      player - A player that will receive this custom item.
      item - A CustomItem instance.
    • giveItem

      public static void giveItem(@NotNull @NotNull org.bukkit.entity.Player player, org.bukkit.Material type)
      Gives someone an ItemStack of the Material given.
      Parameters:
      player - Someone to give an item.
      type - Type of the item you want to give.
    • giveItem

      public static void giveItem(@NotNull @NotNull org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item)
      Adds an ItemStack to someone's inventory.
      Parameters:
      player - Someone to give the stack.
      item - ItemStack you want to give.
    • giveSkull

      public static void giveSkull(@NotNull @NotNull org.bukkit.entity.Player player, org.bukkit.OfflinePlayer skullOwner)
      Gives someone the skull of the OfflinePlayer given.
      Parameters:
      player - Player who you want to give a skull.
      skullOwner - OfflinePlayer who will be the owner of this skull.
    • giveSkull

      public static void giveSkull(@NotNull @NotNull org.bukkit.entity.Player player, org.bukkit.entity.Player skullOwner)
      Gives someone the skull of the Player given.
      Parameters:
      player - Player who you want to give a skull.
      skullOwner - Player who will be the owner of this skull.