java.lang.Object
com.kamikazejam.kamicommon.configuration.spigot.ConfigHelper

public class ConfigHelper extends Object
This is a utility class for creating and saving configurations in a JavaPlugin
  • Constructor Details

    • ConfigHelper

      public ConfigHelper()
  • Method Details

    • createConfig

      public static FileConfiguration createConfig(Plugin plugin, String fileName)
      Returns a new configuration after creating and saving the file (does not load defaults)
      Parameters:
      plugin - The JavaPlugin to grab the datafolder from
      fileName - The name of the file for the new configuration
      Returns:
      The FileConfiguration which was created and saved to file
    • createConfig

      public static FileConfiguration createConfig(Plugin plugin, File dataFolder, String fileName)
      Returns a new configuration after creating and saving the file (does not load defaults)
      Parameters:
      plugin - The JavaPlugin for logging
      dataFolder - The datafolder to put the config file in
      fileName - The name of the file for the new configuration
      Returns:
      The FileConfiguration which was created and saved to file
    • createConfig

      public static FileConfiguration createConfig(Plugin plugin, File dataFolder, String fileName, boolean defaultsFromResource)
      Returns a new configuration after creating and saving the file
      Parameters:
      plugin - The JavaPlugin to grab the datafolder from
      fileName - The name of the file for the new configuration
      defaultsFromResource - Whether to load defaults from the jar resources folder
      Returns:
      The FileConfiguration which was created and saved to file
    • saveConfig

      public static FileConfiguration saveConfig(Plugin plugin, FileConfiguration config, String fileName)
      Saves a config to a file, returns only for chaining purposes
      Parameters:
      plugin - The JavaPlugin to get the datafolder for
      config - The configuration to save to file
      fileName - The name of the file to save to
    • saveConfig

      public static FileConfiguration saveConfig(Plugin plugin, File dataFolder, FileConfiguration config, String fileName)
      Saves a config to a file, returns only for chaining purposes
      Parameters:
      plugin - The JavaPlugin for logging
      dataFolder - The datafolder to save the file in
      config - The configuration to save to file
      fileName - The name of the file to save to
    • reloadConfig

      public static FileConfiguration reloadConfig(Plugin plugin, String fileName)
      Reloads a config object from a file, make sure to set a variable for the returned configuration
      Parameters:
      plugin - The JavaPlugin to get the datafolder for
      fileName - The name of the file to grab
      Returns:
      The same config object for chaining
    • createPluginFile

      public static File createPluginFile(Plugin plugin, String folder, String fileName)
      Creates an empty plugin file at a specified path with a specified name