Class DoubleSetting

java.lang.Object
dev.myriadclient.api.setting.Setting<Double>
dev.myriadclient.api.setting.DoubleSetting

public class DoubleSetting extends Setting<Double>
A number with decimals, set with a slider or typed into a box (DoubleSetting.Builder.typed()). Values are rounded to decimals() places and clamped to min()..max(); NaN gives the default. The slider covers sliderMin()..sliderMax(), which may be narrower.
  • Constructor Details

  • Method Details

    • min

      public double min()
      The lowest value it takes; anything lower is raised to it.
    • max

      public double max()
      The highest value it takes; anything higher is lowered to it.
    • sliderMin

      public double sliderMin()
      The slider's left end.
    • sliderMax

      public double sliderMax()
      The slider's right end.
    • decimals

      public int decimals()
      How many decimal places values are rounded to and shown with.
    • typed

      public boolean typed()
      Whether it's typed into a box rather than set with a slider (see DoubleSetting.Builder.typed()).
    • getFloat

      public float getFloat()
      Setting.get() as a float.
    • validate

      protected Double validate(@Nullable Double v)
      Description copied from class: Setting
      Clamps or normalises a candidate value before it's set or laid over; null gives the default.
      Overrides:
      validate in class Setting<Double>
    • toJson

      public com.google.gson.JsonElement toJson()
      Description copied from class: Setting
      The player's value as JSON, for config and shares.
      Specified by:
      toJson in class Setting<Double>
    • fromJson

      public void fromJson(com.google.gson.JsonElement json)
      Description copied from class: Setting
      Load from JSON; invalid input must leave the value unchanged rather than throw.
      Specified by:
      fromJson in class Setting<Double>
    • parse

      public boolean parse(String input)
      Description copied from class: Setting
      Sets the player's value from what a player typed (a command, a text box). Returns false, leaving the value as it was, if the input isn't valid.
      Specified by:
      parse in class Setting<Double>
    • valueString

      public String valueString()
      Description copied from class: Setting
      The value in effect for people, the way Setting.parse(String) reads it back where it can.
      Overrides:
      valueString in class Setting<Double>