[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:
Bukkit/Spigot
2012-02-29 13:32:33 -05:00
parent da943825be
commit c180de46e2
31 changed files with 1074 additions and 68 deletions

View File

@@ -1,5 +1,7 @@
package org.bukkit.block;
import org.bukkit.inventory.BrewerInventory;
/**
* Represents a brewing stand.
*/
@@ -18,4 +20,6 @@ public interface BrewingStand extends BlockState, ContainerBlock {
* @param brewTime Brewing time
*/
void setBrewingTime(int brewTime);
public BrewerInventory getInventory();
}

View File

@@ -1,16 +1,10 @@
package org.bukkit.block;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
/**
* Indicates a block type that has inventory.
* @deprecated in favour of {@link InventoryHolder}
*/
public interface ContainerBlock {
/**
* Get the block's inventory.
*
* @return The inventory.
*/
public Inventory getInventory();
}
@Deprecated
public interface ContainerBlock extends InventoryHolder {}

View File

@@ -1,5 +1,7 @@
package org.bukkit.block;
import org.bukkit.inventory.FurnaceInventory;
/**
* Represents a furnace.
*/
@@ -32,4 +34,6 @@ public interface Furnace extends BlockState, ContainerBlock {
* @param cookTime Cook time
*/
public void setCookTime(short cookTime);
public FurnaceInventory getInventory();
}