API Reference
Events
Events published on sofyCore's EventBus, when they fire, what data they carry and how to subscribe to them.
sofyCore events are plain Java objects published on its own EventBus, not Bukkit events. Subscribe with api.events().subscribe(Type.class, listener). None of them is cancellable: they report committed changes.
| Event | Fields | Fired when | Cancellable |
|---|---|---|---|
StorageReadyEventnet.sofycore.api.storage | SofyCoreApi api() | Storage and Redis connected; published on the Minecraft thread. | No |
UserSessionReadyEventnet.sofycore.api.user | UUID sessionId(), UserProfile user() | A player's base profile is loaded for a new session. | No |
UserSessionClosedEventnet.sofycore.api.user | UUID sessionId(), UUID userId() | A session closed (quit or shutdown). | No |
RankStateEventnet.sofycore.api.rank | UUID playerId, long revision, boolean available | A rank view was applied or became unusable on this server. | No |
ModerationEventnet.sofycore.api.moderation | String id, String action, Sanction sanction, Report report | A committed sanction issue/removal or report transition. | No |
FreezeEventnet.sofycore.api.staff | Type type (FROZEN, UNFROZEN, DISCONNECTED), FreezeState state, String actor | A freeze change received by this server. | No |
VanishStateEventnet.sofycore.api.staff | UUID playerId, boolean vanished | A player's vanish state changed. | No |
AnnouncementBroadcastEventnet.sofycore.api.announcement | String id(), int recipients() | A local or global announcement was delivered. | No |
Registering a listener
AutoCloseable sub = api.events().subscribe(RankStateEvent.class, event -> {
if (!event.available) return; // the view was invalidated
// refresh something for event.playerId
});
// later, in onDisable:
sub.close();Execution notes
RankStateEvent,FreezeEvent,VanishStateEventandModerationEventare published on the server thread of each server that applies the change.StorageReadyEventis published on the Minecraft thread once storage is connected.UserSessionReadyEventandUserSessionClosedEventare published on the server thread with isolated listeners.- Do not keep a
RankService.Stateafter aRankStateEventwithavailable = false.