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

48 lines
1.1 KiB
Java
Raw Normal View History

2011-07-20 16:20:12 +00:00
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.commands.Commandspawnmob;
public class SignSpawnmob extends EssentialsSign
{
public SignSpawnmob()
{
super("Spawnmob");
}
@Override
protected boolean onSignCreate(ISign sign, User player, String username, IEssentials ess) throws SignException, ChargeException
{
validateInteger(sign, 1);
validateTrade(sign, 3, ess);
return true;
}
@Override
protected boolean onSignInteract(ISign sign, User player, String username, IEssentials ess) throws SignException, ChargeException
{
final Trade charge = getTrade(sign, 3, ess);
charge.isAffordableFor(player);
Commandspawnmob command = new Commandspawnmob();
command.setEssentials(ess);
String[] args = new String[]
{
2011-07-20 16:20:12 +00:00
sign.getLine(2), sign.getLine(1)
};
try
{
command.run(ess.getServer(), player, "spawnmob", args);
}
catch (Exception ex)
{
throw new SignException(ex.getMessage(), ex);
}
charge.charge(player);
return true;
}
}