Fixed NPE while clearing a slot

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
CraftBukkit/Spigot 2011-01-16 14:34:31 +01:00
parent ffc7372165
commit 2f53dbcd0f

View file

@ -43,8 +43,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
public void setContents(ItemStack[] items) {
if (getInventory().getContents().length != items.length) {
throw new IllegalArgumentException("Invalid inventory size; expected "
+ getInventory().getContents().length);
throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContents().length);
}
net.minecraft.server.ItemStack[] mcItems = getInventory().getContents();
@ -54,15 +53,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
if (item == null) {
mcItems[i] = null;
} else {
mcItems[i] = new net.minecraft.server.ItemStack(
item.getTypeId(), item.getAmount(), item.getDamage());
mcItems[i] = new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), item.getDamage());
}
}
}
public void setItem(int index, ItemStack item) {
getInventory().a(index, new net.minecraft.server.ItemStack(
item.getTypeId(), item.getAmount(), item.getDamage()));
getInventory().a(index, (item == null ? null : new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), item.getDamage())));
}
public boolean contains(int materialId) {