summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authoreueln <euelnd@gmail.com>2013-04-11 14:20:41 -0500
committerturt2live <travpc@gmail.com>2014-04-30 22:50:58 -0600
commit2bf22a9c497f1a3dd8b52735128291338d145dc2 (patch)
tree2aa338deb40da144d41beb7212a61a7883995b1f /src/main/java/org
parentc3e4767a793f2a77ddba1aabf15dbaa38798e9a2 (diff)
downloadcraftbukkit-2bf22a9c497f1a3dd8b52735128291338d145dc2.tar
craftbukkit-2bf22a9c497f1a3dd8b52735128291338d145dc2.tar.gz
craftbukkit-2bf22a9c497f1a3dd8b52735128291338d145dc2.tar.lz
craftbukkit-2bf22a9c497f1a3dd8b52735128291338d145dc2.tar.xz
craftbukkit-2bf22a9c497f1a3dd8b52735128291338d145dc2.zip
Implement inventory creation by type and title. Fixes BUKKIT-4045
With the current API it is possible to create an inventory with a specific type, but it is not possible to give such an inventory a title other than the default. 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/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java9
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 111abb82..b0c2156a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1506,6 +1506,10 @@ public final class CraftServer implements Server {
return new CraftInventoryCustom(owner, type);
}
+ public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) {
+ return new CraftInventoryCustom(owner, type, title);
+ }
+
public Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException {
Validate.isTrue(size % 9 == 0, "Chests must have a size that is a multiple of 9!");
return new CraftInventoryCustom(owner, size);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
index a02a723d..533d62ad 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
@@ -18,6 +18,10 @@ public class CraftInventoryCustom extends CraftInventory {
super(new MinecraftInventory(owner, type));
}
+ public CraftInventoryCustom(InventoryHolder owner, InventoryType type, String title) {
+ super(new MinecraftInventory(owner, type, title));
+ }
+
public CraftInventoryCustom(InventoryHolder owner, int size) {
super(new MinecraftInventory(owner, size));
}
@@ -39,6 +43,11 @@ public class CraftInventoryCustom extends CraftInventory {
this.type = type;
}
+ public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) {
+ this(owner, type.getDefaultSize(), title);
+ this.type = type;
+ }
+
public MinecraftInventory(InventoryHolder owner, int size) {
this(owner, size, "Chest");
}