Record Class ScenarioEntryField
java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.scenario.ScenarioEntryField
- Record Components:
key- the field key, unique within its schematype- how the value is validated and editeddefaultValue- the value used while nothing is stored; null for a required fieldrequired- whether an entry without this field is rejectedminimum- the lowest accepted number, forScenarioFieldType.INTEGERandScenarioFieldType.DECIMALmaximum- the highest accepted number, for the same two typesallowedValues- the accepted values of aScenarioFieldType.ENUMfielddisplayName- the label shown in the GUI; falls back to the key when blankdescription- the lines shown under the label in the GUI
public record ScenarioEntryField(@NotNull String key, @NotNull ScenarioFieldType type, @Nullable Object defaultValue, boolean required, double minimum, double maximum, @NotNull Set<String> allowedValues, @NotNull String displayName, @NotNull List<String> description)
extends Record
One field of a structured entry.
A scenario declares the fields of its entries once, in a ScenarioEntrySchema. Zentrix
uses the declaration to validate what an administrator types, to render one row per field in the
entry editor, and to fill in the value of an optional field that was left out.
A field is either required or optional. A required field has no default: an entry missing it is
rejected as a whole, which is what keeps a half-filled entry out of scenarios.yml. An
optional field falls back to its default whenever no value is stored, exactly like a
ScenarioSetting does.
- Since:
- 1.6.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionScenarioEntryField(@NotNull String key, @NotNull ScenarioFieldType type, @Nullable Object defaultValue, boolean required, double minimum, double maximum, @NotNull Set<String> allowedValues, @NotNull String displayName, @NotNull List<String> description) Creates an instance of aScenarioEntryFieldrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theallowedValuesrecord component.static @NotNull ScenarioEntryFieldA required block identifier, resolvable through vanilla, ItemsAdder or Nexo.static @NotNull ScenarioEntryFieldAn optional toggle.static @NotNull ScenarioEntryField.Builderbuilder(@NotNull String key, @NotNull ScenarioFieldType type) static @NotNull ScenarioEntryFieldAn optional choice out of a fixed set.@Nullable ObjectReturns the value of thedefaultValuerecord component.Returns the value of thedescriptionrecord component.@NotNull StringReturns the value of thedisplayNamerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static @NotNull ScenarioEntryFieldAn optional whole number betweenminimumandmaximum, inclusive.static @NotNull ScenarioEntryFieldA required item identifier, resolvable through vanilla, ItemsAdder, Nexo oritems.yml.@NotNull Stringkey()Returns the value of thekeyrecord component.doublemaximum()Returns the value of themaximumrecord component.doubleminimum()Returns the value of theminimumrecord component.booleanrequired()Returns the value of therequiredrecord component.static @NotNull ScenarioEntryFieldrequired(@NotNull String key, @NotNull ScenarioFieldType type) A required field of any type.final StringtoString()Returns a string representation of this record class.@NotNull ScenarioFieldTypetype()Returns the value of thetyperecord component.
-
Constructor Details
-
ScenarioEntryField
public ScenarioEntryField(@NotNull @NotNull String key, @NotNull @NotNull ScenarioFieldType type, @Nullable @Nullable Object defaultValue, boolean required, double minimum, double maximum, @NotNull @NotNull Set<String> allowedValues, @NotNull @NotNull String displayName, @NotNull @NotNull List<String> description) Creates an instance of aScenarioEntryFieldrecord class.- Parameters:
key- the value for thekeyrecord componenttype- the value for thetyperecord componentdefaultValue- the value for thedefaultValuerecord componentrequired- the value for therequiredrecord 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 component
-
-
Method Details
-
required
@NotNull public static @NotNull ScenarioEntryField required(@NotNull @NotNull String key, @NotNull @NotNull ScenarioFieldType type) A required field of any type. -
item
A required item identifier, resolvable through vanilla, ItemsAdder, Nexo oritems.yml. -
block
A required block identifier, resolvable through vanilla, ItemsAdder or Nexo. -
integer
@NotNull public static @NotNull ScenarioEntryField integer(@NotNull @NotNull String key, int defaultValue, int minimum, int maximum) An optional whole number betweenminimumandmaximum, inclusive. -
bool
@NotNull public static @NotNull ScenarioEntryField bool(@NotNull @NotNull String key, boolean defaultValue) An optional toggle. -
choice
@NotNull public static @NotNull ScenarioEntryField choice(@NotNull @NotNull String key, @NotNull @NotNull String defaultValue, @NotNull @NotNull String... choices) An optional choice out of a fixed set. -
builder
@NotNull public static @NotNull ScenarioEntryField.Builder builder(@NotNull @NotNull String key, @NotNull @NotNull ScenarioFieldType type) -
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
-
required
public boolean required()Returns the value of therequiredrecord component.- Returns:
- the value of the
requiredrecord 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
-