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 TypeMethodDescriptionvoid
addChangeListener
(Consumer<apiType> onValueChangeFunc) Adds aConsumer
that will be called whenever the config changes to a new value.boolean
Un-sets the config's API value.Returns the value of the config if it was set by the API.boolean
Returns 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.boolean
Sets 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:IDhApiConfigValue
Returns 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:
getValue
in interfaceIDhApiConfigValue<coreType>
-
getTrueValue
Description copied from interface:IDhApiConfigValue
Returns the value held by this config.
This is the value stored in the config file.- Specified by:
getTrueValue
in interfaceIDhApiConfigValue<coreType>
-
getApiValue
Description copied from interface:IDhApiConfigValue
Returns 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:
getApiValue
in interfaceIDhApiConfigValue<coreType>
-
setValue
Description copied from interface:IDhApiConfigValue
Sets 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:
setValue
in interfaceIDhApiConfigValue<coreType>
- Returns:
- true if the value was set, false otherwise.
-
clearValue
public boolean clearValue()Description copied from interface:IDhApiConfigValue
Un-sets the config's API value.
After this method is called this config will use the value set in the config menu.- Specified by:
clearValue
in interfaceIDhApiConfigValue<coreType>
- Returns:
- true if the value was set, false otherwise.
-
getCanBeOverrodeByApi
public boolean getCanBeOverrodeByApi()- Specified by:
getCanBeOverrodeByApi
in interfaceIDhApiConfigValue<coreType>
- Returns:
- true if this config can be set via the API, false otherwise.
-
getDefaultValue
Description copied from interface:IDhApiConfigValue
Returns the default value for this config.- Specified by:
getDefaultValue
in interfaceIDhApiConfigValue<coreType>
-
getMaxValue
Description copied from interface:IDhApiConfigValue
Returns the max value for this config, null if there is no max.- Specified by:
getMaxValue
in interfaceIDhApiConfigValue<coreType>
-
getMinValue
Description copied from interface:IDhApiConfigValue
Returns the min value for this config, null if there is no min.- Specified by:
getMinValue
in interfaceIDhApiConfigValue<coreType>
-
addChangeListener
Description copied from interface:IDhApiConfigValue
Adds aConsumer
that will be called whenever the config changes to a new value.- Specified by:
addChangeListener
in interfaceIDhApiConfigValue<coreType>
-