Class ConfigUtils

java.lang.Object
me.despical.commons.configuration.ConfigUtils

public class ConfigUtils extends Object
Author:
Despical

Created at 30.05.2020

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.configuration.file.FileConfiguration
    getConfig(org.bukkit.plugin.java.JavaPlugin plugin, String fileName)
    Get the config file's configuration
    static org.bukkit.configuration.file.FileConfiguration
    getConfigFromResources(org.bukkit.plugin.java.JavaPlugin plugin, String fileName)
    Get the config file's configuration, gets the file from the resources.
    static void
    saveConfig(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.configuration.file.FileConfiguration config, String name)
    Save specified config file.
    static void
    writeAndSave(org.bukkit.plugin.java.JavaPlugin plugin, String fileName, Consumer<org.bukkit.configuration.file.FileConfiguration> configConsumer)
    Retrieves, modifies, and saves a configuration file for the given plugin.

    Methods inherited from class java.lang.Object

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

    • ConfigUtils

      public ConfigUtils()
  • Method Details

    • getConfig

      public static org.bukkit.configuration.file.FileConfiguration getConfig(org.bukkit.plugin.java.JavaPlugin plugin, String fileName)
      Get the config file's configuration
      Parameters:
      plugin - to get config file from
      fileName - name of the config file
      Returns:
      file configuration of given file
    • getConfigFromResources

      public static org.bukkit.configuration.file.FileConfiguration getConfigFromResources(org.bukkit.plugin.java.JavaPlugin plugin, String fileName)
      Get the config file's configuration, gets the file from the resources.
      Parameters:
      plugin - to get config file from
      fileName - name of the config file
      Returns:
      file configuration of given file
    • saveConfig

      public static void saveConfig(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.configuration.file.FileConfiguration config, String name)
      Save specified config file.
      Parameters:
      plugin - to get config file from
      config - file to save
      name - to get config
    • writeAndSave

      public static void writeAndSave(org.bukkit.plugin.java.JavaPlugin plugin, String fileName, Consumer<org.bukkit.configuration.file.FileConfiguration> configConsumer)
      Retrieves, modifies, and saves a configuration file for the given plugin.

      This method loads a configuration file using the provided fileName, applies modifications through the specified Consumer of FileConfiguration, and then saves the modified configuration file.

      Parameters:
      plugin - The JavaPlugin instance from which the configuration is loaded and saved.
      fileName - The name of the configuration file to be loaded and saved.
      configConsumer - A Consumer that performs operations on the FileConfiguration. This allows you to modify the configuration before it is saved.