Prevent client crash on 'Free air'

This commit is contained in:
KHobbits 2011-11-14 10:11:23 +00:00
parent cd897890be
commit b619a54105

View File

@ -4,7 +4,9 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import net.minecraft.server.InventoryPlayer;
import org.bukkit.Material;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.inventory.ItemStack;
@ -27,6 +29,11 @@ public class SignFree extends EssentialsSign
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
final ItemStack item = getItemStack(sign.getLine(1), 1, ess);
if (item.getType() == Material.AIR)
{
throw new SignException(Util.format("cantSpawnItem", "Air"));
}
item.setAmount(item.getType().getMaxStackSize()*9*4);
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
inv.clear();