Class ConfigManager

java.lang.Object
com.github.pinont.singularitylib.api.manager.ConfigManager

public class ConfigManager extends Object
Manages configuration files for the plugin. This class provides functionality to create, load, save, and manipulate YAML configuration files.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConfigManager(org.bukkit.plugin.Plugin plugin, String fileName)
    Creates a ConfigManager for a configuration file in the plugin's data folder.
    ConfigManager(org.bukkit.plugin.Plugin plugin, String subFolder, String fileName)
    Creates a ConfigManager for a configuration file in a specific subfolder.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String path)
    Gets a value from the specified path in the configuration.
    org.bukkit.configuration.file.FileConfiguration
    Gets the FileConfiguration instance.
    static boolean
    isExists(org.bukkit.plugin.Plugin plugin, String subFolder, String fileName)
    Checks if a configuration file exists in a specific subfolder.
    boolean
    Checks if this is the first time the configuration file is being loaded.
    void
    Reloads the configuration from disk.
    void
    Saves the configuration to the file.
    void
    set(String path, Object value)
    Sets a value at the specified path in the configuration.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigManager

      public ConfigManager(org.bukkit.plugin.Plugin plugin, String fileName)
      Creates a ConfigManager for a configuration file in the plugin's data folder.
      Parameters:
      fileName - the name of the configuration file
    • ConfigManager

      public ConfigManager(org.bukkit.plugin.Plugin plugin, String subFolder, String fileName)
      Creates a ConfigManager for a configuration file in a specific subfolder.
      Parameters:
      subFolder - the subfolder where the configuration file should be located
      fileName - the name of the configuration file
  • Method Details

    • isExists

      public static boolean isExists(org.bukkit.plugin.Plugin plugin, String subFolder, String fileName)
      Checks if a configuration file exists in a specific subfolder.
      Parameters:
      subFolder - the subfolder to check in
      fileName - the name of the configuration file
      Returns:
      true if the file exists, false otherwise
    • set

      public void set(String path, Object value)
      Sets a value at the specified path in the configuration.
      Parameters:
      path - the configuration path
      value - the value to set
    • get

      public Object get(String path)
      Gets a value from the specified path in the configuration.
      Parameters:
      path - the configuration path
      Returns:
      the value at the specified path, or null if not found
    • saveConfig

      public void saveConfig()
      Saves the configuration to the file. This method writes all changes made to the configuration back to the file.
    • getConfig

      public org.bukkit.configuration.file.FileConfiguration getConfig()
      Gets the FileConfiguration instance.
      Returns:
      the FileConfiguration instance, or null if there was an error loading
    • reloadConfig

      public void reloadConfig()
      Reloads the configuration from disk.

      Useful when the file is manually modified while the server is running.

    • isFirstLoad

      public boolean isFirstLoad()
      Checks if this is the first time the configuration file is being loaded.
      Returns:
      true if this is the first load (file was just created), false otherwise