summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorRaphfrk <raphfrk@gmail.com>2011-04-29 00:26:04 +0100
committerEvilSeph <evilseph@unaligned.org>2011-05-02 02:09:24 -0400
commitaa70240917c2b6698c20c60a101431ba73da29af (patch)
tree008c962715442e158875b158ca9b05fcafbacb83 /src/main
parente56a8d47201b4adc48da2576ddedb623b95090ab (diff)
downloadcraftbukkit-aa70240917c2b6698c20c60a101431ba73da29af.tar
craftbukkit-aa70240917c2b6698c20c60a101431ba73da29af.tar.gz
craftbukkit-aa70240917c2b6698c20c60a101431ba73da29af.tar.lz
craftbukkit-aa70240917c2b6698c20c60a101431ba73da29af.tar.xz
craftbukkit-aa70240917c2b6698c20c60a101431ba73da29af.zip
Added a setArmorContents method to PlayerInventory.
It handles error checking. Null item stacks and air item stacks are both converted to clear slot calls to prevent crashing the client.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
index 68adab93..72c6a478 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
@@ -71,4 +71,18 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent
}
return ret;
}
+
+ public void setArmorContents(ItemStack[] items) {
+ int cnt = getSize();
+ if (items == null) {
+ items = new ItemStack[4];
+ }
+ for (ItemStack item : items) {
+ if (item == null || item.getTypeId() == 0) {
+ clear(cnt++);
+ } else {
+ setItem(cnt++, item);
+ }
+ }
+ }
}