From d20d4dc43aaa74fba457c44994cda8180523c9db Mon Sep 17 00:00:00 2001 From: feildmaster Date: Sat, 15 Dec 2012 01:33:14 -0600 Subject: [PATCH] ItemStack.asBukkitStack(null) should return Air. Fixes BUKKIT-3170 --- .../java/org/bukkit/craftbukkit/entity/CraftItemFrame.java | 6 ++---- .../org/bukkit/craftbukkit/inventory/CraftItemStack.java | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index e6958b0f8f..9183e61265 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -1,10 +1,9 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityItemFrame; -import net.minecraft.server.ItemStack; import org.apache.commons.lang.Validate; -import org.bukkit.Material; + import org.bukkit.Rotation; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -26,8 +25,7 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { } public org.bukkit.inventory.ItemStack getItem() { - ItemStack i = getHandle().i(); - return i == null ? new org.bukkit.inventory.ItemStack(Material.AIR) : CraftItemStack.asBukkitStack(i); + return CraftItemStack.asBukkitStack(getHandle().i()); } public Rotation getRotation() { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 5d5ae069dd..84b28a98e2 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -242,6 +242,9 @@ public class CraftItemStack extends ItemStack { * Copies the NMS stack to return as a strictly-Bukkit stack */ public static ItemStack asBukkitStack(net.minecraft.server.ItemStack original) { + if (original == null) { + return new ItemStack(Material.AIR); + } ItemStack stack = new ItemStack(original.id, original.count, (short) original.getData()); stack.addUnsafeEnchantments(getEnchantments(original)); return stack;