Class DhApiConfigValue<coreType,apiType>
java.lang.Object
com.seibel.distanthorizons.api.objects.config.DhApiConfigValue<coreType,apiType>
- Type Parameters:
coreType- The datatype Distant Horizons uses in the background; implementing developers can ignore this.apiType- The datatype you, an API dev will use.
- All Implemented Interfaces:
IDhApiConfigValue<apiType>
public class DhApiConfigValue<coreType,apiType>
extends Object
implements IDhApiConfigValue<apiType>
A wrapper used to interface with Distant Horizon's Config.
When using this object you need to explicitly define the generic types, otherwise Intellij won't do any type checking and the wrong types can be used.
For example a method returning IDhApiConfig<Integer> when the config should be a Boolean.
When using this object you need to explicitly define the generic types, otherwise Intellij won't do any type checking and the wrong types can be used.
For example a method returning IDhApiConfig<Integer> when the config should be a Boolean.
- Since:
- API 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionDhApiConfigValue(IConfigEntry<coreType> newConfigEntry) This constructor should only be called internally.DhApiConfigValue(IConfigEntry<coreType> newConfigEntry, IConverter<coreType, apiType> newConverter) This constructor should only be called internally. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(Consumer<apiType> onValueChangeFunc) Adds aConsumerthat will be called whenever the config changes to a new value.booleanUn-sets the config's API value.Returns the value of the config if it was set by the API.booleanReturns the default value for this config.Returns the max value for this config, null if there is no max.Returns the min value for this config, null if there is no min.Returns the value held by this config.getValue()Returns the active value for this config.booleanSets the config's value.
-
Constructor Details
-
DhApiConfigValue
This constructor should only be called internally.
There is no reason for API users to create this object.
Uses the default object converter, this requires coreType and apiType to be the same. -
DhApiConfigValue
public DhApiConfigValue(IConfigEntry<coreType> newConfigEntry, IConverter<coreType, apiType> newConverter) This constructor should only be called internally.
There is no reason for API users to create this object.
-
-
Method Details
-
getValue
Description copied from interface:IDhApiConfigValueReturns the active value for this config.
Returns the True value if either the config cannot be overridden by the API or if it hasn't been set by the API.- Specified by:
getValuein interfaceIDhApiConfigValue<coreType>
-
getTrueValue
Description copied from interface:IDhApiConfigValueReturns the value held by this config.
This is the value stored in the config file.- Specified by:
getTrueValuein interfaceIDhApiConfigValue<coreType>
-
getApiValue
Description copied from interface:IDhApiConfigValueReturns the value of the config if it was set by the API. Returns null if the config hasn't been set by the API.- Specified by:
getApiValuein interfaceIDhApiConfigValue<coreType>
-
setValue
Description copied from interface:IDhApiConfigValueSets the config's value.
If the newValue is set to null then the config will revert to using the True Value (IE the value visible in the config menu).
If the config cannot be set via the API this method will return false.- Specified by:
setValuein interfaceIDhApiConfigValue<coreType>- Returns:
- true if the value was set, false otherwise.
-
clearValue
public boolean clearValue()Description copied from interface:IDhApiConfigValueUn-sets the config's API value.
After this method is called this config will use the value set in the config menu.- Specified by:
clearValuein interfaceIDhApiConfigValue<coreType>- Returns:
- true if the value was set, false otherwise.
-
getCanBeOverrodeByApi
public boolean getCanBeOverrodeByApi()- Specified by:
getCanBeOverrodeByApiin interfaceIDhApiConfigValue<coreType>- Returns:
- true if this config can be set via the API, false otherwise.
-
getDefaultValue
Description copied from interface:IDhApiConfigValueReturns the default value for this config.- Specified by:
getDefaultValuein interfaceIDhApiConfigValue<coreType>
-
getMaxValue
Description copied from interface:IDhApiConfigValueReturns the max value for this config, null if there is no max.- Specified by:
getMaxValuein interfaceIDhApiConfigValue<coreType>
-
getMinValue
Description copied from interface:IDhApiConfigValueReturns the min value for this config, null if there is no min.- Specified by:
getMinValuein interfaceIDhApiConfigValue<coreType>
-
addChangeListener
Description copied from interface:IDhApiConfigValueAdds aConsumerthat will be called whenever the config changes to a new value.- Specified by:
addChangeListenerin interfaceIDhApiConfigValue<coreType>
-