@Override
 public void onDisable() {
   getLogger().log(Level.INFO, "Disabling...");
   getConfig().save();
   try {
     db.close();
   } catch (ConnectionException e) {
     e.printStackTrace();
   }
   server.interrupt();
   server = null;
   getLogger().log(Level.INFO, "Successfully disabled!");
   instance = null;
 }
  @Override
  public void onEnable() {
    instance = this;
    getLogger().log(Level.INFO, "Enabling...");

    MySQLConfiguration dbConfig = new MySQLConfiguration();
    dbConfig.setHost(getConfig().getString("database.mysql.host", "127.0.0.1"));
    dbConfig.setPort(getConfig().getInt("database.mysql.port", MySQLConstants.DefaultPort));
    dbConfig.setDatabase(getConfig().getString("database.mysql.database"));
    dbConfig.setUser(getConfig().getString("database.mysql.user", MySQLConstants.DefaultUser));
    dbConfig.setPassword(
        getConfig().getString("database.mysql.password", MySQLConstants.DefaultPass));

    db = DatabaseFactory.createNewDatabase(dbConfig);

    try {
      db.registerTable(CommitChannel.class);
      db.registerTable(CommitAuthor.class);
    } catch (TableRegistrationException e) {
      e.printStackTrace();
    }

    try {
      db.connect();
    } catch (ConnectionException e) {
      e.printStackTrace();
    }

    ShortUrlService.setService(
        ShortUrlService.Service.valueOf(
            config.getString("short-url.type", "BIT_LY").toUpperCase()));
    ShortUrlService.setUser(config.getString("short-url.user", null));
    ShortUrlService.setApiKey(config.getString("short-url.apikey", null));

    server = new Server(config.getInt("listen-port", 5555));
    server.start();

    getCyborg()
        .getCommandManager()
        .registerCommands(this, CommitCommands.class, new EmptyConstructorInjector());

    getLogger().log(Level.INFO, "Successfully enabled!");
  }