Search in sources :

Example 1 with Commandrepair

use of com.earth2me.essentials.commands.Commandrepair in project Essentials by drtshock.

the class SignRepair method onSignInteract.

@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
    final Trade charge = getTrade(sign, 2, ess);
    charge.isAffordableFor(player);
    Commandrepair command = new Commandrepair();
    command.setEssentials(ess);
    try {
        if (sign.getLine(1).equalsIgnoreCase("hand")) {
            command.repairHand(player);
        } else if (sign.getLine(1).equalsIgnoreCase("all")) {
            command.repairAll(player);
        } else {
            throw new NotEnoughArgumentsException();
        }
    } catch (Exception ex) {
        throw new SignException(ex.getMessage(), ex);
    }
    charge.charge(player);
    Trade.log("Sign", "Repair", "Interact", username, null, username, charge, sign.getBlock().getLocation(), ess);
    return true;
}
Also used : Trade(com.earth2me.essentials.Trade) Commandrepair(com.earth2me.essentials.commands.Commandrepair) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException) ChargeException(com.earth2me.essentials.ChargeException)

Aggregations

ChargeException (com.earth2me.essentials.ChargeException)1 Trade (com.earth2me.essentials.Trade)1 Commandrepair (com.earth2me.essentials.commands.Commandrepair)1 NotEnoughArgumentsException (com.earth2me.essentials.commands.NotEnoughArgumentsException)1