public class ConfigManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static java.util.Map<java.lang.Class<?>,ITypeAdapter> |
ADAPTERS |
(package private) static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> |
ARRAY_REMAP |
private static java.util.Map<java.lang.String,com.google.common.collect.Multimap<Config.Type,ASMDataTable.ASMData>> |
asm_data |
private static java.util.Map<java.lang.String,Configuration> |
CONFIGS |
private static java.util.Map<java.lang.String,java.util.Set<java.lang.Class<?>>> |
MOD_CONFIG_CLASSES |
(package private) static com.google.common.base.Joiner |
NEW_LINE |
(package private) static com.google.common.base.Joiner |
PIPE |
Constructor and Description |
---|
ConfigManager() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
exists(Configuration cfg,
java.lang.String category,
java.lang.String property) |
(package private) static Configuration |
getConfiguration(java.lang.String modid,
java.lang.String name) |
static java.lang.Class<?>[] |
getModConfigClasses(java.lang.String modid) |
private static java.lang.String |
getName(java.lang.reflect.Field f) |
static boolean |
hasConfigForMod(java.lang.String modid) |
static void |
load(java.lang.String modid,
Config.Type type)
Bounces to sync().
|
static void |
loadData(ASMDataTable data) |
private static Property |
property(Configuration cfg,
java.lang.String category,
java.lang.String property,
Property.Type type,
boolean isList) |
private static void |
register(java.lang.Class<?> cls,
ITypeAdapter adpt) |
private static boolean |
shouldReadFromVar(Property property,
java.lang.Object propValue,
java.lang.Object fieldValue) |
private static void |
sync(Configuration cfg,
java.lang.Class<?> cls,
java.lang.String modid,
java.lang.String category,
boolean loading,
java.lang.Object instance) |
static void |
sync(java.lang.String modid,
Config.Type type)
Synchronizes configuration data between the file on disk, the
Configuration object and the annotated
mod classes containing the configuration variables. |
private static java.util.Map<java.lang.String,com.google.common.collect.Multimap<Config.Type,ASMDataTable.ASMData>> asm_data
static java.util.Map<java.lang.Class<?>,ITypeAdapter> ADAPTERS
static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> ARRAY_REMAP
private static java.util.Map<java.lang.String,Configuration> CONFIGS
private static java.util.Map<java.lang.String,java.util.Set<java.lang.Class<?>>> MOD_CONFIG_CLASSES
static final com.google.common.base.Joiner NEW_LINE
static final com.google.common.base.Joiner PIPE
private static void register(java.lang.Class<?> cls, ITypeAdapter adpt)
public static void loadData(ASMDataTable data)
public static void load(java.lang.String modid, Config.Type type)
public static void sync(java.lang.String modid, Config.Type type)
Configuration
object and the annotated
mod classes containing the configuration variables.
When first called, this method will try to load the configuration from disk. If this fails, because the file
does not exist, it will be created with default values derived from the mods config classes variable default values
and comments and ranges, as well as configuration names based on the appropriate annotations found in @Config
.
Note, that this method is being called by the FMLModContainer
, so the mod needn't call it in init().
If this method is called after the initial load, it will check whether the values in the Configuration object differ
from the values in the corresponding variables. If they differ, it will either overwrite the variables if the Configuration
object is marked as changed (e.g. if it was changed with the ConfigGui) or otherwise overwrite the Configuration object's values.
It then proceeds to saving the changes to disk.modid
- the mod's ID for which the configuration shall be loadedtype
- the configuration type, currently always Config.Type.INSTANCE
public static java.lang.Class<?>[] getModConfigClasses(java.lang.String modid)
public static boolean hasConfigForMod(java.lang.String modid)
static Configuration getConfiguration(java.lang.String modid, java.lang.String name)
private static void sync(Configuration cfg, java.lang.Class<?> cls, java.lang.String modid, java.lang.String category, boolean loading, java.lang.Object instance)
private static Property property(Configuration cfg, java.lang.String category, java.lang.String property, Property.Type type, boolean isList)
private static boolean exists(Configuration cfg, java.lang.String category, java.lang.String property)
private static boolean shouldReadFromVar(Property property, java.lang.Object propValue, java.lang.Object fieldValue)
private static java.lang.String getName(java.lang.reflect.Field f)