2011-06-08 01:18:33 +00:00
|
|
|
package com.earth2me.essentials.signs;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.IEssentials;
|
2011-07-16 01:51:12 +00:00
|
|
|
import com.earth2me.essentials.InventoryWorkaround;
|
|
|
|
import com.earth2me.essentials.Trade;
|
2011-06-08 01:18:33 +00:00
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
import net.minecraft.server.InventoryPlayer;
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
|
|
|
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);
|
|
|
|
item.setAmount(item.getType().getMaxStackSize()*9*4);
|
2011-06-08 01:18:33 +00:00
|
|
|
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
|
|
|
|
inv.clear();
|
2011-07-16 01:51:12 +00:00
|
|
|
InventoryWorkaround.addItem(inv, true, item);
|
2011-06-08 01:18:33 +00:00
|
|
|
player.showInventory(inv);
|
2011-07-16 01:51:12 +00:00
|
|
|
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), ess);
|
2011-06-08 01:18:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|