SPIGOT-3981: Make custom inventories return specialised types where practical.

By: Senmori <thesenmori@gmail.com>
This commit is contained in:
Bukkit/Spigot
2018-07-25 18:03:20 +10:00
parent 193950a668
commit 1965b05b87
3 changed files with 93 additions and 8 deletions

View File

@@ -701,13 +701,27 @@ public interface Server extends PluginMessageRecipient {
public HelpMap getHelpMap();
/**
* 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.
* Creates an empty inventory with the specified type and title. 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.<br>
* It should be noted that some inventory types do not support titles and
* may not render with said titles on the Minecraft client.
* <br>
* {@link InventoryType#WORKBENCH} will not process crafting recipes if
* created with this method. Use
* {@link Player#openWorkbench(Location, boolean)} instead.
* <br>
* {@link InventoryType#ENCHANTING} will not process {@link ItemStack}s
* for possible enchanting results. Use
* {@link Player#openEnchanting(Location, boolean)} instead.
*
* @param owner the holder of the inventory, or null to indicate no holder
* @param type the type of inventory to create
* @return a new inventory
* @throws IllegalArgumentException if the {@link InventoryType} cannot be
* viewed.
*
* @see InventoryType#isCreatable()
*/
Inventory createInventory(InventoryHolder owner, InventoryType type);
@@ -717,11 +731,23 @@ public interface Server extends PluginMessageRecipient {
* otherwise the new inventory has the normal size for its type.<br>
* It should be noted that some inventory types do not support titles and
* may not render with said titles on the Minecraft client.
* <br>
* {@link InventoryType#WORKBENCH} will not process crafting recipes if
* created with this method. Use
* {@link Player#openWorkbench(Location, boolean)} instead.
* <br>
* {@link InventoryType#ENCHANTING} will not process {@link ItemStack}s
* for possible enchanting results. Use
* {@link Player#openEnchanting(Location, boolean)} instead.
*
* @param owner The holder of the inventory; can be null if there's no holder.
* @param type The type of inventory to create.
* @param title The title of the inventory, to be displayed when it is viewed.
* @return The new inventory.
* @throws IllegalArgumentException if the {@link InventoryType} cannot be
* viewed.
*
* @see InventoryType#isCreatable()
*/
Inventory createInventory(InventoryHolder owner, InventoryType type, String title);