Package studio.magemonkey.genesis.api
Class InventoryUtil
java.lang.Object
studio.magemonkey.genesis.api.InventoryUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intconvertSlot(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class.static org.bukkit.inventory.InventorygetBottomInventory(org.bukkit.event.inventory.InventoryEvent event) In API versions 1.20.6 and earlier, InventoryView is a class.static org.bukkit.inventory.InventorygetInventory(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class.static org.bukkit.inventory.ItemStackgetItem(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class.static Stringstatic org.bukkit.inventory.InventorygetTopInventory(Object view) static org.bukkit.inventory.InventorygetTopInventory(org.bukkit.event.inventory.InventoryEvent event) In API versions 1.20.6 and earlier, InventoryView is a class.static voidsetCursor(org.bukkit.event.inventory.InventoryEvent event, org.bukkit.inventory.ItemStack item) In API versions 1.20.6 and earlier, InventoryView is a class.static void
-
Constructor Details
-
InventoryUtil
public InventoryUtil()
-
-
Method Details
-
getTopInventory
public static org.bukkit.inventory.Inventory getTopInventory(org.bukkit.event.inventory.InventoryEvent event) In API versions 1.20.6 and earlier, InventoryView is a class. In versions 1.21 and later, it is an interface. This method uses reflection to get the top Inventory object from the InventoryView associated with an InventoryEvent, to avoid runtime errors.- Parameters:
event- The generic InventoryEvent with an InventoryView to inspect.- Returns:
- The top Inventory object from the event's InventoryView.
-
getTitle
-
getTopInventory
-
getBottomInventory
public static org.bukkit.inventory.Inventory getBottomInventory(org.bukkit.event.inventory.InventoryEvent event) In API versions 1.20.6 and earlier, InventoryView is a class. In versions 1.21 and later, it is an interface. This method uses reflection to get the bottom Inventory object from the InventoryView associated with an InventoryEvent, to avoid runtime errors.- Parameters:
event- The generic InventoryEvent with an InventoryView to inspect.- Returns:
- The bottom Inventory object from the event's InventoryView.
-
setCursor
public static void setCursor(org.bukkit.event.inventory.InventoryEvent event, org.bukkit.inventory.ItemStack item) In API versions 1.20.6 and earlier, InventoryView is a class. In versions 1.21 and later, it is an interface. This method uses reflection to set the cursor ItemStack in the InventoryView associated with an InventoryEvent, to avoid runtime errors.- Parameters:
event- The generic InventoryEvent with an InventoryView to modify.item- The ItemStack to set as the cursor in the event's InventoryView.
-
setItem
-
getInventory
public static org.bukkit.inventory.Inventory getInventory(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class. In versions 1.21 and later, it is an interface. This method uses reflection to get the Inventory object from the InventoryView associated with an InventoryEvent, to avoid runtime errors. The slot parameter is used to determine which Inventory object to return. If the slot is in the top Inventory, the top Inventory is returned. If the slot is in the bottom Inventory, the bottom Inventory is returned. If the slot is not in either Inventory, null is returned.- Parameters:
event- The generic InventoryEvent with an InventoryView to inspect.slot- The slot index to check in the InventoryView.- Returns:
- The Inventory object from the event's InventoryView at the specified slot.
-
getItem
public static org.bukkit.inventory.ItemStack getItem(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class. In versions 1.21 and later, it is an interface. This method uses reflection to get the ItemStack at the specified slot in the InventoryView associated with an InventoryEvent, to avoid runtime errors. The slot parameter is used to determine which ItemStack to return.- Parameters:
event- The generic InventoryEvent with an InventoryView to inspect.slot- The slot index to check in the InventoryView.- Returns:
- The ItemStack from the event's InventoryView at the specified slot.
-
convertSlot
public static int convertSlot(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class. In versions 1.21 and later, it is an interface. This method uses reflection to convert the slot index from the InventoryView associated with an InventoryEvent, to avoid runtime errors. The slot parameter is used to determine which slot index to convert.- Parameters:
event- The generic InventoryEvent with an InventoryView to inspect.slot- The slot index to convert in the InventoryView.- Returns:
- The converted slot index from the event's InventoryView.
-