Package studio.magemonkey.codex.compat
Interface Compat
public interface Compat
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault intconvertSlot(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class.org.bukkit.attribute.AttributeModifiercreateAttributeModifier(NBTAttribute attribute, double amount, org.bukkit.attribute.AttributeModifier.Operation operation) getAttributeKey(org.bukkit.attribute.AttributeModifier attributeModifier) getAttributeKey(NBTAttribute attribute) default org.bukkit.inventory.InventorygetBottomInventory(org.bukkit.event.inventory.InventoryEvent event) Gets the bottom inventory from the InventoryEvent's InventoryView.default org.bukkit.inventory.InventorygetInventory(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class.default org.bukkit.inventory.ItemStackgetItem(org.bukkit.event.inventory.InventoryEvent event, int slot) In API versions 1.20.6 and earlier, InventoryView is a class.default StringgetItemName(org.bukkit.inventory.ItemStack item) default org.bukkit.inventory.InventorygetTopInventory(org.bukkit.entity.Player player) Gets the top inventory from the player's open inventory.default org.bukkit.inventory.InventorygetTopInventory(org.bukkit.event.inventory.InventoryEvent event) Gets the top inventory from an InventoryEvent's InventoryView.default voidsetCursor(org.bukkit.event.inventory.InventoryEvent event, org.bukkit.inventory.ItemStack item) Again, version compatibility stuff.default voidsetItem(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
-
-
Method Details
-
createAttributeModifier
org.bukkit.attribute.AttributeModifier createAttributeModifier(NBTAttribute attribute, double amount, org.bukkit.attribute.AttributeModifier.Operation operation) -
getAttributeKey
-
getAttributeKey
-
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 forslot- the target slotitem- 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
-