Class ConfigurableParameter<T>

java.lang.Object
me.nabdev.oxconfig.ConfigurableParameter<T>
Type Parameters:
T - The type of the parameter

public class ConfigurableParameter<T> extends Object
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

    Constructors
    Constructor
    Description
    Creates a new ConfigurableParameter with the given value and key, and registers it with the OxConfig
    ConfigurableParameter(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 Type
    Method
    Description
    get()
    Gets the current value of the parameter since the last reload
    void
    set(T val)
    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
    boolean
    Whether or not a comment should be stored.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigurableParameter

      public ConfigurableParameter(T val, String key)
      Creates a new ConfigurableParameter with the given value and key, and registers it with the OxConfig
      Parameters:
      val - Default value, must not include commas
      key - json key to register with (e.g. "driveTrainMaxSpeed"), must not include commas
    • ConfigurableParameter

      public ConfigurableParameter(T val, String key, Consumer<T> callback)
      Creates a new ConfigurableParameter with the given value and key, and registers it with the OxConfig
      Parameters:
      val - Default value, must not include commas
      key - json key to register with (e.g. "driveTrain/maxSpeed"), must not include commas
      callback - Callback function on value change
  • Method Details

    • set

      public void set(T val)
      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

      public T 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.