Modules
Ranks API
Read rank views, inspect players, apply rank changes and register permission contexts with RankService and its companions.
Reading an online player's view
api.service(RankService.class)
.flatMap(ranks -> ranks.online(player.getUniqueId()))
.ifPresent(state -> {
long revision = state.revision;
// state.ranks: catalog at this revision, state.user: grants and rules
});online() reads memory and never does I/O. During an invalidation it may be empty; wait for the next RankStateEvent.
Actors
Every authorized operation takes a RankService.Actor:
RankService.Actor actor = new RankService.Actor(player.getUniqueId(), false, RankContexts.EMPTY, player::isOnline);
RankService.Actor console = new RankService.Actor(null, true);The last argument tells sofyCore whether the actor is still current when the operation commits.
Applying a change
changeAsync(actor, change) applies a RankService.Change. Actions are CREATE, EDIT, DELETE, RANK_PERMISSION, INHERIT, TEMPLATE, OWNER, GRANT, REVOKE, EXTEND, USER_PERMISSION, COLOR, RANK_RULE, USER_RULE and CLOCK. Authorization is evaluated again when the change commits, exactly as with /access.
Custom contexts
AutoCloseable reg = api.service(RankContextService.class).get()
.register(java.util.Collections.singleton("arena"), uuid -> java.util.Collections.singletonMap("arena", arenaOf(uuid)));Callbacks run on the platform thread and must only read local memory. Call refresh(uuid) when the value changes.