-
Notifications
You must be signed in to change notification settings - Fork 0
feat: hook api #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: version/1.21.11
Are you sure you want to change the base?
feat: hook api #188
Conversation
…rations for Bukkit, Velocity, and core APIs
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1112ea2a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
...rf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt
Show resolved
Hide resolved
...ity-server/src/main/kotlin/dev/slne/surf/surfapi/velocity/server/hook/VelocityHookService.kt
Show resolved
Hide resolved
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Introduces a modular hook system for Surf API plugins, including compile-time hook metadata generation and runtime hook discovery/lifecycle management across supported server platforms.
Changes:
- Added hook API + lifecycle (
AbstractHook,SurfHookApi) and dependency annotations (DependsOn*). - Implemented runtime hook loading/validation via
HookServicewith platform implementations (Paper/Bukkit, Velocity) and a fallback. - Added a KSP processor to generate
surf-hooks.jsonduring compilation and wired it into the gradle processor module.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| surf-api-velocity/surf-api-velocity-server/src/main/kotlin/dev/slne/surf/surfapi/velocity/server/hook/VelocityHookService.kt | Velocity implementation of HookService for resource/classloader access and plugin checks. |
| surf-api-gradle-plugin/surf-api-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider | Registers the new hook KSP processor provider alongside the existing AutoService provider. |
| surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/util/util.kt | Adds shared KSP utilities for deriving binary class names. |
| surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/PluginHookMeta.kt | Defines the serialized hook metadata model used by the processor output. |
| surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessorProvider.kt | Adds KSP provider for hook metadata generation. |
| surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt | Implements hook annotation scanning and surf-hooks.json generation. |
| surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/autoservice/AutoServiceSymbolProcessor.kt | Refactors to use the shared binary-name utility. |
| surf-api-gradle-plugin/surf-api-processor/build.gradle.kts | Enables serialization support and adds JSON serialization dependency for the processor. |
| surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/impl/hook/SurfHookApiImpl.kt | Runtime implementation of SurfHookApi delegating to HookService. |
| surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/PluginHookMeta.kt | Runtime model for decoding surf-hooks.json. |
| surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/HookServiceFallback.kt | Fallback service when hooks aren’t supported on the current platform. |
| surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/HookService.kt | Core runtime hook discovery, dependency checks, caching, and ordering. |
| surf-api-core/surf-api-core-server/src/main/java/dev/slne/surf/surfapi/core/server/impl/reflection/SurfInvocationHandlerJava.java | Updates reflection proxy implementation to use privateLookupIn and adjusts method resolution. |
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/hook/requirement/DependsOnPlugin.kt | Adds plugin dependency annotation. |
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/hook/requirement/DependsOnOnePlugin.kt | Adds “one-of” plugin dependency annotation. |
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/hook/requirement/DependsOnClassName.kt | Adds class-name dependency annotation. |
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/hook/requirement/DependsOnClass.kt | Adds class dependency annotation. |
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/hook/SurfHookApi.kt | Defines the public hook API entrypoint and singleton accessor. |
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/hook/HookMeta.kt | Adds hook metadata annotation (priority). |
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/hook/AbstractHook.kt | Adds base hook lifecycle + priority ordering. |
| surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/reflection/Reflection.kt | Registers JavaPluginProxy and adjusts classloader access usage. |
| surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/reflection/JavaPluginProxy.kt | Adds reflection proxy for accessing JavaPlugin classloader. |
| surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/impl/glow/entity/EntityGlowingData.kt | Fixes TeamData companion access. |
| surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/hook/PaperHookService.kt | Paper/Bukkit implementation of HookService. |
| surf-api-bukkit/surf-api-bukkit-plugin-test/src/main/kotlin/dev/slne/surf/surfapi/bukkit/test/hook/TestHook.kt | Adds an example hook demonstrating dependency annotations and lifecycle logs. |
| surf-api-bukkit/surf-api-bukkit-plugin-test/src/main/kotlin/dev/slne/surf/surfapi/bukkit/test/BukkitPluginMain.kt | Updates test plugin to invoke hook lifecycle in async plugin lifecycle methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...rf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt
Outdated
Show resolved
Hide resolved
...ity-server/src/main/kotlin/dev/slne/surf/surfapi/velocity/server/hook/VelocityHookService.kt
Show resolved
Hide resolved
...c/main/java/dev/slne/surf/surfapi/core/server/impl/reflection/SurfInvocationHandlerJava.java
Show resolved
Hide resolved
...e/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/HookService.kt
Outdated
Show resolved
Hide resolved
...shared-internal/src/main/kotlin/dev/slne/surf/surfapi/shared/internal/hook/PluginHookMeta.kt
Show resolved
Hide resolved
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
|
@twisti-dev I've opened a new pull request, #190, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 53 out of 55 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| validHooks.forEach { (meta, _) -> visit(meta.className) } | ||
| return sorted.sortedBy { it.priority } |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
topologicalSort builds a dependency-respecting order via DFS in sorted, but the final sorted.sortedBy { it.priority } reorders hooks and can violate declared DependsOnHook ordering (a dependent hook may run before its dependency). Return the computed topological order as-is, or incorporate priority as a tie-breaker during traversal / Kahn’s algorithm without re-sorting the final list.
| return sorted.sortedBy { it.priority } | |
| return sorted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
...rf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt
Show resolved
Hide resolved
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
|
@twisti-dev I've opened a new pull request, #191, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
…ng DFS Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com>
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com>
Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com>
…rithm with priority tie-breaking (#191)
This pull request introduces a new modular hook system for the Surf API, enabling plugins to declare and manage dependencies on classes and other plugins, and providing a lifecycle for hooks. The changes include the addition of hook metadata annotations, hook requirement annotations, a core hook API, a base
AbstractHookclass, and the backend services for hook discovery and management. The plugin test and server modules are updated to use this new system.Core Hook System Implementation:
AbstractHookbase class, which manages hook lifecycle (bootstrap, load, enable, disable) and enforces the presence ofHookMetaannotation. Hooks are now comparable by priority.HookMetaannotation for hooks, allowing specification of hook priority.DependsOnClass,DependsOnClassName,DependsOnPlugin, andDependsOnOnePlugin, enabling hooks to declare dependencies on classes or plugins. [1] [2] [3] [4]SurfHookApiinterface and singleton accessor for managing hook lifecycle and querying hooks by type or owner.HookServiceabstract class, providing hook discovery, dependency checks, and lifecycle management, with support for caching and logging missing dependencies.Bukkit/Server Integration:
PaperHookServiceimplementation to integrate the hook system with Bukkit/Paper servers, handling plugin resource loading, classloader access, plugin presence checks, and logging.JavaPluginProxyinterface and integrated it into the server reflection utilities for classloader access. [1] [2]BukkitPluginMain) to use the new async lifecycle methods and call the hook API at appropriate stages.Example Hook and Usage:
TestHookclass demonstrating the use of the new hook system, including requirement annotations and lifecycle logging.Other Improvements and Fixes:
MethodHandles.privateLookupInfor better encapsulation and compatibility, and updated method finding logic. [1] [2] [3] [4] [5] [6]EntityGlowingDatato accessTeamDatacompanion object correctly.These changes collectively introduce a robust, extensible hook system, improving modularity and dependency management for plugins in the Surf API ecosystem.