Пример #1
0
  @Override
  public void onEnable() {
    plugin = this;

    setupConfigs();
    try {
      if (!configuration.isDebugEnabled()) {
        disableDatabaseLogging();
      }

      if (!setupConnections()) {
        return;
      }

      setupStorages();
    } catch (SQLException e) {
      getLogger()
          .warning(
              "An error occurred attempting to make a database connection, please see stack trace below");
      plugin.getPluginLoader().disablePlugin(this);
      e.printStackTrace();
      return;
    }

    try {
      long timeDiff = DateUtils.findTimeDiff();

      if (timeDiff > 1) {
        getLogger()
            .severe(
                "The time on your server and MySQL database are out by "
                    + timeDiff
                    + " seconds, this may cause syncing issues.");
      }
    } catch (SQLException e) {
      getLogger()
          .warning(
              "An error occurred attempting to find the time difference, please see stack trace below");
      plugin.getPluginLoader().disablePlugin(this);
      e.printStackTrace();
    }

    if (conversionConn != null) {
      setupConversion();
    }

    setupListeners();
    setupCommands();
    setupRunnables();

    try {
      MetricsLite metrics = new MetricsLite(this);
      metrics.start();
    } catch (IOException e) {
      // Failed to submit the stats :-(
    }
  }
Пример #2
0
  private void setupConversion() {
    getLogger().info("Running pre-conversion launch checks");
    ConvertDatabaseConfig conversionDb = configuration.getConversionDb();

    if (configuration.getLocalDb().getHost().equals(conversionDb.getHost())
        && configuration.getLocalDb().getName().equals(conversionDb.getName())) {
      if (!conversionChecks()) {
        return;
      }
    }

    // Begin the converting
    getLogger()
        .info("Conversion will begin shortly. You have 30 seconds to kill the process to abort.");
    try {
      Thread.sleep(30000L);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    getLogger().info("Launching conversion process");
    new UUIDConvert(conversionConn);
  }
Пример #3
0
  @Override
  public void setupListeners() {
    new JoinListener().register();
    new ChatListener().register();
    new CommandListener().register();
    new HookListener().register();

    if (configuration.isDisplayNotificationsEnabled()) {
      new BanListener().register();
      new MuteListener().register();
      new NoteListener().register();
      new ReportListener().register();
    }
  }
Пример #4
0
  @Override
  public void setupConfigs() {
    new MessagesConfig().load();

    configuration = new DefaultConfig();
    configuration.load();

    consoleConfig = new ConsoleConfig();
    consoleConfig.load();

    schedulesConfig = new SchedulesConfig();
    schedulesConfig.load();

    exemptionsConfig = new ExemptionsConfig();
    exemptionsConfig.load();

    reasonsConfig = new ReasonsConfig();
    reasonsConfig.load();

    geoIpConfig = new GeoIpConfig();
    geoIpConfig.load();
  }
Пример #5
0
  public boolean setupConnections() throws SQLException {
    if (!configuration.getLocalDb().isEnabled()) {
      getLogger().warning("Local Database is not enabled, disabling plugin");
      plugin.getPluginLoader().disablePlugin(this);
      return false;
    }

    localConn = setupConnection(configuration.getLocalDb());

    if (configuration.getConversionDb().isEnabled()) {
      conversionConn = setupConnection(configuration.getConversionDb());
    }

    if (configuration.getExternalDb().isEnabled()) {
      externalConn = setupConnection(configuration.getExternalDb());
    }

    return true;
  }
Пример #6
0
  private boolean conversionChecks() {
    ConvertDatabaseConfig conversionDb = configuration.getConversionDb();

    if (playerStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("playerIpsTable"))) {
      getLogger().severe("players table equals playerIpsTable, aborting");
      return false;
    }

    if (playerBanStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("bansTable"))) {
      getLogger().severe("playerBans table equals bansTable, aborting");
      return false;
    }

    if (playerBanRecordStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("bansRecordTable"))) {
      getLogger().severe("playerBanRecords table equals bansRecordTable, aborting");
      return false;
    }

    if (playerMuteStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("mutesTable"))) {
      getLogger().severe("playerMutes table equals mutesTable, aborting");
      return false;
    }

    if (playerMuteRecordStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("mutesRecordTable"))) {
      getLogger().severe("playerMuteRecords table equals mutesRecordTable, aborting");
      return false;
    }

    if (playerKickStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("kicksTable"))) {
      getLogger().severe("playerKicks table equals kicksTable, aborting");
      return false;
    }

    if (playerWarnStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("warningsTable"))) {
      getLogger().severe("playerWarnings table equals warningsTable, aborting");
      return false;
    }

    if (ipBanStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("ipBansTable"))) {
      getLogger().severe("ipBans table equals ipBansTable, aborting");
      return false;
    }

    if (ipBanRecordStorage
        .getTableInfo()
        .getTableName()
        .equals(conversionDb.getTableName("ipBansRecordTable"))) {
      getLogger().severe("ipBanRecords table equals ipBansRecordTable, aborting");
      return false;
    }

    return true;
  }