Click or drag to resize
Configuration Class
Utility class to store configuration values for your mod. This is a basic Key-Value store and supports only strings as keys and strings, ints, floats, doubles and bools as values. This class also provides the setConfigValue command to users. Configuration is stored in Mods/Config/<modname>.json.
Inheritance Hierarchy
SystemObject
  spaar.ModLoaderConfiguration

Namespace: spaar.ModLoader
Assembly: SpaarModLoader (in SpaarModLoader.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public static class Configuration

The Configuration type exposes the following members.

Methods
  NameDescription
Public methodStatic memberDoesKeyExist
Checks whether a given key exists in the configuration for your mod. Note that this will only be the case after it has ben set once.
Public methodStatic memberGetBool
Gets a bool configuration value stored by your mod. Returns defaultVal if the specified key does not exist for your mod or the value stored at the specified key is not a bool.
Public methodStatic memberGetDouble
Gets a double configuration value stored by your mod. Returns defaultVal if the specified key does not exist for your mod or the value stored at the specified key is not a double.
Public methodStatic memberGetFloat
Gets a float configuration value stored by your mod. Returns defaultVal if the specified key does not exist for your mod or the value stored at the specified key is not a float.
Public methodStatic memberGetInt
Gets an integer configuration value stored by your mod. Returns defaultVal if the specified key does not exist for your mod or the value stored at the specified key is not an integer.
Public methodStatic memberGetKeys
Gets all keys currently stored in the configuration of your mod.
Public methodStatic memberGetString
Gets a string configuration value stored by your mod. Returns defaultVal if the specified key does not exist for your mod or the value stored at the specified key is not a string.
Public methodStatic memberRemoveKey
Removes the specified key and its associated value from the configuration.
Public methodStatic memberSave
Saves the configuration of your mod to disk.
Public methodStatic memberSetBool
Sets a bool in the configuration of your mod.
Public methodStatic memberSetDouble
Sets a double in the configuration of your mod.
Public methodStatic memberSetFloat
Sets a float in the configuration of your mod.
Public methodStatic memberSetInt
Sets an integer in the configuration of your mod.
Public methodStatic memberSetString
Sets a string in the configuration of your mod.
Top
Events
  NameDescription
Public eventStatic memberOnConfigurationChange
This event is raised whenever the configuration for your mod was changed. Use this if your mod needs to react to changes that were made to its configuration at runtime, possibly by the user via the console.
Top
Remarks
Your configuration is loaded automatically when access it, but you will need to manually save it. To do so, call Configuration.Save(). It is recommended that you do this in your Mod.OnUnload() method if you use the Configuration at all.
See Also