Package de.kilobyte22.optionparse

Examples of de.kilobyte22.optionparse.OptionSet


                //return tmp;
            }
        }
    }
    public void setPermissions(String nick, HashMap<String, Boolean> perms) {
        Database database = bot.database;
        String tmpperms = "";
        for(String key : perms.keySet()) {
            if (!tmpperms.equals("")) tmpperms += ";";
            if (perms.get(key) != null) tmpperms += key + "=" + (perms.get(key) ? "true" : "false");
        }
        logger.log(tmpperms);
        try {
            if (bot.useYaml) {
                HashMap<String, String> perms_ = bot.yamlEngine.load(new File("permissions.yaml"));
                perms_.put(nick, tmpperms);
                bot.yamlEngine.writeYaml(new File("permissions.yaml"), perms_);
            } else {
                PreparedStatement s = database.prepareStatement("SELECT * FROM permissions WHERE server = ? AND nickserv = ?");
                s.setString(1, bot.getServer());
                s.setString(2, nick);
                try {
                    //s.executeQuery().next();
                    s = database.prepareStatement("UPDATE permissions SET permissions=? WHERE server = ? AND nickserv = ?");
                    s.setString(1, tmpperms);
                    s.setString(2, bot.getServer());
                    s.setString(3, nick);
                    if (!s.execute())
                        throw new Exception("");
                    logger.log(s.toString());
                } catch (Exception ex) {
                    //logger.log(ex);
                    //s.executeQuery().next();
                    s = database.prepareStatement("INSERT INTO permissions (server, nickserv, permissions) VALUES (?, ?, ?)");
                    s.setString(1, bot.getServer());
                    s.setString(2, nick);
                    s.setString(3, tmpperms);
                    s.execute();
                }
View Full Code Here


        eventBusLock.setLockState(true); // BAM
        eventBusLock.setFrozen(true);

        permissionSystem = bot.permissionSystem;
        nickservSystem = bot.nickservSystem;
        commandManager = new CommandManager(bot.commandManager);
        commandManager.setEnabled(false);

        config = new Configuration(new File("config/" + plugin.getName() + ".cfg"));
        logger = new Logger("PLUGIN/" + plugin.getName());
    }
View Full Code Here

        botAccess.commandManager.setEnabled(true);
    }

    public void disable() {
        enabled = false;
        eventBus.postLocal(new DisableEvent());
        eventBus.post(new PluginDisableEvent());
        botAccess.commandManager.setEnabled(false);
    }
View Full Code Here

        this.eventBus = eventBus;
    }

    public void enable() {
        enabled = true;
        eventBus.postLocal(new EnableEvent());
        eventBus.post(new PluginEnableEvent(name));
        botAccess.commandManager.setEnabled(true);
    }
View Full Code Here

    }

    public void disable() {
        enabled = false;
        eventBus.postLocal(new DisableEvent());
        eventBus.post(new PluginDisableEvent());
        botAccess.commandManager.setEnabled(false);
    }
View Full Code Here

    }

    public void enable() {
        enabled = true;
        eventBus.postLocal(new EnableEvent());
        eventBus.post(new PluginEnableEvent(name));
        botAccess.commandManager.setEnabled(true);
    }
View Full Code Here

            } catch (PluginAlreadyLoadedException e) {
                e.printStackTrace();
            }
        }

        eventBus.post(new RehashEvent(user));
        config.save();
        logger.log("Rehash done.");
        return res;
    }
View Full Code Here

        if (clazz == null) {
            try {
                bot.pluginManager.load(args.getOrError(1));
                print("Done.");
            } catch (PluginNotFoundException e) {
                throw new CommandException("Unknown Plugin");
            } catch (InvalidPluginException e) {
                throw new CommandException("Invalid Plugin:" + e.getMessage());
            } catch (ClassNotFoundException e) {
                throw new CommandException("Plugin Class not found");
            } catch (IOException e) {
                throw new CommandException("IOException: " + e.getMessage());
            } catch (InstantiationException e) {
                throw new CommandException("Could not create plugin: " + e.getMessage());
            } catch (IllegalAccessException e) {
                throw new CommandException("Constructor was private");
            } catch (PluginAlreadyLoadedException e) {
                throw new CommandException("Plugin already loaded");
            }
        } else {
            try {
                bot.pluginManager.loadInternal(clazz, args.getOrError(1));
                if (args.getNamedParam('n') == null && args.getNamedParam("noenable") == null)
                    bot.pluginManager.enable(args.getOrError(1));
                print("Done.");
            } catch (IllegalAccessException e) {
                throw new CommandException("Could not access constructor for Plugin");
            } catch (InstantiationException e) {
                throw new CommandException("Could not create new Plugin");
            } catch (ClassNotFoundException e) {
                throw new CommandException("Invalid Class");
            } catch (PluginAlreadyLoadedException e) {
                throw new CommandException("Plugin already loaded");
            } catch (InvalidPluginException e) {
                throw new CommandException("Invalid plugin: " + e.getMessage());
            } catch (PluginNotFoundException e) {
                throw new CommandException("Plugin does not exist");
            }
        }
    }
View Full Code Here

    public void enable() {
        try {
            bot.pluginManager.enable(args.getOrError(1));
            print("Done.");
        } catch (PluginNotFoundException e) {
            throw new CommandException("Plugin not found");
        }
    }
View Full Code Here

    public void disable() {
        try {
            bot.pluginManager.disable(args.getOrError(1));
            print("Done.");
        } catch (PluginNotFoundException e) {
            throw new CommandException("Plugin not found");
        }
    }
View Full Code Here

TOP

Related Classes of de.kilobyte22.optionparse.OptionSet

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.