コード例 #1
0
 /**
  * Method for loading the configuration from disk. First we get the config object from disk, than
  * we read in the standard configuration part. We also log a message if #debugLogEnabled and we
  * produce some debug logs. After that we load the custom configuration part #loadCustomConfig()
  *
  * @see #loadCustomConfig()
  */
 void loadConfig() {
   // Starting to update the standard configuration
   configVer = config.getString("configVer");
   // Debug OutPut NOW!
   attackControlLogger.debug("configCurrent", configCurrent);
   attackControlLogger.debug("configVer", configVer);
   loadCustomConfig();
   attackControlLogger.info("Configuration v." + configVer + " loaded.");
 }
コード例 #2
0
  /**
   * Method for writing the configuration file. First we write the standard configuration part, than
   * we write the custom configuration part via #writeCustomConfig()
   *
   * @return true if writing the config was successful
   * @see #writeCustomConfig(java.io.PrintWriter)
   */
  public boolean writeConfig() {
    attackControlLogger.debug("creating config");
    boolean success = false;
    try {
      PrintWriter stream;
      File folder = main.getDataFolder();
      if (folder != null) {
        folder.mkdirs();
      }
      PluginDescriptionFile pdfFile = main.getDescription();
      stream = new PrintWriter(pluginPath + configFile);
      attackControlLogger.debug("starting contents");
      // Let's write our config ;)
      stream.println(
          "# "
              + pdfFile.getName()
              + " "
              + pdfFile.getVersion()
              + " by "
              + pdfFile.getAuthors().toString());
      stream.println("#");
      stream.println("# Configuration File for module [" + MODULE_NAME + "]");
      stream.println("#");
      stream.println("# For detailed assistance please visit: " + mainConfig.getPluginSlug());
      stream.println();
      stream.println("# Configuration Version");
      stream.println("configVer: \"" + configVer + "\"");
      stream.println();
      // Getting the custom config information from the top of the class
      attackControlLogger.debug("going for customConfig");
      writeCustomConfig(stream);

      stream.println();

      stream.close();

      success = true;

    } catch (FileNotFoundException e) {
      attackControlLogger.warning("Error saving the " + configFile + ".");
    }

    return success;
  }
コード例 #3
0
 /**
  * Method to write and create the default configuration. The custom configuration variables are
  * added via #setupCustomDefaultVariables() Than we write the configuration to disk #writeConfig()
  * Than we get the config object from disk We are adding the default configuration for the
  * variables and load the defaults for the custom variables #customDefaultConfig()
  *
  * @see #setupCustomDefaultVariables()
  * @see #customDefaultConfig()
  */
 private void defaultConfig() {
   setupCustomDefaultVariables();
   if (!writeConfig()) {
     attackControlLogger.severe("Problems writing default config!");
     attackControlLogger.info("Using internal Defaults!");
   } else {
     attackControlLogger.debug("DefaultConfig written");
   }
   config.addDefault("configVer", configVer);
 }