Interface Config

All Known Implementing Classes:
BaseConfig, JsonConfig, YamlConfig

public interface Config
Represents a plugin configuration file.

Config provides methods to read and write configuration values with type safety. Supports nested sections, lists, and various data types.

Example Usage:

Config config = plugin.getConfig();

// Get values with defaults
String name = config.getString("server.name", "Default Server");
int maxPlayers = config.getInt("server.max-players", 20);

// Set values
config.set("server.name", "My Server");
config.set("server.enabled", true);

// Save changes
config.save();
Since:
1.0.4
Version:
1.0.4
Author:
HytaleLoader
  • Method Details

    • get

      Object get(String path)
      Gets a value from the config.
      Parameters:
      path - the path to the value (e.g., "server.name")
      Returns:
      the value, or null if not found
    • get

      Object get(String path, Object def)
      Gets a value with a default fallback.
      Parameters:
      path - the path to the value
      def - the default value if not found
      Returns:
      the value, or default if not found
    • set

      void set(String path, Object value)
      Sets a value in the config.
      Parameters:
      path - the path to set
      value - the value to set
    • getString

      String getString(String path)
      Gets a string value.
      Parameters:
      path - the path to the value
      Returns:
      the string value, or null if not found
    • getString

      String getString(String path, String def)
      Gets a string value with default.
      Parameters:
      path - the path to the value
      def - the default value
      Returns:
      the string value, or default if not found
    • getInt

      int getInt(String path)
      Gets an integer value.
      Parameters:
      path - the path to the value
      Returns:
      the integer value, or 0 if not found
    • getInt

      int getInt(String path, int def)
      Gets an integer value with default.
      Parameters:
      path - the path to the value
      def - the default value
      Returns:
      the integer value, or default if not found
    • getDouble

      double getDouble(String path)
      Gets a double value.
      Parameters:
      path - the path to the value
      Returns:
      the double value, or 0.0 if not found
    • getDouble

      double getDouble(String path, double def)
      Gets a double value with default.
      Parameters:
      path - the path to the value
      def - the default value
      Returns:
      the double value, or default if not found
    • getBoolean

      boolean getBoolean(String path)
      Gets a boolean value.
      Parameters:
      path - the path to the value
      Returns:
      the boolean value, or false if not found
    • getBoolean

      boolean getBoolean(String path, boolean def)
      Gets a boolean value with default.
      Parameters:
      path - the path to the value
      def - the default value
      Returns:
      the boolean value, or default if not found
    • getList

      List<?> getList(String path)
      Gets a list value.
      Parameters:
      path - the path to the value
      Returns:
      the list, or null if not found
    • getList

      List<?> getList(String path, List<?> def)
      Gets a list value with default.
      Parameters:
      path - the path to the value
      def - the default value
      Returns:
      the list, or default if not found
    • getStringList

      List<String> getStringList(String path)
      Gets a string list.
      Parameters:
      path - the path to the value
      Returns:
      the string list, or empty list if not found
    • getSection

      ConfigSection getSection(String path)
      Gets a config section.
      Parameters:
      path - the path to the section
      Returns:
      the config section, or null if not found
    • contains

      boolean contains(String path)
      Checks if a path exists in the config.
      Parameters:
      path - the path to check
      Returns:
      true if the path exists
    • getKeys

      Set<String> getKeys(boolean deep)
      Gets all keys in the config.
      Parameters:
      deep - whether to get keys from nested sections
      Returns:
      set of all keys
    • getValues

      Map<String,Object> getValues()
      Gets all values as a map.
      Returns:
      map of all values
    • save

      void save() throws IOException
      Saves the config to file.
      Throws:
      IOException - if save fails
    • reload

      void reload() throws IOException
      Reloads the config from file.
      Throws:
      IOException - if reload fails
    • getFile

      File getFile()
      Gets the file this config is bound to.
      Returns:
      the config file
    • setDefaults

      void setDefaults(Map<String,Object> defaults)
      Sets the default values for this config. Values will be used if not present in the file.
      Parameters:
      defaults - map of default values
    • addDefault

      void addDefault(String path, Object value)
      Adds default values to the config.
      Parameters:
      path - the path to set
      value - the default value