Search in sources :

Example 1 with NotEnoughArgumentsException

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

the class Commandspawn method run.

@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    if (args.length < 1) {
        throw new NotEnoughArgumentsException();
    }
    final User user = getPlayer(server, args, 0, true, false);
    respawn(sender, null, user, null);
    user.sendMessage(tl("teleportAtoB", Console.NAME, "spawn"));
}
Also used : User(com.earth2me.essentials.User) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException)

Example 2 with NotEnoughArgumentsException

use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by EssentialsX.

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)

Example 3 with NotEnoughArgumentsException

use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by EssentialsX.

the class Worth method getAmount.

public int getAmount(IEssentials ess, User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception {
    if (is == null || is.getType() == Material.AIR) {
        throw new Exception(tl("itemSellAir"));
    }
    int id = is.getTypeId();
    int amount = 0;
    if (args.length > 1) {
        try {
            amount = Integer.parseInt(args[1].replaceAll("[^0-9]", ""));
        } catch (NumberFormatException ex) {
            throw new NotEnoughArgumentsException(ex);
        }
        if (args[1].startsWith("-")) {
            amount = -amount;
        }
    }
    boolean stack = args.length > 1 && args[1].endsWith("s");
    boolean requireStack = ess.getSettings().isTradeInStacks(id);
    if (requireStack && !stack) {
        throw new Exception(tl("itemMustBeStacked"));
    }
    int max = 0;
    for (ItemStack s : user.getBase().getInventory().getContents()) {
        if (s == null || !s.isSimilar(is)) {
            continue;
        }
        max += s.getAmount();
    }
    if (stack) {
        amount *= is.getType().getMaxStackSize();
    }
    if (amount < 1) {
        amount += max;
    }
    if (requireStack) {
        amount -= amount % is.getType().getMaxStackSize();
    }
    if (amount > max || amount < 1) {
        if (!isBulkSell) {
            user.sendMessage(tl("itemNotEnough2"));
            user.sendMessage(tl("itemNotEnough3"));
            throw new Exception(tl("itemNotEnough1"));
        } else {
            return amount;
        }
    }
    return amount;
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException)

Example 4 with NotEnoughArgumentsException

use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by EssentialsX.

the class Commandxmppspy method run.

@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException {
    if (args.length < 1) {
        throw new NotEnoughArgumentsException();
    }
    final List<Player> matches = server.matchPlayer(args[0]);
    if (matches.isEmpty()) {
        sender.sendMessage("§cThere are no players matching that name.");
    }
    for (Player p : matches) {
        try {
            final boolean toggle = EssentialsXMPP.getInstance().toggleSpy(p);
            sender.sendMessage("XMPP Spy " + (toggle ? "enabled" : "disabled") + " for " + p.getDisplayName());
        } catch (Exception ex) {
            sender.sendMessage("Error: " + ex.getMessage());
        }
    }
}
Also used : Player(org.bukkit.entity.Player) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException)

Example 5 with NotEnoughArgumentsException

use of com.earth2me.essentials.commands.NotEnoughArgumentsException 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

NotEnoughArgumentsException (com.earth2me.essentials.commands.NotEnoughArgumentsException)8 ChargeException (com.earth2me.essentials.ChargeException)2 Trade (com.earth2me.essentials.Trade)2 User (com.earth2me.essentials.User)2 Commandrepair (com.earth2me.essentials.commands.Commandrepair)2 Player (org.bukkit.entity.Player)2 ItemStack (org.bukkit.inventory.ItemStack)2