Class ScenarioCapability

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

public final class ScenarioCapability extends Object
A gameplay area a scenario takes charge of, named rather than enumerated.

Conflicts between scenarios are normally declared by ID, which only works between scenarios that already know about each other. A capability is the open-ended version of the same idea: a scenario declares what it takes charge of, and another scenario declares what it cannot live alongside. Validation then rejects the pair without either of them naming the other, so a scenario written today stays incompatible with one written years later.

A scenario that both provides and conflicts with the same capability forms a mutual-exclusion group: any two members of the group conflict, while the group as a whole stays open for new members. That is how, for example, two scenarios that each pin the world clock keep each other out.

Example


 // Grants enchantments, so anything that bans them will not run alongside it.
 ScenarioDescriptor.builder("toolsmiths-edge")
         .provides(ScenarioCapability.ENCHANTMENTS)
         .build();

 // Bans enchantments, whoever grants them.
 ScenarioDescriptor.builder("no-enchants")
         .conflictsWithCapability(ScenarioCapability.ENCHANTMENTS)
         .build();

 // A mutual-exclusion group only one member of which may run.
 ScenarioDescriptor.builder("permanent-day")
         .provides(ScenarioCapability.WORLD_TIME)
         .conflictsWithCapability(ScenarioCapability.WORLD_TIME)
         .build();
 

Addon capabilities should be namespaced — myaddon:gravity — so two addons cannot collide. The zentrix: namespace is reserved for the constants below.

Since:
1.6.0
  • Field Details

    • ENCHANTMENTS

      public static final ScenarioCapability ENCHANTMENTS
      Adding, upgrading or transferring vanilla enchantments on items players end up holding.

      Declare this whenever the scenario can put an enchantment on a player's item — through crafting, loot, kits or an ability — so scenarios that ban enchantments can keep clear of it.

    • WORLD_TIME

      public static final ScenarioCapability WORLD_TIME
      Pinning or driving the world clock of the match's worlds.
    • WORLD_WEATHER

      public static final ScenarioCapability WORLD_WEATHER
      Pinning or driving the weather of the match's worlds.
    • WIN_CONDITION

      public static final ScenarioCapability WIN_CONDITION
      Deciding when the match is over, in place of Zentrix's own alive-team count.
    • PLAYER_IDENTITY

      public static final ScenarioCapability PLAYER_IDENTITY
      Changing who players appear to be — their name, their skin, or both.

      Declare this whenever the scenario masks, scrambles or hides player identities, so anything that depends on players recognising each other can keep clear of it.

      Since:
      1.6.0
    • DEATHMATCH_LOCATION

      public static final ScenarioCapability DEATHMATCH_LOCATION
      Deciding where the deathmatch happens, in place of Zentrix's copied template arena.

      Only one scenario can move the final fight, so every scenario that answers the deathmatch-destination hook should both provide and conflict with this.

      Since:
      1.6.0
    • DEATH_HANDLING

      public static final ScenarioCapability DEATH_HANDLING
      Taking a player's death over from Zentrix's own elimination handling.

      Declare this whenever the scenario answers GameplayHooks.PLAYER_DEATH with a replacement, which tells Zentrix to leave the death alone entirely. Only one scenario can own a death, so anything that does should both provide and conflict with this and let validation keep the pair apart.

      Since:
      1.6.0
  • Method Details

    • of

      @NotNull public static @NotNull ScenarioCapability of(@NotNull @NotNull String id)
      Creates a capability key.
      Parameters:
      id - the capability identifier, lower-cased and trimmed; use a namespace:name form for anything an addon defines
      Throws:
      IllegalArgumentException - when the identifier is blank or malformed
    • id

      @NotNull public @NotNull String id()
      The normalized identifier this capability is compared by.
    • 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