2011-06-08 01:18:33 +00:00
|
|
|
package com.earth2me.essentials.signs;
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
|
|
|
import com.earth2me.essentials.IEssentials;
|
|
|
|
import com.earth2me.essentials.Trade;
|
|
|
|
import com.earth2me.essentials.User;
|
2011-11-14 10:11:23 +00:00
|
|
|
import org.bukkit.Material;
|
2012-03-01 15:15:37 +00:00
|
|
|
import org.bukkit.inventory.Inventory;
|
2011-06-08 01:18:33 +00:00
|
|
|
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
|
|
|
|
{
|
2011-07-16 01:51:12 +00:00
|
|
|
getItemStack(sign.getLine(1), 1, ess);
|
2011-06-08 01:18:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
|
|
|
{
|
2011-07-16 01:51:12 +00:00
|
|
|
final ItemStack item = getItemStack(sign.getLine(1), 1, ess);
|
2011-11-14 10:11:23 +00:00
|
|
|
if (item.getType() == Material.AIR)
|
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
throw new SignException(_("cantSpawnItem", "Air"));
|
2011-11-14 10:11:23 +00:00
|
|
|
}
|
|
|
|
|
2012-03-23 20:15:03 +00:00
|
|
|
item.setAmount(item.getType().getMaxStackSize());
|
|
|
|
Inventory invent = ess.getServer().createInventory(player, 36);
|
|
|
|
for (int i = 0; i < 36; i++) {
|
|
|
|
invent.addItem(item);
|
|
|
|
}
|
|
|
|
player.openInventory(invent);
|
2011-07-18 02:49:38 +00:00
|
|
|
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess);
|
2011-06-08 01:18:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|