Package com.sk89q.craftbook.util.exceptions

Examples of com.sk89q.craftbook.util.exceptions.FastCommandException


            key = context.getFlag('n');

        if(VariableManager.instance.hasVariable(context.getString(0), key)) {

            if(!RegexUtil.VARIABLE_KEY_PATTERN.matcher(context.getString(0)).find())
                throw new FastCommandException("Invalid Variable Name!");

            checkModifyPermissions(sender, key, context.getString(0));

            if(!RegexUtil.VARIABLE_VALUE_PATTERN.matcher(context.getString(1)).find())
                throw new FastCommandException("Invalid Variable Value!");

            String var = VariableManager.instance.getVariable(context.getString(0), key);
            try {

                double f = Double.parseDouble(var);
                if(f == 0)
                    throw new FastCommandException("Can't divide by 0!");
                f /= context.getDouble(1);
                var = String.valueOf(f);
                if (var.endsWith(".0"))
                    var = var.replace(".0", "");
            } catch (RuntimeException e) {
                throw e;
            } catch(Exception e) {
                throw new FastCommandException("Variable not of numeric type!");
            }
            VariableManager.instance.setVariable(context.getString(0), key, var);
            resetICCache(context.getString(0), key);
            sender.sendMessage(ChatColor.YELLOW + "Variable is now: " + var);
        } else
            throw new FastCommandException("Unknown Variable!");
    }
View Full Code Here


    @Command(aliases = {"edit"}, desc = "Edits the copied sign.", usage = "<Line> <Text>", min = 1, max = 2)
    public void editSign(CommandContext context, CommandSender sender) throws CommandException {

        if(SignCopier.signs == null)
            throw new FastCommandException("SignCopier mechanic is not enabled!");

        if(!(sender instanceof Player))
            throw new FastCommandException("This command can only be performed by a player!");

        if(!sender.hasPermission("craftbook.mech.signcopy.edit"))
            throw new CommandPermissionsException();

        if(!SignCopier.signs.containsKey(sender.getName()))
            throw new FastCommandException("You haven't copied a sign!");

        int line = context.getInteger(0, 0);
        String text = context.getString(1, "");

        String[] signCache = SignCopier.signs.get(sender.getName());
View Full Code Here

TOP

Related Classes of com.sk89q.craftbook.util.exceptions.FastCommandException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.