Class ScenarioProfile

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

public final class ScenarioProfile extends Object
A set of scenario overrides an addon hands to Zentrix for one source arena.

This is the same shape as an arena's section of scenarios.yml, expressed as a value instead of as a file: how a match picks its scenarios, the administrator set, the automatic and voting rules, and — per scenario — whether it is switched on, which game types it is kept out of, and what its settings are. It is read ahead of both the stored arena overrides and the global configuration, and it is never written to disk.

A profile is attached to an ArenaSourceLease, so the arena a match is created from carries the rules that match will run under. Anything the profile does not mention falls through to the ordinary configuration, which is what makes an empty profile mean "use the server's own settings" rather than "run nothing".

Values are stored under the same keys the configuration file uses, so a profile built by the builder and one loaded from an addon's own YAML are the same thing. Every value is validated when the match reads it: a setting whose value no longer fits what the scenario declares is skipped exactly as a stored one would be, and a scenario that is not registered is ignored without its values being lost.

Since:
1.6.0
  • Field Details

    • SELECTION_MODE

      public static final String SELECTION_MODE
      Where a match's selection mode lives.
      See Also:
    • ADMIN_SET

      public static final String ADMIN_SET
      Where the administrator set lives.
      See Also:
    • AUTOMATIC_COUNT

      public static final String AUTOMATIC_COUNT
      How many scenarios an automatic match draws.
      See Also:
    • AUTOMATIC_POOL

      public static final String AUTOMATIC_POOL
      What an automatic match may draw from; empty means every selectable scenario.
      See Also:
    • VOTING_PREFIX

      public static final String VOTING_PREFIX
      The prefix every voting rule sits under.
      See Also:
    • SCENARIOS_PREFIX

      public static final String SCENARIOS_PREFIX
      The prefix every per-scenario section sits under.
      See Also:
  • Method Details

    • empty

      @NotNull public static @NotNull ScenarioProfile empty()
      A profile that overrides nothing, so every match reads the server's own configuration.
    • of

      @NotNull public static @NotNull ScenarioProfile of(@Nullable @Nullable Map<String,Object> values)
      A profile built from values already keyed by configuration path.

      Useful for an addon that stores its profile in a YAML file of its own: the paths are the ones scenarios.yml uses under an arena, so the file can be read straight into a profile. Blank paths and null values are dropped.

    • builder

      @NotNull public static @NotNull ScenarioProfile.Builder builder()
    • isEmpty

      public boolean isEmpty()
      Whether this profile overrides nothing at all.
    • values

      @NotNull public @NotNull Map<String,Object> values()
      Every override, keyed by the configuration path it applies to.
    • value

      @NotNull public @NotNull Optional<Object> value(@NotNull @NotNull String path)
      One override, empty when this profile has no opinion about that path.
    • selectionMode

      @NotNull public @NotNull Optional<ScenarioSelectionMode> selectionMode()
      The selection mode this profile imposes, empty when it leaves the decision alone.
    • configuredScenarioIds

      @NotNull public @NotNull Set<String> configuredScenarioIds()
      The scenario IDs this profile mentions anywhere, for diagnostics.
    • toString

      public String toString()
      Overrides:
      toString in class Object