diff options
author | Raphfrk <raphfrk@gmail.com> | 2011-04-29 00:26:04 +0100 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-05-02 02:09:24 -0400 |
commit | aa70240917c2b6698c20c60a101431ba73da29af (patch) | |
tree | 008c962715442e158875b158ca9b05fcafbacb83 /src/main | |
parent | e56a8d47201b4adc48da2576ddedb623b95090ab (diff) | |
download | craftbukkit-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.java | 14 |
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); + } + } + } } |