summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authoreueln <euelnd@gmail.com>2013-04-11 14:13:11 -0500
committerturt2live <travpc@gmail.com>2014-05-01 17:18:20 -0600
commit562af14d25bc87162a68e033f59c0b8dba76663b (patch)
tree0d9d28c1fecd89cb2e5060071afa9dc86a6d1ace /src/main
parent0bf83c077dc503950c9819446fb5d89ed720779e (diff)
downloadbukkit-562af14d25bc87162a68e033f59c0b8dba76663b.tar
bukkit-562af14d25bc87162a68e033f59c0b8dba76663b.tar.gz
bukkit-562af14d25bc87162a68e033f59c0b8dba76663b.tar.lz
bukkit-562af14d25bc87162a68e033f59c0b8dba76663b.tar.xz
bukkit-562af14d25bc87162a68e033f59c0b8dba76663b.zip
Allow inventory creation by InventoryType and title. Fixes BUKKIT-4045
Up until now it has not been possible to create a new Inventory using a custom title and permit any InventoryType available. The commit changes that by adding a method to optionally supply the title for the given inventory type and holder, creating the functionality to display any supported inventory type with a 32 character length String. If the inventory title supplied is larger than 32 characters then an IllegalArgumentException is thrown stating so.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/Bukkit.java7
-rw-r--r--src/main/java/org/bukkit/Server.java14
2 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 6b9c9f3a..f61270ab 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -592,6 +592,13 @@ public final class Bukkit {
}
/**
+ * @see Server#createInventory(InventoryHolder owner, InventoryType type, String title)
+ */
+ public static Inventory createInventory(InventoryHolder owner, InventoryType type, String title) {
+ return server.createInventory(owner, type, title);
+ }
+
+ /**
* @see Server#createInventory(InventoryHolder owner, int size)
*/
public static Inventory createInventory(InventoryHolder owner, int size) {
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 22dc74a2..3c4d5418 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -693,6 +693,20 @@ public interface Server extends PluginMessageRecipient {
Inventory createInventory(InventoryHolder owner, InventoryType 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.
+ *
+ * @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.
+ */
+ Inventory createInventory(InventoryHolder owner, InventoryType type, String title);
+
+ /**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
* specified size.
*