Interface Compat


public interface Compat
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final UUID
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    convertSlot(org.bukkit.event.inventory.InventoryEvent event, int slot)
    In API versions 1.20.6 and earlier, InventoryView is a class.
    org.bukkit.attribute.AttributeModifier
    createAttributeModifier(NBTAttribute attribute, double amount, org.bukkit.attribute.AttributeModifier.Operation operation)
     
    getAttributeKey(org.bukkit.attribute.AttributeModifier attributeModifier)
     
     
    default org.bukkit.inventory.Inventory
    getBottomInventory(org.bukkit.event.inventory.InventoryEvent event)
    Gets the bottom inventory from the InventoryEvent's InventoryView.
    default 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.
    default 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.
    default String
    getItemName(org.bukkit.inventory.ItemStack item)
     
    default org.bukkit.inventory.Inventory
    getTopInventory(org.bukkit.entity.Player player)
    Gets the top inventory from the player's open inventory.
    default org.bukkit.inventory.Inventory
    getTopInventory(org.bukkit.event.inventory.InventoryEvent event)
    Gets the top inventory from an InventoryEvent's InventoryView.
    default void
    setCursor(org.bukkit.event.inventory.InventoryEvent event, org.bukkit.inventory.ItemStack item)
    Again, version compatibility stuff.
    default void
    setItem(org.bukkit.entity.Player player, int slot, org.bukkit.inventory.ItemStack item)
    Sets the item in the specified slot of the player's open inventory.
  • Field Details

    • ATTRIBUTE_BONUS_UUID

      static final UUID ATTRIBUTE_BONUS_UUID
  • Method Details

    • createAttributeModifier

      org.bukkit.attribute.AttributeModifier createAttributeModifier(NBTAttribute attribute, double amount, org.bukkit.attribute.AttributeModifier.Operation operation)
    • getAttributeKey

      String getAttributeKey(org.bukkit.attribute.AttributeModifier attributeModifier)
    • getAttributeKey

      String getAttributeKey(NBTAttribute attribute)
    • getTopInventory

      default org.bukkit.inventory.Inventory getTopInventory(org.bukkit.event.inventory.InventoryEvent event)
      Gets the top inventory from an InventoryEvent's InventoryView. We do this here because InventoryView is an interface in 1.21+. Running the code here allows us to compile against an older bytecode version and thus allow Spigot's auto-conversion system to upgrade the bytecode to look for the interface instead of the class where applicable.
      Parameters:
      event - The generic InventoryEvent with an InventoryView to inspect.
      Returns:
      The top Inventory object from the event's InventoryView.
    • getTopInventory

      @NotNull default org.bukkit.inventory.Inventory getTopInventory(org.bukkit.entity.Player player)
      Gets the top inventory from the player's open inventory. We do this here because the InventoryView class is actually an interface in 1.21+. Running the code here allows us to compile against an older bytecode version and thus allow Spigot's auto-conversion system to upgrade the bytecode to look for the interface instead of the class where applicable.
      Parameters:
      player - The player to get the top inventory from.
      Returns:
      The top Inventory object from the player's open inventory.
    • getBottomInventory

      default org.bukkit.inventory.Inventory getBottomInventory(org.bukkit.event.inventory.InventoryEvent event)
      Gets the bottom inventory from the InventoryEvent's InventoryView. We do this here because the InventoryView class is actually an interface in 1.21+. Running the code here allows us to compile against an older bytecode version and thus allow Spigot's auto-conversion system to upgrade the bytecode to look for the interface instead of the class where applicable.
      Parameters:
      event - The generic InventoryEvent with an InventoryView to inspect.
      Returns:
      The bottom Inventory object from the event's InventoryView.
    • setCursor

      default void setCursor(org.bukkit.event.inventory.InventoryEvent event, org.bukkit.inventory.ItemStack item)
      Again, version compatibility stuff.
      Parameters:
      event - The generic InventoryEvent with an InventoryView to modify.
      item - The ItemStack to set as the cursor in the event's InventoryView.
    • setItem

      default void setItem(org.bukkit.entity.Player player, int slot, org.bukkit.inventory.ItemStack item)
      Sets the item in the specified slot of the player's open inventory. Doing here for compatibility.
      Parameters:
      player - the player to set the item for
      slot - the target slot
      item - the item to set
    • getInventory

      default 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 code is compiled against 1.16.5 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.
      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

      default 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 code is compiled against 1.16.5 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

      default 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 code is compiled against 1.16.5 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.
    • getItemName

      default String getItemName(org.bukkit.inventory.ItemStack item)