Class ScenarioEntry

java.lang.Object
dev.itsharshxd.zentrix.api.scenario.ScenarioEntry

public final class ScenarioEntry extends Object
One entry of a ScenarioSettingType.STRUCTURED_LIST setting.

An entry is an immutable set of values keyed by the field keys of its ScenarioEntrySchema. Every accessor falls back to the field's declared default, so reading a field a stored entry left out yields the same value the scenario asked for rather than nothing at all.

Instances are cheap and immutable: with(String, Object) returns a new entry, which is how the management GUI edits one field at a time without ever mutating what a running match is using.

Since:
1.6.0
  • Constructor Details

    • ScenarioEntry

      public ScenarioEntry(@NotNull @NotNull ScenarioEntrySchema schema, @NotNull @NotNull Map<String,Object> values)
      An entry of schema holding values.

      Values whose keys the schema does not declare are dropped, so an entry can never carry a field a later version of the scenario stopped declaring.

  • Method Details

    • schema

      @NotNull public @NotNull ScenarioEntrySchema schema()
    • raw

      @NotNull public @NotNull Optional<Object> raw(@NotNull @NotNull String key)
      The stored value of one field, without falling back to its default.
    • has

      public boolean has(@NotNull @NotNull String key)
      Whether this entry stores a value of its own for the field.
    • get

      @Nullable public @Nullable Object get(@NotNull @NotNull String key)
      The value of one field, falling back to the field's default.
    • getString

      @NotNull public @NotNull String getString(@NotNull @NotNull String key)
    • getInt

      public int getInt(@NotNull @NotNull String key)
    • getDouble

      public double getDouble(@NotNull @NotNull String key)
    • getBoolean

      public boolean getBoolean(@NotNull @NotNull String key)
    • getMaterial

      @NotNull public @NotNull Optional<org.bukkit.Material> getMaterial(@NotNull @NotNull String key)
      The field read as a Bukkit material, empty when the stored name does not resolve.
    • asMap

      @NotNull public @NotNull Map<String,Object> asMap()
      Every stored value, keyed by field key, in declaration order.
    • with

      @NotNull public @NotNull ScenarioEntry with(@NotNull @NotNull String key, @Nullable @Nullable Object value)
      A copy of this entry with one field changed; a null value clears the field.
    • isComplete

      public boolean isComplete()
      Whether every required field of the schema carries a value.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object