Getting started
Anything you can write in zones.yml, you can build from code instead. What the API adds is rules
that read live game state: reveal whoever holds the point right now, reveal the top three of the
standings, and let both follow the game without any code running on change.
Set up the project
Section titled “Set up the project”-
Add the dependency.
The artifact holds interfaces only, the implementation lives in the plugin. Depend on it with
compileOnlyin Gradle orprovidedin Maven, and do not shade it into your jar.build.gradle repositories {maven {name = 'soma'url = 'https://sowmha.github.io/maven/'}}dependencies {compileOnly 'top.soma:hider-api:1.16.5'}build.gradle.kts repositories {maven("https://sowmha.github.io/maven/") {name = "soma"}}dependencies {compileOnly("top.soma:hider-api:1.16.5")}pom.xml <repositories><repository><id>soma</id><url>https://sowmha.github.io/maven/</url></repository></repositories><dependencies><dependency><groupId>top.soma</groupId><artifactId>hider-api</artifactId><version>1.16.5</version><scope>provided</scope></dependency></dependencies> -
Declare the plugin.
plugin.yml depend: [SomaHider]Use
softdependinstead if your plugin should still work when SomaHider is absent. You then guard your calls withSomaHiderProvider.getOrNull(). -
Get the API.
import top.soma.hider.api.SomaHider;import top.soma.hider.api.SomaHiderProvider;SomaHider hider = SomaHiderProvider.get();Call this from
onEnable()or later, never from your constructor oronLoad(): SomaHider registers itself while it enables, so it does not exist yet at those points.
| Method | Returns |
|---|---|
SomaHiderProvider.get() | The API, or throws IllegalStateException if SomaHider is not loaded. |
SomaHiderProvider.getOrNull() | The API, or null. |
SomaHiderProvider.isAvailable() | Whether the API is registered. |
Open a zone
Section titled “Open a zone”import java.time.Duration;
import top.soma.hider.api.rule.Reveal;import top.soma.hider.api.zone.HiderZone;import top.soma.hider.api.zone.Region;
Region arena = Region.circle(center, 40.0);
HiderZone zone = SomaHiderProvider.get() .hide(arena) .named("arena") .duration(Duration.ofMinutes(30)) .reveal(Reveal.sameGroup()) .open();Everyone inside the circle is now hidden from everyone else, except that players sharing a group see each other. Close it when your event ends:
zone.close();A zone opened with a duration also closes on its own. One opened without runs until you close it:
unlike /sh start, the API applies no ceiling of its own, so nothing will stop a zone you forget.
Teach it who belongs together
Section titled “Teach it who belongs together”Reveal.sameGroup() needs to know what a group is, and only your plugin can answer that. A
GroupResolver maps a player to a group id, or to null when they belong to none. A null group is
never revealed.
.groupResolver(player -> { Faction faction = FactionUtils.getFactionByPlayer(player); return faction != null && faction.isNormal() ? faction.getId() : null;})Set it once on the zone, and every group-based rule uses it.
Where to go next
Section titled “Where to go next”A real integration is the page to read next. It walks through a working event plugin end to end, and the patterns in it cover most of what you will write.
For the details: zones for the builder and regions, reveal rules for the rule catalogue and how to keep them cheap, and disguises for changing the look from code.