Class DoubleSetting
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds aDoubleSetting; 0, unbounded and 2 decimals by default.Nested classes/interfaces inherited from class Setting
Setting.Layer -
Field Summary
Fields inherited from class Setting
defaultValue, description, id, name, value -
Constructor Summary
ConstructorsConstructorDescriptionDoubleSetting(String name, @Nullable String description, double defaultValue, @Nullable Supplier<Boolean> visible, double min, double max, double sliderMin, double sliderMax, int decimals) A setting as itsDoubleSetting.Buildermakes it; get one fromSettingGroup.decimal(String), or call this from a subclass. -
Method Summary
Modifier and TypeMethodDescriptionintdecimals()How many decimal places values are rounded to and shown with.voidfromJson(com.google.gson.JsonElement json) Load from JSON; invalid input must leave the value unchanged rather than throw.floatgetFloat()Setting.get()as a float.doublemax()The highest value it takes; anything higher is lowered to it.doublemin()The lowest value it takes; anything lower is raised to it.booleanSets the player's value from what a player typed (a command, a text box).doubleThe slider's right end.doubleThe slider's left end.com.google.gson.JsonElementtoJson()The player's value as JSON, for config and shares.booleantyped()Whether it's typed into a box rather than set with a slider (seeDoubleSetting.Builder.typed()).protected DoubleClamps or normalises a candidate value before it's set or laid over; null gives the default.The value in effect for people, the waySetting.parse(String)reads it back where it can.Methods inherited from class Setting
changed, copy, decode, decode, defaultValue, description, edit, editsTakeEffect, encode, get, group, id, isDefault, isOverridden, isProtected, isSerializable, isVisible, name, onChanged, overriddenBy, override, override, playerValue, release, reset, set, setGlobalChangeHook, suggestions
-
Constructor Details
-
DoubleSetting
public DoubleSetting(String name, @Nullable String description, double defaultValue, @Nullable Supplier<Boolean> visible, double min, double max, double sliderMin, double sliderMax, int decimals) A setting as itsDoubleSetting.Buildermakes it; get one fromSettingGroup.decimal(String), or call this from a subclass.
-
-
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 (seeDoubleSetting.Builder.typed()). -
getFloat
public float getFloat()Setting.get()as a float. -
validate
-
toJson
-
fromJson
-
parse
-
valueString
Description copied from class:SettingThe value in effect for people, the waySetting.parse(String)reads it back where it can.- Overrides:
valueStringin classSetting<Double>
-