Refactor Hook System to Component System with Meta-Annotation Support #192
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.
Refactors the hook system to a Spring-inspired component system with meta-annotation support, auto-discovery of post-processors, and proper cycle detection using Tarjan's SCC algorithm.
Renames
Hook→Component,AbstractHook→AbstractComponent@HookMeta→@ComponentMeta,@DependsOnHook→@DependsOnComponent@ConditionalOnCustom→@ConditionalOnHookService→ComponentService,surfHookApi→surfComponentApiMETA-INF/surf-api/hooks/→META-INF/surf-api/components/New Features
Separate
@Priorityannotation:Meta-annotation support —
@ComponentMetaon annotation classes enables custom component annotations:Auto-discovered post-processors — no annotation required:
New conditional annotations:
@ConditionalOnProperty(key, havingValue, matchIfMissing)@ConditionalOnMissingComponent(component)@ConditionalOnEnvironment(environments)Cycle Detection Rewrite
Replaced broken DFS-based cycle detection with Tarjan's SCC algorithm. Detects all cycle types (simple, complex, self-loops) with detailed error messages showing full dependency paths.
Unchanged
PAPI hook files (
SurfBukkitPAPIHook,SurfBukkitHookManager) remain in.hook.package — unrelated to component system.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
downloads.gradle.org/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Xmx64m -Xms64m -Dorg.gradle.appname=gradlew -jar /home/REDACTED/work/surf-api/surf-api/gradle/wrapper/gradle-wrapper.jar classes --no-daemon(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Refactor Hook System to Component System with Meta-Annotation Support
Overview
Refactor the current hook system to a more general component system inspired by Spring Framework. The system should support meta-annotations (annotations on annotations) and be more flexible.
Core Changes
1. Rename Hook → Component
Hookinterface →ComponentAbstractHook→AbstractComponent@HookMeta→@ComponentHookService→ComponentServicesurfHookApi→surfComponentApiSurfHookApi→SurfComponentApihook/→component/)2. Update Lifecycle Methods
Keep the existing lifecycle methods in
Componentinterface:bootstrap()- Initial bootstrap phaseload()- Loading phaseenable()- Enable phasedisable()- Disable phase3. Make @component a Meta-Annotation
Update
@Componentannotation to be usable on other annotations:4. Support Meta-Annotations in Processor
Update
HookSymbolProcessor→ComponentSymbolProcessorto:@Componentannotation on target classes AND their annotations@Servicewhich is annotated with@Component, treat the class as a componentExample meta-annotation support:
5. Auto-Discovery of ComponentPostProcessor
Update the processor to automatically discover
ComponentPostProcessorimplementations:5.1 Extend PluginComponentMeta
Add post-processor list to metadata:
5.2 Scan for ComponentPostProcessor in Symbol Processor
In
ComponentSymbolProcessor:ComponentPostProcessorinterfacePluginComponentMeta.postProcessorslistExample:
6. Rename and Extend Conditionals
@ConditionalOnCustom→@ConditionalOn@DependsOnClass,@DependsOnClassName,@DependsOnPlugin,@DependsOnOnePlugin,@DependsOnHook→@DependsOnComponent7. Add ComponentPostProcessor Interface
Create new interface for post-processing components after initialization: