1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-05 06:07:54 +02:00

Prevent client crash on 'Free air'

This commit is contained in:
KHobbits
2011-11-14 10:11:23 +00:00
parent f98039a415
commit 0eaae89739

View File

@@ -4,7 +4,9 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.InventoryWorkaround; import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import net.minecraft.server.InventoryPlayer; import net.minecraft.server.InventoryPlayer;
import org.bukkit.Material;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.inventory.ItemStack; 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 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); 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); item.setAmount(item.getType().getMaxStackSize()*9*4);
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle())); final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
inv.clear(); inv.clear();