feat(core): add SurfEventBus for cross-plugin events#320
Draft
Copilot wants to merge 1 commit intoversion/26.1from
Draft
feat(core): add SurfEventBus for cross-plugin events#320Copilot wants to merge 1 commit intoversion/26.1from
Copilot wants to merge 1 commit intoversion/26.1from
Conversation
…ple Paper events Agent-Logs-Url: https://github.com/SLNE-Development/surf-api/sessions/5ea8a361-4ecf-4c77-bff6-5f750e2f54b9 Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
twisti-dev
April 23, 2026 08:39
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a central, platform-independent
SurfEventBusso surf-* plugins (surf-playtime, surf-clan, …) can define and fire their own events and listen to others' events without taking a direct dependency on the firing plugin.Core API (
surf-api-core,dev.slne.surf.api.core.event)SurfEventparent +SurfSyncEvent/SurfAsyncEventbase classes andSurfCancellableEventmixin (withisCancelled/cancel()).SurfEventPriorityenum (LOWEST…MONITOR) and@SurfEventHandler(priority, ignoreCancelled)annotation.SurfEventBusinterface withcompanion object : SurfEventBus by requiredService(), plusregisterListeners(vararg),unregisterListeners(vararg), and inlineon<T> { … }/onAsync<T> { … }DSL helpers that return a token usable for unregistration.Invoker infrastructure (
dev.slne.surf.api.core.event.invoker,@InternalInvokerApi)SurfSyncEventInvokerandSurfAsyncEventInvokerfunctional interfaces.SurfSyncEventInvokerTemplate,SurfAsyncEventInvokerTemplate) that reuse the existingInvokerFactory/HiddenInvokerUtil(sync vialoadClassData, async vialoadClassDataWithAutoSuspend, branching onDATA.isSuspend()).Implementation (
surf-api-core-server)SurfEventBusImplregistered via@AutoService(SurfEventBus::class)and guarded withcheckInstantiationByServiceLoader().SurfEvent-subtype parameter;suspendrejected forSurfSyncEventhandlers.ConcurrentHashMap<Class, ConcurrentSkipListMap<Priority, CopyOnWriteArrayList<RegisteredHandler>>>. Dispatch matches every registered type assignable from the concrete event class, sorts the union by priority, honoursignoreCancelled, and isolates handler exceptions via Flogger.suspendCoroutineUninterceptedOrReturn, supporting bothsuspendand non-suspendhandlers transparently.Sample events (
surf-api-paper,dev.slne.surf.api.paper.event.surf)AbstractSurfPlayerEvent(playerUuid)async base.PlayerAfkStateChangeEvent(playerUuid, fromState, toState)implementingSurfCancellableEvent.Usage
Kotlin ABI dumps for
surf-api-coreandsurf-api-paperare regenerated. The Bukkit/Velocity event systems are untouched and coexist with this bus.