Class ScenarioCapability
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final ScenarioCapabilityTaking a player's death over from Zentrix's own elimination handling.static final ScenarioCapabilityDeciding where the deathmatch happens, in place of Zentrix's copied template arena.static final ScenarioCapabilityAdding, upgrading or transferring vanilla enchantments on items players end up holding.static final ScenarioCapabilityChanging who players appear to be — their name, their skin, or both.static final ScenarioCapabilityDeciding when the match is over, in place of Zentrix's own alive-team count.static final ScenarioCapabilityPinning or driving the world clock of the match's worlds.static final ScenarioCapabilityPinning or driving the weather of the match's worlds. -
Method Summary
-
Field Details
-
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
Pinning or driving the world clock of the match's worlds. -
WORLD_WEATHER
Pinning or driving the weather of the match's worlds. -
WIN_CONDITION
Deciding when the match is over, in place of Zentrix's own alive-team count. -
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
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
Taking a player's death over from Zentrix's own elimination handling.Declare this whenever the scenario answers
GameplayHooks.PLAYER_DEATHwith 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
Creates a capability key.- Parameters:
id- the capability identifier, lower-cased and trimmed; use anamespace:nameform for anything an addon defines- Throws:
IllegalArgumentException- when the identifier is blank or malformed
-
id
The normalized identifier this capability is compared by. -
equals
-
hashCode
public int hashCode() -
toString
-