Class ConfigManager

java.lang.Object
tech.anonymoushacker1729.cobaltconfig.config.ConfigManager

public class ConfigManager extends Object
  • Method Details

    • initializeConfig

      @Internal public void initializeConfig(Class<?> configClass)
      Initializes the config file by reading the values and setting the static fields.
      Parameters:
      configClass - the config class
    • reload

      public void reload(Class<?> configClass)
      Reloads the config file by reading the values and setting the static fields.
      Parameters:
      configClass - the config class
    • loadFromMap

      @Internal public static void loadFromMap(String configClassName, Map<String,Object> configValues)
      Loads the config values from a map.
      Parameters:
      configClassName - the config class name
      configValues - the config values
    • writeChanges

      public void writeChanges()
      Writes the current values of the config class to the config file.
    • reloadAll

      public static void reloadAll()
      Reloads all config files.
    • classToMap

      @Nullable @Internal public static @Nullable Map<String,Object> classToMap(Class<?> configClass)
      Converts a config class to a map.
      Parameters:
      configClass - the config class
      Returns:
      Map
    • getManagers

      public static List<ConfigManager> getManagers(boolean ignoreClientOnly)
      Get the list of configuration managers.
    • getManagers

      public static List<ConfigManager> getManagers(String modId, boolean ignoreClientOnly)
      Get the list of configuration managers for a specific mod ID.
      Parameters:
      modId - the mod ID
      ignoreClientOnly - whether to ignore client-only configs
      Returns:
      List
    • getConfigClass

      public Class<?> getConfigClass()
      Gets the config class.
      Returns:
      Class
    • getComment

      @Nullable @AvailableSince("1.0.0") public static @Nullable String getComment(Class<?> configClass, String key)
      Get a ConfigEntry.comment() for a given key if present.
      Parameters:
      configClass - the config class
      key - the key
      Returns:
      the comment or null if not present
    • getGroup

      @AvailableSince("1.0.0") public static String getGroup(Class<?> configClass, String key)
      Get a ConfigEntry.group() for a given key if present.
      Parameters:
      configClass - the config class
      key - the key
      Returns:
      the group if present, otherwise an empty string
    • getMin

      public static Double getMin(Class<?> configClass, String key)
      Get the ConfigEntry.min() for a given key if present.
      Parameters:
      configClass - the config class
      key - the key
      Returns:
      the min value. If not specified, it will be Double.MIN_VALUE
    • getMax

      public static Double getMax(Class<?> configClass, String key)
      Get the ConfigEntry.max() for a given key if present.
      Parameters:
      configClass - the config class
      key - the key
      Returns:
      the max value. If not specified, it will be Double.MAX_VALUE
    • getRestartRequired

      @AvailableSince("1.0.0") public static boolean getRestartRequired(Class<?> configClass, String key)
      Get the ConfigEntry.restartRequired() for a given key if present.
      Parameters:
      configClass - the config class
      key - the key
      Returns:
      true if a restart is required
    • getDefaultValues

      @AvailableSince("1.0.0") public Map<String,Object> getDefaultValues()
      Get the default values of this configuration.
      Returns:
      Map
    • getConfigName

      @AvailableSince("1.0.0") public net.minecraft.network.chat.Component getConfigName()
      Gets the config name as a Component.
      Returns:
      Component
    • getModId

      @AvailableSince("1.0.0") public String getModId()
      Gets the mod ID.
      Returns:
      String
    • isClientOnly

      @AvailableSince("1.0.0") public boolean isClientOnly()
      Returns whether the config is client-only.
      Returns:
      boolean
    • getConfigPath

      public static Path getConfigPath(String modId, @Nullable @Nullable String suffix)
      Gets the path to the config file.
      Parameters:
      modId - the mod ID
      suffix - the suffix, if any
      Returns:
      Path