Package net.bnubot.bot

Examples of net.bnubot.bot.EventHandler


     
    //Other plugins
    ArrayList<EventHandler> pluginEHs = new ArrayList<EventHandler>();
    if(plugins != null) {
      for(int i = 0; i < plugins.length; i++) {
        EventHandler eh = (EventHandler)Class.forName(plugins[i]).newInstance();
        pluginEHs.add(eh);
        primary.addEventHandler(eh);
      }
    }
   
    //CLI
    EventHandler cli = null;
    if(cs.enableCLI) {
      cli = new ConsoleEventHandler();
      primary.addEventHandler(cli);
    }
   
    //GUI
    EventHandler gui = null;
    if(cs.enableGUI) {
      gui = new GuiEventHandler();
      primary.addEventHandler(gui);
    }
   
    //Bot
    EventHandler cmd = null;
    if(cs.enableCommands) {
      String db_driver = Settings.read("database", "driver", "org.apache.derby.jdbc.EmbeddedDriver");
      String db_url = Settings.read("database", "url", "jdbc:derby:database;create=true");
      String db_username = Settings.read("database", "username", null);
      String db_password = Settings.read("database", "password", null);
      String db_schema = Settings.read("database", "schema", "schema.derby");
     
      if((db_driver == null)
      || (db_url == null)) {
        if(gui != null)
          primary.recieveInfo("Database is not configured; disabling commands.");
        else
          Out.info("main", "Database is not configured; disabling commands.");
      } else {
        try {
          new Database(db_driver, db_url, db_username, db_password, db_schema);
          BNetUser.setDatabase();
          cmd = new CommandEventHandler();
          primary.addEventHandler(cmd);
         
          Settings.write("database", "driver", db_driver);
          Settings.write("database", "url", db_url);
          Settings.write("database", "username", db_username);
          Settings.write("database", "password", db_password);
          Settings.write("database", "schema", db_schema);
        } catch(Exception e) {
          e.printStackTrace();
          String msg = "Failed to initialize the database; commands will be disabled.\n" + e.getMessage();
          if(gui != null)
            primary.recieveError(msg);
          else
            Out.error("Main", msg);
        }
      }
    }
   
    //Trivia
    if(cs.enableTrivia) {
      EventHandler trivia = new TriviaEventHandler();
      primary.addEventHandler(trivia);
    }
   
    try {
      VersionCheck.checkVersion(primary);
View Full Code Here

TOP

Related Classes of net.bnubot.bot.EventHandler

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.