Skip to content

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.

EventFieldsFired whenCancellable
StorageReadyEventnet.sofycore.api.storageSofyCoreApi api()Storage and Redis connected; published on the Minecraft thread.No
UserSessionReadyEventnet.sofycore.api.userUUID sessionId(), UserProfile user()A player's base profile is loaded for a new session.No
UserSessionClosedEventnet.sofycore.api.userUUID sessionId(), UUID userId()A session closed (quit or shutdown).No
RankStateEventnet.sofycore.api.rankUUID playerId, long revision, boolean availableA rank view was applied or became unusable on this server.No
ModerationEventnet.sofycore.api.moderationString id, String action, Sanction sanction, Report reportA committed sanction issue/removal or report transition.No
FreezeEventnet.sofycore.api.staffType type (FROZEN, UNFROZEN, DISCONNECTED), FreezeState state, String actorA freeze change received by this server.No
VanishStateEventnet.sofycore.api.staffUUID playerId, boolean vanishedA player's vanish state changed.No
AnnouncementBroadcastEventnet.sofycore.api.announcementString id(), int recipients()A local or global announcement was delivered.No

Registering a listener

Java
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, VanishStateEvent and ModerationEvent are published on the server thread of each server that applies the change.
  • StorageReadyEvent is published on the Minecraft thread once storage is connected.
  • UserSessionReadyEvent and UserSessionClosedEvent are published on the server thread with isolated listeners.
  • Do not keep a RankService.State after a RankStateEvent with available = false.