Class Config

java.lang.Object
valorless.valorlessutils.config.Config

public class Config extends Object
Handles plugin configuration files.

Provides utility methods to get, set, and validate values in a YAML configuration file. Supports primitive types, Vector2, Vector3, ItemStack, Material, and lists.

  • Constructor Details

    • Config

      public Config(org.bukkit.plugin.java.JavaPlugin plugin, String file)
      Constructs a new Config object.

      If the file does not exist, it will be copied from the plugin's resources.

      Parameters:
      plugin - The JavaPlugin instance.
      file - The name of the configuration file.
  • Method Details

    • Set

      public void Set(String key, Object value)
      Sets a key-value pair in the config.
    • SetVector2

      public <T extends Number> void SetVector2(String key, Vector2<T> value)
      Sets a Vector2 value in the config.
    • SetVector3

      public <T extends Number> void SetVector3(String key, Vector3<T> value)
      Sets a Vector3 value in the config.
    • GetString

      public String GetString(String key)
      Retrieves a String from the config.
    • GetBool

      public Boolean GetBool(String key)
      Retrieves a boolean from the config.
    • GetInt

      public Integer GetInt(String key)
      Retrieves an integer from the config.
    • GetFloat

      @Deprecated public Double GetFloat(String key)
      Deprecated.
      This method is outdated and will be removed in future versions.
      Retrieves a float (double) value from the config.
    • GetDouble

      public Double GetDouble(String key)
      Retrieves a double from the config.
    • GetVector2

      public <T extends Number> Vector2<T> GetVector2(String key)
      Retrieves a Vector2 from the config.
    • GetVector3

      public <T extends Number> Vector3<T> GetVector3(String key)
      Retrieves a Vector3 from the config.
    • GetMaterial

      public org.bukkit.Material GetMaterial(String key)
      Retrieves a Material from the config.
    • Get

      public Object Get(String key)
      Retrieves a generic object from the config.
    • GetStringList

      public List<String> GetStringList(String key)
      Retrieves a list of strings from the config.
    • GetIntList

      public List<Integer> GetIntList(String key)
      Retrieves a list of integers from the config.
    • GetDoubleList

      public List<Double> GetDoubleList(String key)
      Retrieves a list of doubles from the config.
    • GetList

      public List<?> GetList(String key)
      Retrieves a generic list from the config.
    • GetItemStack

      public org.bukkit.inventory.ItemStack GetItemStack(String key)
      Retrieves an ItemStack from the config.
    • HasKey

      public Boolean HasKey(String key)
      Checks if a key exists in the config.
    • GetConfigurationSection

      public org.bukkit.configuration.ConfigurationSection GetConfigurationSection(String key)
      Retrieves a ConfigurationSection from the config.
    • GetFile

      public YamlFile GetFile()
      Returns the underlying YamlFile instance.
    • Reload

      public void Reload()
      Reloads the configuration file and validates it.
    • SaveConfig

      public void SaveConfig()
      Saves the configuration file.
    • AddValidationEntry

      public void AddValidationEntry(String key, Object value)
      Adds a key-value pair to the validation list.
    • AddValidationEntry

      public <T extends Number> void AddValidationEntry(String key, Vector2<T> value)
      Adds a Vector2 entry to the validation list.
    • AddValidationEntry

      public <T extends Number> void AddValidationEntry(String key, Vector3<T> value)
      Adds a Vector3 entry to the validation list.
    • Validate

      public void Validate()
      Validates the configuration file against the validation list.

      Adds missing keys with their default values and saves the file if necessary. Logs any added or missing entries.