Package me.nabdev.oxconfig
Class ConfigurableParameter<T>
java.lang.Object
me.nabdev.oxconfig.ConfigurableParameter<T>
- Type Parameters:
T
- The type of the parameter
A single parameter that can be configured by OxConfig.
If you need several instances of a class with several parameters, use
ConfigurableClass instead.
-
Constructor Summary
ConstructorsConstructorDescriptionConfigurableParameter
(T val, String key) Creates a new ConfigurableParameter with the given value and key, and registers it with the OxConfigConfigurableParameter
(T val, String key, Consumer<T> callback) Creates a new ConfigurableParameter with the given value and key, and registers it with the OxConfig -
Method Summary
Modifier and TypeMethodDescriptionget()
Gets the current value of the parameter since the last reloadvoid
Sets the value of the parameter and calls the setter method Note: This does not save the value to the config file and will be overwritten on reloadboolean
Whether or not a comment should be stored.
-
Constructor Details
-
ConfigurableParameter
Creates a new ConfigurableParameter with the given value and key, and registers it with the OxConfig- Parameters:
val
- Default value, must not include commaskey
- json key to register with (e.g. "driveTrainMaxSpeed"), must not include commas
-
ConfigurableParameter
Creates a new ConfigurableParameter with the given value and key, and registers it with the OxConfig- Parameters:
val
- Default value, must not include commaskey
- json key to register with (e.g. "driveTrain/maxSpeed"), must not include commascallback
- Callback function on value change
-
-
Method Details
-
set
Sets the value of the parameter and calls the setter method Note: This does not save the value to the config file and will be overwritten on reload- Parameters:
val
- The new value
-
get
Gets the current value of the parameter since the last reload- Returns:
- The current value of the parameter
-
shouldStoreComment
public boolean shouldStoreComment()Whether or not a comment should be stored.- Returns:
- Whether or not a commentshould be stored.
-