TF-EssentialsX/Essentials/src/com/earth2me/essentials/signs/SignFree.java

41 lines
1.2 KiB
Java
Raw Normal View History

package com.earth2me.essentials.signs;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.ShowInventory;
2011-11-14 10:11:23 +00:00
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class SignFree extends EssentialsSign
{
public SignFree()
{
super("Free");
}
@Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
getItemStack(sign.getLine(1), 1, ess);
return true;
}
@Override
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);
2011-11-14 10:11:23 +00:00
if (item.getType() == Material.AIR)
{
throw new SignException(_("cantSpawnItem", "Air"));
2011-11-14 10:11:23 +00:00
}
item.setAmount(item.getType().getMaxStackSize() * 9 * 4);
ShowInventory.showFilledInventory(player.getBase(), item);
2011-07-18 02:49:38 +00:00
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess);
return true;
}
}