Record Class ScenarioSetting
- Record Components:
key- the setting key, unique within its scenariotype- how the value is validated and editeddefaultValue- the value used until an administrator configures one; never nullminimum- the lowest accepted number, forScenarioSettingType.INTEGERandScenarioSettingType.DECIMALmaximum- the highest accepted number, for the same two typesallowedValues- the accepted values of anScenarioSettingType.ENUMsettingdisplayName- the label shown in the GUI; falls back to the key when blankdescription- the lines shown under the label in the GUIentrySchema- the shape of one entry of aScenarioSettingType.STRUCTURED_LISTsetting, and null for every other type
A scenario declares its settings once, in its ScenarioDescriptor. Zentrix uses the
declaration to validate values, to render an editor in the management GUI, and to supply the
default whenever no administrator has configured the setting.
Declaring a setting never writes anything to disk. A value only reaches scenarios.yml
once an administrator edits it, which keeps a dynamically registered scenario out of the main
configuration until somebody deliberately configures it.
- Since:
- 1.6.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionScenarioSetting(@NotNull String key, @NotNull ScenarioSettingType type, @NotNull Object defaultValue, double minimum, double maximum, @NotNull Set<String> allowedValues, @NotNull String displayName, @NotNull List<String> description) The pre-1.6.0 constructor, kept so anything compiled against an earlier API still links.ScenarioSetting(@NotNull String key, @NotNull ScenarioSettingType type, @NotNull Object defaultValue, double minimum, double maximum, @NotNull Set<String> allowedValues, @NotNull String displayName, @NotNull List<String> description, @Nullable ScenarioEntrySchema entrySchema) Creates an instance of aScenarioSettingrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theallowedValuesrecord component.static @NotNull ScenarioSettingA toggle.static @NotNull ScenarioSetting.Builderbuilder(@NotNull String key, @NotNull ScenarioSettingType type, @NotNull Object defaultValue) static @NotNull ScenarioSettingOne of a fixed set of choices.static @NotNull ScenarioSettingA fractional number betweenminimumandmaximum, inclusive.@NotNull List<ScenarioEntry> The declared entry defaults of aScenarioSettingType.STRUCTURED_LISTsetting.@NotNull ObjectReturns the value of thedefaultValuerecord component.Returns the value of thedescriptionrecord component.@NotNull StringReturns the value of thedisplayNamerecord component.static @NotNull ScenarioSettingentries(@NotNull String key, @NotNull ScenarioEntrySchema schema) A list of entries shaped byschema, empty until an administrator adds one.static @NotNull ScenarioSettingentries(@NotNull String key, @NotNull ScenarioEntrySchema schema, @NotNull List<ScenarioEntry> defaultValue) A list of entries shaped byschema.@Nullable ScenarioEntrySchemaReturns the value of theentrySchemarecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static @NotNull ScenarioSettingA whole number betweenminimumandmaximum, inclusive.booleanWhether this setting accepts numeric bounds.booleanWhether this setting holds a list of entries shaped byentrySchema().@NotNull Stringkey()Returns the value of thekeyrecord component.static @NotNull ScenarioSettingA list of Bukkit material names.doublemaximum()Returns the value of themaximumrecord component.doubleminimum()Returns the value of theminimumrecord component.static @NotNull ScenarioSettingFree text.final StringtoString()Returns a string representation of this record class.@NotNull ScenarioSettingTypetype()Returns the value of thetyperecord component.
-
Constructor Details
-
ScenarioSetting
public ScenarioSetting(@NotNull @NotNull String key, @NotNull @NotNull ScenarioSettingType type, @NotNull @NotNull Object defaultValue, double minimum, double maximum, @NotNull @NotNull Set<String> allowedValues, @NotNull @NotNull String displayName, @NotNull @NotNull List<String> description, @Nullable @Nullable ScenarioEntrySchema entrySchema) Creates an instance of aScenarioSettingrecord class.- Parameters:
key- the value for thekeyrecord componenttype- the value for thetyperecord componentdefaultValue- the value for thedefaultValuerecord componentminimum- the value for theminimumrecord componentmaximum- the value for themaximumrecord componentallowedValues- the value for theallowedValuesrecord componentdisplayName- the value for thedisplayNamerecord componentdescription- the value for thedescriptionrecord componententrySchema- the value for theentrySchemarecord component
-
ScenarioSetting
public ScenarioSetting(@NotNull @NotNull String key, @NotNull @NotNull ScenarioSettingType type, @NotNull @NotNull Object defaultValue, double minimum, double maximum, @NotNull @NotNull Set<String> allowedValues, @NotNull @NotNull String displayName, @NotNull @NotNull List<String> description) The pre-1.6.0 constructor, kept so anything compiled against an earlier API still links.Declares no entry schema, which is exactly right:
ScenarioSettingType.STRUCTURED_LISTdid not exist before the schema did.
-
-
Method Details
-
bool
@NotNull public static @NotNull ScenarioSetting bool(@NotNull @NotNull String key, boolean defaultValue) A toggle. -
integer
@NotNull public static @NotNull ScenarioSetting integer(@NotNull @NotNull String key, int defaultValue, int minimum, int maximum) A whole number betweenminimumandmaximum, inclusive. -
decimal
@NotNull public static @NotNull ScenarioSetting decimal(@NotNull @NotNull String key, double defaultValue, double minimum, double maximum) A fractional number betweenminimumandmaximum, inclusive. -
text
@NotNull public static @NotNull ScenarioSetting text(@NotNull @NotNull String key, @NotNull @NotNull String defaultValue) Free text. -
choice
@NotNull public static @NotNull ScenarioSetting choice(@NotNull @NotNull String key, @NotNull @NotNull String defaultValue, @NotNull @NotNull String... choices) One of a fixed set of choices. -
materials
@NotNull public static @NotNull ScenarioSetting materials(@NotNull @NotNull String key, @NotNull @NotNull List<String> defaultValue) A list of Bukkit material names. -
entries
@NotNull public static @NotNull ScenarioSetting entries(@NotNull @NotNull String key, @NotNull @NotNull ScenarioEntrySchema schema, @NotNull @NotNull List<ScenarioEntry> defaultValue) A list of entries shaped byschema.The schema decides what one entry holds: a single field for a plain list, two for a list of pairs, more for anything else the scenario needs. Zentrix stays unaware of what the fields mean, so the same setting type serves any scenario.
- Parameters:
schema- the fields every entry of this setting carriesdefaultValue- the entries used until an administrator configures the setting
-
entries
@NotNull public static @NotNull ScenarioSetting entries(@NotNull @NotNull String key, @NotNull @NotNull ScenarioEntrySchema schema) A list of entries shaped byschema, empty until an administrator adds one. -
builder
@NotNull public static @NotNull ScenarioSetting.Builder builder(@NotNull @NotNull String key, @NotNull @NotNull ScenarioSettingType type, @NotNull @NotNull Object defaultValue) -
isNumeric
public boolean isNumeric()Whether this setting accepts numeric bounds. -
isStructured
public boolean isStructured()Whether this setting holds a list of entries shaped byentrySchema(). -
defaultEntries
The declared entry defaults of aScenarioSettingType.STRUCTURED_LISTsetting.Empty for every other type, and for a structured setting whose default was declared in a shape this version no longer understands, so a caller never has to guard the declaration.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
key
Returns the value of thekeyrecord component.- Returns:
- the value of the
keyrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
defaultValue
Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-
minimum
public double minimum()Returns the value of theminimumrecord component.- Returns:
- the value of the
minimumrecord component
-
maximum
public double maximum()Returns the value of themaximumrecord component.- Returns:
- the value of the
maximumrecord component
-
allowedValues
Returns the value of theallowedValuesrecord component.- Returns:
- the value of the
allowedValuesrecord component
-
displayName
Returns the value of thedisplayNamerecord component.- Returns:
- the value of the
displayNamerecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
entrySchema
Returns the value of theentrySchemarecord component.- Returns:
- the value of the
entrySchemarecord component
-