Package com.ranull.graves.util
Class InventoryUtil
java.lang.Object
com.ranull.graves.util.InventoryUtil
Utility class for inventory-related operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
equipArmor
(org.bukkit.inventory.Inventory inventory, org.bukkit.entity.Player player) Equips the player's armor from the given inventory.static void
equipItems
(org.bukkit.inventory.Inventory inventory, org.bukkit.entity.Player player) Equips the player's inventory items from the given inventory.static int
getInventorySize
(int size) Gets the appropriate inventory size based on the given size.static String
inventoryToString
(org.bukkit.inventory.Inventory inventory) Converts the given inventory to a string representation.static boolean
isArmor
(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is armor.static boolean
isBoots
(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is boots.static boolean
isChestplate
(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is a chestplate.static boolean
isHelmet
(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is a helmet.static boolean
isLeggings
(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is leggings.static void
playArmorEquipSound
(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack itemStack) Plays the appropriate armor equip sound based on the item type.static org.bukkit.inventory.Inventory
stringToInventory
(org.bukkit.inventory.InventoryHolder inventoryHolder, String string, String title, Graves plugin) Converts a string representation of an inventory to an Inventory object.
-
Constructor Details
-
InventoryUtil
public InventoryUtil()
-
-
Method Details
-
getInventorySize
public static int getInventorySize(int size) Gets the appropriate inventory size based on the given size.- Parameters:
size
- The size to be used for determining the inventory size.- Returns:
- The appropriate inventory size.
-
equipArmor
public static void equipArmor(org.bukkit.inventory.Inventory inventory, org.bukkit.entity.Player player) Equips the player's armor from the given inventory.- Parameters:
inventory
- The inventory containing the armor items.player
- The player to be equipped with armor.
-
equipItems
public static void equipItems(org.bukkit.inventory.Inventory inventory, org.bukkit.entity.Player player) Equips the player's inventory items from the given inventory.- Parameters:
inventory
- The inventory containing the items.player
- The player to be equipped with items.
-
playArmorEquipSound
public static void playArmorEquipSound(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack itemStack) Plays the appropriate armor equip sound based on the item type.- Parameters:
player
- The player equipping the armor.itemStack
- The armor item being equipped.
-
isArmor
public static boolean isArmor(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is armor.- Parameters:
itemStack
- The item stack to be checked.- Returns:
- True if the item stack is armor, false otherwise.
-
isHelmet
public static boolean isHelmet(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is a helmet.- Parameters:
itemStack
- The item stack to be checked.- Returns:
- True if the item stack is a helmet, false otherwise.
-
isChestplate
public static boolean isChestplate(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is a chestplate.- Parameters:
itemStack
- The item stack to be checked.- Returns:
- True if the item stack is a chestplate, false otherwise.
-
isLeggings
public static boolean isLeggings(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is leggings.- Parameters:
itemStack
- The item stack to be checked.- Returns:
- True if the item stack is leggings, false otherwise.
-
isBoots
public static boolean isBoots(org.bukkit.inventory.ItemStack itemStack) Checks if the given item stack is boots.- Parameters:
itemStack
- The item stack to be checked.- Returns:
- True if the item stack is boots, false otherwise.
-
inventoryToString
Converts the given inventory to a string representation.- Parameters:
inventory
- The inventory to be converted.- Returns:
- The string representation of the inventory.
-
stringToInventory
public static org.bukkit.inventory.Inventory stringToInventory(org.bukkit.inventory.InventoryHolder inventoryHolder, String string, String title, Graves plugin) Converts a string representation of an inventory to an Inventory object.- Parameters:
inventoryHolder
- The inventory holder.string
- The string representation of the inventory.title
- The title of the inventory.plugin
- The Graves plugin instance.- Returns:
- The Inventory object.
-