mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-03 21:52:05 -07:00
[Bleeding] Inventory framework and events. Addresses BUKKIT-856
New events: - InventoryOpenEvent - InventoryClickEvent - detects any clicks on a slot or outside the window - In the creative inventory view, only clicks on the quickbar are detected - InventoryCloseEvent - BrewEvent - when a potion finishes brewing - CraftItemEvent (a subevent of InventoryClickEvent) - fired when taking the crafted item - PrepareItemCraftEvent - fired just before updating the result slot Changes to existing events: - EnchantItemEvent extends InventoryEvent and also has a new whichButton() method - PrepareItemEnchantEvent also extends InventoryEvent - FurnaceBurnEvent and FurnaceSmeltEvent now extend BlockEvent (as does BrewEvent) - PlayerInventoryEvent is deprecated (though it never did anything anyway) New subclasses of Inventory: - BrewerInventory - CraftingInventory - DoubleChestInventory - EnchantingInventory - FurnaceInventory New methods in Inventory: - getViewers() - getTitle() - getType() - getHolder() - iterator() - Yes, inventories are now iterable! - The iterator is a ListIterator that does not support add or remove New methods in Player: - getOpenInventory() - openInventory() - openWorkbench() - openEnchanting() - closeInventory() - setWindowProperty() - getItemOnCursor() - setItemOnCursor() Other changes: - createInventory() methods in Server to make inventories not linked to an object - ContainerBlock is deprecated in favour of InventoryHolder - New InventoryView class gives direct access to an inventory window! - Removed the Slot class which did nothing and was used nowhere Some small credit goes to Afforess (initial conception of openInventory() methods) and Drakia (initial conception of InventoryOpenEvent and InventoryCloseEvent). By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
@@ -13,6 +13,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.map.MapView;
|
||||
@@ -560,4 +563,33 @@ public interface Server extends PluginMessageRecipient {
|
||||
* @return Messenger responsible for this server.
|
||||
*/
|
||||
public Messenger getMessenger();
|
||||
|
||||
/**
|
||||
* Creates an empty inventory of the specified type. If the type is {@link InventoryType#CHEST},
|
||||
* the new inventory has a size of 27; otherwise the new inventory has the normal size for
|
||||
* its type.
|
||||
* @param owner The holder of the inventory; can be null if there's no holder.
|
||||
* @param type The type of inventory to create.
|
||||
* @return The new inventory.
|
||||
*/
|
||||
Inventory createInventory(InventoryHolder owner, InventoryType type);
|
||||
|
||||
/**
|
||||
* Creates an empty inventory of type {@link InventoryType#CHEST} with the specified size.
|
||||
* @param owner The holder of the inventory; can be null if there's no holder.
|
||||
* @param size The size of inventory to create; must be a multiple of 9.
|
||||
* @return The new inventory.
|
||||
* @throws IllegalArgumentException If the size is not a multiple of 9.
|
||||
*/
|
||||
Inventory createInventory(InventoryHolder owner, int size);
|
||||
|
||||
/**
|
||||
* Creates an empty inventory of type {@link InventoryType#CHEST} with the specified size and title.
|
||||
* @param owner The holder of the inventory; can be null if there's no holder.
|
||||
* @param size The size of inventory to create; must be a multiple of 9.
|
||||
* @param title The title of the inventory, to be displayed when it is viewed.
|
||||
* @return The new inventory.
|
||||
* @throws IllegalArgumentException If the size is not a multiple of 9.
|
||||
*/
|
||||
Inventory createInventory(InventoryHolder owner, int size, String title);
|
||||
}
|
||||
|
Reference in New Issue
Block a user