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!");
            VariableManager.instance.setVariable(context.getString(0), key, context.getString(1));
            resetICCache(context.getString(0), key);
            sender.sendMessage(ChatColor.YELLOW + "Variable is now: " + VariableManager.instance.getVariable(context.getString(0), key));
        } else
            throw new FastCommandException("Unknown Variable!");
    }
View Full Code Here


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

            if(!hasVariablePermission(sender, key, context.getString(0), "define"))
                throw new CommandPermissionsException();
            if(!RegexUtil.VARIABLE_KEY_PATTERN.matcher(context.getString(0)).find())
                throw new FastCommandException("Invalid Variable Name!");
            if(!RegexUtil.VARIABLE_VALUE_PATTERN.matcher(context.getString(1)).find())
                throw new FastCommandException("Invalid Variable Value!");
            VariableManager.instance.setVariable(context.getString(0), key, context.getString(1));
            resetICCache(context.getString(0), key);
            sender.sendMessage(ChatColor.YELLOW + "Variable is now: " + VariableManager.instance.getVariable(context.getString(0), key));
        } else
            throw new FastCommandException("Existing Variable!");
    }
View Full Code Here

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

            if(!hasVariablePermission(sender, key, context.getString(0), "get"))
                throw new CommandPermissionsException();
            if(!RegexUtil.VARIABLE_KEY_PATTERN.matcher(context.getString(0)).find())
                throw new FastCommandException("Invalid Variable Name!");
            sender.sendMessage(ChatColor.YELLOW + context.getString(0) + ": " + VariableManager.instance.getVariable(context.getString(0), key));
        } else
            throw new FastCommandException("Unknown Variable!");
    }
View Full Code Here

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

            if(!hasVariablePermission(sender, key, context.getString(0), "erase"))
                throw new CommandPermissionsException();
            if(!RegexUtil.VARIABLE_KEY_PATTERN.matcher(context.getString(0)).find())
                throw new FastCommandException("Invalid Variable Name!");
            VariableManager.instance.removeVariable(context.getString(0), key);
            resetICCache(context.getString(0), key);
            sender.sendMessage(ChatColor.YELLOW + "Removed variable: " + context.getString(0));
        } else
            throw new FastCommandException("Unknown Variable!");
    }
View Full Code Here

            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!");
            VariableManager.instance.setVariable(context.getString(0), key, VariableManager.instance.getVariable(context.getString(0), key) + context.getString(1));
            resetICCache(context.getString(0), key);
            sender.sendMessage(ChatColor.YELLOW + "Variable is now: " + VariableManager.instance.getVariable(context.getString(0), key));
        } else
            throw new FastCommandException("Unknown Variable!");
    }
View Full Code Here

            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!");
            VariableManager.instance.setVariable(context.getString(0), key, context.getString(1) + VariableManager.instance.getVariable(context.getString(0), key));
            resetICCache(context.getString(0), key);
            sender.sendMessage(ChatColor.YELLOW + "Variable is now: " + VariableManager.instance.getVariable(context.getString(0), key));
        } else
            throw new FastCommandException("Unknown Variable!");
    }
View Full Code Here

            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));

            String var = VariableManager.instance.getVariable(context.getString(0), key);
            if(var.equalsIgnoreCase("0") || var.equalsIgnoreCase("1"))
                var = var.equalsIgnoreCase("1") ? "0" : "1";
            else if(var.equalsIgnoreCase("true") || var.equalsIgnoreCase("false"))
                var = var.equalsIgnoreCase("true") ? "false" : "true";
            else if(var.equalsIgnoreCase("yes") || var.equalsIgnoreCase("no"))
                var = var.equalsIgnoreCase("yes") ? "no" : "yes";
            else
                throw new FastCommandException("Variable not of boolean 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

            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);
                f += context.getDouble(1);
                var = String.valueOf(f);
                if (var.endsWith(".0"))
                    var = var.replace(".0", "");
            } 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

            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);
                f -= context.getDouble(1);
                var = String.valueOf(f);
                if (var.endsWith(".0"))
                    var = var.replace(".0", "");
            } 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

            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);
                f *= context.getDouble(1);
                var = String.valueOf(f);
                if (var.endsWith(".0"))
                    var = var.replace(".0", "");
            } 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

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.