Class InventoryUtil

java.lang.Object
studio.magemonkey.genesis.api.InventoryUtil

public class InventoryUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    convertSlot(org.bukkit.event.inventory.InventoryEvent event, int slot)
    In API versions 1.20.6 and earlier, InventoryView is a class.
    static org.bukkit.inventory.Inventory
    getBottomInventory(org.bukkit.event.inventory.InventoryEvent event)
    In API versions 1.20.6 and earlier, InventoryView is a class.
    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.
    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.
    static String
     
    static org.bukkit.inventory.Inventory
     
    static org.bukkit.inventory.Inventory
    getTopInventory(org.bukkit.event.inventory.InventoryEvent event)
    In API versions 1.20.6 and earlier, InventoryView is a class.
    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.
    static void
    setItem(Object view, int slot, org.bukkit.inventory.ItemStack item)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static String getTitle(Object view)
    • getTopInventory

      public static org.bukkit.inventory.Inventory getTopInventory(Object view)
    • 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

      public static void setItem(Object view, int slot, org.bukkit.inventory.ItemStack item)
    • 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.