Package me.efekos.simpler.items
Class ItemManager
java.lang.Object
me.efekos.simpler.items.ItemManager
Static manager for
CustomItems. You can register your CustomItems using this class.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.bukkit.NamespacedKeyKey that is used to save item ids ofCustomItems onItemStacks. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.inventory.ItemStackcreateStack(CustomItem item) Creates an item stack using the custom item instance given.static CustomItemgetItem(org.bukkit.inventory.ItemStack stack) Finds theCustomIteminstance of theItemStackgiven.static voidgiveItem(@NotNull org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item) Adds anItemStackto someone's inventory.static voidgiveItem(@NotNull org.bukkit.entity.Player player, org.bukkit.Material type) Gives someone anItemStackof theMaterialgiven.static voidgiveItem(org.bukkit.entity.Player player, CustomItem item) Creates anItemStackfor the item given, and gives it to the player.static voidgiveSkull(@NotNull org.bukkit.entity.Player player, org.bukkit.entity.Player skullOwner) Gives someone the skull of thePlayergiven.static voidgiveSkull(@NotNull org.bukkit.entity.Player player, org.bukkit.OfflinePlayer skullOwner) Gives someone the skull of theOfflinePlayergiven.static booleanisCustom(org.bukkit.inventory.ItemStack stack) Checks the stack to validate that it is a custom item instance.static voidLoads the custom item data from the plugin given before usingsetPlugin(JavaPlugin)static voidregisterItem(org.bukkit.NamespacedKey key, Class<? extends CustomItem> item) Registers a custom item.static voidSaves the custom item data to the plugin given before usingsetPlugin(JavaPlugin)static voidsetPlugin(org.bukkit.plugin.java.JavaPlugin plugin) Registers the event listeners using the plugin given.
-
Field Details
-
ITEM_UUID_KEY
public static final org.bukkit.NamespacedKey ITEM_UUID_KEYKey that is used to save item ids ofCustomItems onItemStacks.
-
-
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 usingsetPlugin(JavaPlugin) -
loadCustomItems
public static void loadCustomItems()Loads the custom item data from the plugin given before usingsetPlugin(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
Registers a custom item.- Parameters:
key- Identifier of this custom item type.item- Class of the custom item.
-
createStack
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
Finds theCustomIteminstance of theItemStackgiven.- Parameters:
stack- A stack.- Returns:
- A
CustomIteminstance if found,nullotherwise.
-
giveItem
Creates anItemStackfor the item given, and gives it to the player.- Parameters:
player- A player that will receive this custom item.item- ACustomIteminstance.
-
giveItem
public static void giveItem(@NotNull @NotNull org.bukkit.entity.Player player, org.bukkit.Material type) Gives someone anItemStackof theMaterialgiven.- 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 anItemStackto someone's inventory.- Parameters:
player- Someone to give the stack.item-ItemStackyou want to give.
-
giveSkull
public static void giveSkull(@NotNull @NotNull org.bukkit.entity.Player player, org.bukkit.OfflinePlayer skullOwner) Gives someone the skull of theOfflinePlayergiven.- Parameters:
player-Playerwho you want to give a skull.skullOwner-OfflinePlayerwho 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 thePlayergiven.- Parameters:
player-Playerwho you want to give a skull.skullOwner-Playerwho will be the owner of this skull.
-