Search in sources :

Example 1 with NoChargeException

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

the class SignKit method onSignInteract.

@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
    final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim();
    final String group = sign.getLine(2).trim();
    if ((!group.isEmpty() && ("ยง2Everyone".equals(group) || player.inGroup(group))) || (group.isEmpty() && (player.isAuthorized("essentials.kits." + kitName)))) {
        final Trade charge = getTrade(sign, 3, ess);
        charge.isAffordableFor(player);
        try {
            final Kit kit = new Kit(kitName, ess);
            kit.checkDelay(player);
            kit.setTime(player);
            kit.expandItems(player);
            charge.charge(player);
            Trade.log("Sign", "Kit", "Interact", username, null, username, charge, sign.getBlock().getLocation(), ess);
        } catch (NoChargeException ex) {
            return false;
        } catch (Exception ex) {
            throw new SignException(ex.getMessage(), ex);
        }
        return true;
    } else {
        if (group.isEmpty()) {
            throw new SignException(tl("noKitPermission", "essentials.kits." + kitName));
        } else {
            throw new SignException(tl("noKitGroup", group));
        }
    }
}
Also used : Trade(com.earth2me.essentials.Trade) NoChargeException(com.earth2me.essentials.commands.NoChargeException) Kit(com.earth2me.essentials.Kit) NoChargeException(com.earth2me.essentials.commands.NoChargeException) ChargeException(com.earth2me.essentials.ChargeException)

Example 2 with NoChargeException

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

the class MessagingTest method runCommand.

private void runCommand(String command, User user, String[] args) throws Exception {
    IEssentialsCommand cmd;
    try {
        cmd = (IEssentialsCommand) Essentials.class.getClassLoader().loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
        cmd.setEssentials(ess);
        cmd.run(server, user, command, null, args);
    } catch (NoChargeException ex) {
    }
}
Also used : NoChargeException(com.earth2me.essentials.commands.NoChargeException) IEssentialsCommand(com.earth2me.essentials.commands.IEssentialsCommand)

Example 3 with NoChargeException

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

the class MessagingTest method runConsoleCommand.

private void runConsoleCommand(String command, String[] args) throws Exception {
    IEssentialsCommand cmd;
    CommandSender sender = server.getConsoleSender();
    try {
        cmd = (IEssentialsCommand) Essentials.class.getClassLoader().loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
        cmd.setEssentials(ess);
        cmd.run(server, new CommandSource(sender), command, null, args);
    } catch (NoChargeException ex) {
    }
}
Also used : NoChargeException(com.earth2me.essentials.commands.NoChargeException) IEssentialsCommand(com.earth2me.essentials.commands.IEssentialsCommand) CommandSender(org.bukkit.command.CommandSender)

Example 4 with NoChargeException

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

the class ToggleTest method runConsoleCommand.

private void runConsoleCommand(String command, String[] args) throws Exception {
    IEssentialsCommand cmd;
    CommandSender sender = server.getConsoleSender();
    try {
        cmd = (IEssentialsCommand) Essentials.class.getClassLoader().loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
        cmd.setEssentials(ess);
        cmd.run(server, new CommandSource(sender), command, null, args);
    } catch (NoChargeException ex) {
    }
}
Also used : NoChargeException(com.earth2me.essentials.commands.NoChargeException) IEssentialsCommand(com.earth2me.essentials.commands.IEssentialsCommand) CommandSender(org.bukkit.command.CommandSender)

Example 5 with NoChargeException

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

the class EconomyTest method runCommand.

private void runCommand(String command, User user, String[] args) throws Exception {
    IEssentialsCommand cmd;
    try {
        cmd = (IEssentialsCommand) Essentials.class.getClassLoader().loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
        cmd.setEssentials(ess);
        cmd.run(server, user, command, null, args);
    } catch (NoChargeException ex) {
    }
}
Also used : NoChargeException(com.earth2me.essentials.commands.NoChargeException) IEssentialsCommand(com.earth2me.essentials.commands.IEssentialsCommand)

Aggregations

NoChargeException (com.earth2me.essentials.commands.NoChargeException)16 IEssentialsCommand (com.earth2me.essentials.commands.IEssentialsCommand)12 CommandSender (org.bukkit.command.CommandSender)6 Trade (com.earth2me.essentials.Trade)4 ChargeException (com.earth2me.essentials.ChargeException)2 Kit (com.earth2me.essentials.Kit)2 User (com.earth2me.essentials.User)2