Replace For* interface tag by annotation#16
Conversation
…ion (remove `Tag` system)
Tag interface system with annotationFor* interface marker by annotation
For* interface marker by annotationFor* interface tag by annotation
There was a problem hiding this comment.
Pull Request Overview
Replace legacy For* marker interfaces (and Optional/Required) with compile-time annotations to express component-entity compatibility, enforced via an annotation processor. Also refactors component tagging into a new components package (Behavior/Property/GameComponent), cleans up imports/usages, and minor structural tweaks across systems and utilities.
- Introduces @ForEntity and @SuitableEntity with SuitableEntityProcessor to validate compatibility.
- Removes old tag interfaces and updates factories/components to use annotations.
- Minor refactors: singleton holder placement, visibility modifiers, utils cooldown API, and formatting.
Reviewed Changes
Copilot reviewed 49 out of 56 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/resources/options/default.properties | Removed legacy default properties file. |
| src/main/java/com/github/codestorm/bounceverse/factory/WallFactory.java | Removed unused Side import. |
| src/main/java/com/github/codestorm/bounceverse/factory/BrickFactory.java | Replaced generic constraint tags with @SuitableEntity on type parameter; doc cleanup. |
| src/main/java/com/github/codestorm/bounceverse/data/types/EntityType.java | Doc links simplified; imports adjusted for javadoc. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/requirements/Required.java | Removed legacy requirement tag. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/requirements/Optional.java | Removed legacy requirement tag. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/entities/ForPowerUp.java | Removed legacy marker interface. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/entities/ForPaddle.java | Removed legacy marker interface. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/entities/ForBullet.java | Removed legacy marker interface. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/entities/ForBrick.java | Removed legacy marker interface. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/Tag.java | Removed base tag type. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/RequirementTag.java | Removed base requirement tag type. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/EntityTag.java | Removed base entity tag type. |
| src/main/java/com/github/codestorm/bounceverse/data/tags/ComponentTag.java | Removed base component tag type. |
| src/main/java/com/github/codestorm/bounceverse/data/meta/entities/SuitableEntityProcessor.java | Added annotation processor for @SuitableEntity. |
| src/main/java/com/github/codestorm/bounceverse/data/meta/entities/SuitableEntity.java | New annotation to require suitable entity types. |
| src/main/java/com/github/codestorm/bounceverse/data/meta/entities/ForEntity.java | New annotation to mark components suitable for entity types. |
| src/main/java/com/github/codestorm/bounceverse/data/contracts/CanUndo.java | Added basic undoable contract. |
| src/main/java/com/github/codestorm/bounceverse/core/systems/UISystem.java | Made final; reordered singleton/access methods. |
| src/main/java/com/github/codestorm/bounceverse/core/systems/System.java | Constructor placement tweak. |
| src/main/java/com/github/codestorm/bounceverse/core/systems/PhysicSystem.java | Reordered holder and constructor. |
| src/main/java/com/github/codestorm/bounceverse/core/systems/InputSystem.java | Reordered holder class to bottom. |
| src/main/java/com/github/codestorm/bounceverse/core/systems/GameSystem.java | Reordered holder and constructor. |
| src/main/java/com/github/codestorm/bounceverse/core/UserSetting.java | Reordered inner Video class and constructor placement. |
| src/main/java/com/github/codestorm/bounceverse/core/SettingsManager.java | Constructor placement tweak. |
| src/main/java/com/github/codestorm/bounceverse/core/LaunchOptions.java | Constructor placement tweak. |
| src/main/java/com/github/codestorm/bounceverse/components/properties/bullet/BulletVelocity.java | Switched to new Behavior package and @ForEntity(BULLET). |
| src/main/java/com/github/codestorm/bounceverse/components/properties/brick/BrickShield.java | Switched to @ForEntity(BRICK) and javafx Side. |
| src/main/java/com/github/codestorm/bounceverse/components/properties/brick/BrickHealth.java | Switched to @ForEntity(BRICK); early returns expanded. |
| src/main/java/com/github/codestorm/bounceverse/components/properties/Width.java | Switched to new Property package; method reordering. |
| src/main/java/com/github/codestorm/bounceverse/components/properties/Velocity.java | Switched to new Property package; removed Optional. |
| src/main/java/com/github/codestorm/bounceverse/components/properties/Shield.java | Switched to new Property package; minor reordering. |
| src/main/java/com/github/codestorm/bounceverse/components/properties/Health.java | Switched to new Property package. |
| src/main/java/com/github/codestorm/bounceverse/components/behaviors/paddle/PaddleShrink.java | Renamed class; switched to new Behavior package and @ForEntity(PADDLE). |
| src/main/java/com/github/codestorm/bounceverse/components/behaviors/paddle/PaddleExpand.java | Switched to new Behavior package and @ForEntity(PADDLE). |
| src/main/java/com/github/codestorm/bounceverse/components/behaviors/brick/BrickExplode.java | Refactored explosion logic; @ForEntity(BRICK). |
| src/main/java/com/github/codestorm/bounceverse/components/behaviors/brick/BrickDrop.java | Switched to new Behavior package and @ForEntity(BRICK); minor ctor placement. |
| src/main/java/com/github/codestorm/bounceverse/components/behaviors/CanShoot.java | Removed Optional; adjusted API. |
| src/main/java/com/github/codestorm/bounceverse/components/_old/powerup/PowerUp.java | Reordered constructors. |
| src/main/java/com/github/codestorm/bounceverse/components/_old/brick/ExplodeBrick.java | Constant placement tweak. |
| src/main/java/com/github/codestorm/bounceverse/components/_old/base/EntityComponent.java | Removed unused Optional import. |
| src/main/java/com/github/codestorm/bounceverse/components/Property.java | Moved to new package; extends GameComponent. |
| src/main/java/com/github/codestorm/bounceverse/components/GameComponent.java | New sealed base for Property/Behavior. |
| src/main/java/com/github/codestorm/bounceverse/components/Behavior.java | Moved to new package; extends GameComponent. |
| src/main/java/com/github/codestorm/bounceverse/Utils.java | Added constructors/fields to Cooldown; moved utility constructors. |
| src/main/java/com/github/codestorm/bounceverse/Bounceverse.java | Reordered main method before overrides. |
| .run/bytecode.run.xml | Formatting changes only. |
| .github/git-commit-instructions.md | Formatting/word-wrapping only. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/java/com/github/codestorm/bounceverse/components/behaviors/CanShoot.java
Outdated
Show resolved
Hide resolved
src/main/java/com/github/codestorm/bounceverse/data/meta/entities/SuitableEntityProcessor.java
Outdated
Show resolved
Hide resolved
| final var actualClassElement = | ||
| processingEnv.getTypeUtils().asElement(requireParameter.asType()); | ||
| if (actualClassElement == null) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
When @SuitableEntity is used on a varargs parameter, asType() is an array type and asElement() returns null; the check silently skips validation. Unwrap ArrayType to its component type before calling asElement(), so array parameters (e.g., BrickComponent...) are validated.
| processingEnv | ||
| .getMessager() | ||
| .printMessage(Diagnostic.Kind.ERROR, message, requireParameter); | ||
| } |
There was a problem hiding this comment.
If the component class lacks @ForEntity, no error is reported (the check only runs when actualAnnotation != null). Add an else branch to emit a diagnostic when the requirement cannot be verified because @ForEntity is missing.
| } | |
| } | |
| } else { | |
| final var message = String.format( | |
| "Parameter '%s' requires a component class suitable for '%s', but '%s' does not have the required @ForEntity annotation, so the requirement cannot be verified.", | |
| requireParameter.getSimpleName(), | |
| String.join(", ", requiredTypes.stream().map(Enum::name).toArray(String[]::new)), | |
| actualClassElement.getSimpleName()); | |
| processingEnv | |
| .getMessager() | |
| .printMessage(Diagnostic.Kind.ERROR, message, requireParameter); |
| * gạch và dành được điểm số cao nhất. Nhưng liệu mọi thứ chỉ đơn giản như vậy?</i> | ||
| */ | ||
| public final class Bounceverse extends GameApplication { | ||
| static void main(String[] args) { |
There was a problem hiding this comment.
The JVM requires a public static void main(String[] args) entry point; package-private main may not be recognized by launchers (e.g., Gradle run or java -jar). Change to public static.
| static void main(String[] args) { | |
| public static void main(String[] args) { |
src/main/java/com/github/codestorm/bounceverse/components/behaviors/brick/BrickExplode.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 49 out of 56 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/java/com/github/codestorm/bounceverse/components/properties/brick/BrickShield.java
Show resolved
Hide resolved
| if (actualClassElement == null) { | ||
| continue; | ||
| } | ||
| final var actualAnnotation = actualClassElement.getAnnotation(ForEntity.class); |
There was a problem hiding this comment.
Missing null check for actualClassElement. If processingEnv.getTypeUtils().asElement() returns null (which is already checked on line 41), but this could still result in issues if the element is not properly typed.
| if (actualClassElement == null) { | |
| continue; | |
| } | |
| final var actualAnnotation = actualClassElement.getAnnotation(ForEntity.class); | |
| if (actualClassElement == null || !(actualClassElement instanceof TypeElement)) { | |
| continue; | |
| } | |
| final var actualAnnotation = ((TypeElement) actualClassElement).getAnnotation(ForEntity.class); |
| final var health = entity.getComponent(BrickHealth.class); | ||
| health.damage(1); |
There was a problem hiding this comment.
Using getComponent() without null check. This will throw an exception if the entity doesn't have a BrickHealth component. Should use getComponentOptional() or add null checking.
| final var health = entity.getComponent(BrickHealth.class); | |
| health.damage(1); | |
| entity.getComponentOptional(BrickHealth.class) | |
| .ifPresent(health -> health.damage(1)); |
* feat: Brick * feat(brick): add PowerBrick and update Brick, ExoplodeBrick, ProtectedBrick * docs(brick): add Javadoc for Brick, ExoplodeBrick, PowerBrick, ProtectedBrick * refactor(brick): remove NormalBrick and StrongBrick * feat(paddle): add ExpendPaddle, LaserPaddle, ShrinkPaddle and update Paddle * feat(paddle): add ExpendPaddle, LaserPaddle, ShrinkPaddle and update Paddle * refactor: remove brick and gameManager packages * feat(brick): refactor and document brick module (Factory, Component, Protected, Explode) * feat(game): add GameManager and BounceVerseApp for game initialization * feat(paddle): add PaddleComponent and variants (Expand, Shrink, Laser, Bullet) with factory integration * feat(brick): implement explosion logic and health management refactor * feat(components): add new paddle behaviors and properties (Bullet, Width); refactor brick to components structure * refactor: migrate paddle and bullet systems to new structure * refactor(paddle): adjust PaddleFactory, Shoot and Width property for move and scaling * feat(wall): add WallFactory and Wall components with Move property for paddle collision * feat(physics): handle paddle-wall collision in CollisionSystem * feat(data): add WALL entity type for collision system * feat(behavior): update BrickExplode logic for new collision handling * feat(paddle-wall): add Move component update and WallFactory with correct sides and spawn registration * (skip ci) refactor: rename components and update imports for consistency Refactored various components by renaming `BehaviorComponent` to `Behavior`, `OptionalTag` to `Optional`, and `PropertyComponent` to `Property`. Updated imports accordingly to maintain consistency across the codebase. * [skip ci] Add and refactor Systems, Core (#15) * [skip ci] feat(core): implement game systems and refactor initialization - Introduced GameSystem, InputSystem, PhysicSystem, and UISystem for better organization and modularity (applies game logic, input handling, physics, and UI settings). - Refactored Bounceverse to utilize new systems for initialization and configuration management. - Updated credits and settings files for improved user experience. * [skip ci] ci: update CI configuration for Spotless checks and builds - Rename linting.yml to spotlessCheck.yml for clarity - Add concurrency settings to optimize CI runs - Modify job conditions to skip CI based on commit messages - Implement automatic code formatting application on failure * [skip ci] feat(core): initialize Video instance in UserSetting Add a new Video instance to the UserSetting class to ensure proper initialization and avoid null references. This change enhances the reliability of video settings management. * [skip ci] refactor: rename spotlessCheck.yml to spotless.yml for consistency * [skip ci] chore: Remove log files * Replace `For*` interface tag by annotation (#16) * [skip ci] refactor: replace `For*` interface with `Suitable*` annotation (remove `Tag` system) * [skip ci] chore: reformat code and optimize import * [skip ci] chore: update JAVA_LANGUAGE to 24_PREVIEW * [skip ci] refactor: Assign new `For*` annotation for components * [skip ci] fix: fix null ref on `Utils.Time.Cooldown#current` * feat: add Attack and Attributes components for entity interactions Introduce Attack and Attributes classes to manage damage and defense mechanics for entities. The Attack class allows entities to inflict damage based on their attributes, while the Attributes class holds general property values like defense. This enhances gameplay dynamics by enabling combat interactions. * fix(paddle): fix freeze paddle * ci: update CI conditions to use startsWith for skip ci Modified CI configuration to use startsWith instead of contains for detecting '[skip ci]' in commit messages, improving clarity and functionality. * chore: correct spelling and rename classes for consistency Renamed `HeathDeath` to `HealthDeath` and fixed spelling in `CanExecute` documentation. These changes improve code readability and maintainability. --------- Co-authored-by: Mai Thành <62001770+thnhmai06@users.noreply.github.com> Co-authored-by: ManhTanTran <199453990+tunpogaz@users.noreply.github.com>
* feat: Brick * feat(brick): add PowerBrick and update Brick, ExoplodeBrick, ProtectedBrick * docs(brick): add Javadoc for Brick, ExoplodeBrick, PowerBrick, ProtectedBrick * refactor(brick): remove NormalBrick and StrongBrick * feat(paddle): add ExpendPaddle, LaserPaddle, ShrinkPaddle and update Paddle * feat(paddle): add ExpendPaddle, LaserPaddle, ShrinkPaddle and update Paddle * refactor: remove brick and gameManager packages * feat(brick): refactor and document brick module (Factory, Component, Protected, Explode) * feat(game): add GameManager and BounceVerseApp for game initialization * feat(paddle): add PaddleComponent and variants (Expand, Shrink, Laser, Bullet) with factory integration * feat(brick): implement explosion logic and health management refactor * feat(components): add new paddle behaviors and properties (Bullet, Width); refactor brick to components structure * refactor: migrate paddle and bullet systems to new structure * refactor(paddle): adjust PaddleFactory, Shoot and Width property for move and scaling * feat(wall): add WallFactory and Wall components with Move property for paddle collision * feat(physics): handle paddle-wall collision in CollisionSystem * feat(data): add WALL entity type for collision system * feat(behavior): update BrickExplode logic for new collision handling * feat(paddle-wall): add Move component update and WallFactory with correct sides and spawn registration * (skip ci) refactor: rename components and update imports for consistency Refactored various components by renaming `BehaviorComponent` to `Behavior`, `OptionalTag` to `Optional`, and `PropertyComponent` to `Property`. Updated imports accordingly to maintain consistency across the codebase. * [skip ci] Add and refactor Systems, Core (#15) * [skip ci] feat(core): implement game systems and refactor initialization - Introduced GameSystem, InputSystem, PhysicSystem, and UISystem for better organization and modularity (applies game logic, input handling, physics, and UI settings). - Refactored Bounceverse to utilize new systems for initialization and configuration management. - Updated credits and settings files for improved user experience. * [skip ci] ci: update CI configuration for Spotless checks and builds - Rename linting.yml to spotlessCheck.yml for clarity - Add concurrency settings to optimize CI runs - Modify job conditions to skip CI based on commit messages - Implement automatic code formatting application on failure * [skip ci] feat(core): initialize Video instance in UserSetting Add a new Video instance to the UserSetting class to ensure proper initialization and avoid null references. This change enhances the reliability of video settings management. * [skip ci] refactor: rename spotlessCheck.yml to spotless.yml for consistency * [skip ci] chore: Remove log files * Replace `For*` interface tag by annotation (#16) * [skip ci] refactor: replace `For*` interface with `Suitable*` annotation (remove `Tag` system) * [skip ci] chore: reformat code and optimize import * [skip ci] chore: update JAVA_LANGUAGE to 24_PREVIEW * [skip ci] refactor: Assign new `For*` annotation for components * [skip ci] fix: fix null ref on `Utils.Time.Cooldown#current` * feat: add Attack and Attributes components for entity interactions Introduce Attack and Attributes classes to manage damage and defense mechanics for entities. The Attack class allows entities to inflict damage based on their attributes, while the Attributes class holds general property values like defense. This enhances gameplay dynamics by enabling combat interactions. * fix(paddle): fix freeze paddle * ci: update CI conditions to use startsWith for skip ci Modified CI configuration to use startsWith instead of contains for detecting '[skip ci]' in commit messages, improving clarity and functionality. * chore: correct spelling and rename classes for consistency Renamed `HeathDeath` to `HealthDeath` and fixed spelling in `CanExecute` documentation. These changes improve code readability and maintainability. --------- Co-authored-by: Mai Thành <62001770+thnhmai06@users.noreply.github.com>
* feat: Brick * feat(brick): add PowerBrick and update Brick, ExoplodeBrick, ProtectedBrick * docs(brick): add Javadoc for Brick, ExoplodeBrick, PowerBrick, ProtectedBrick * refactor(brick): remove NormalBrick and StrongBrick * feat(paddle): add ExpendPaddle, LaserPaddle, ShrinkPaddle and update Paddle * feat(paddle): add ExpendPaddle, LaserPaddle, ShrinkPaddle and update Paddle * refactor: remove brick and gameManager packages * feat(brick): refactor and document brick module (Factory, Component, Protected, Explode) * feat(game): add GameManager and BounceVerseApp for game initialization * feat(paddle): add PaddleComponent and variants (Expand, Shrink, Laser, Bullet) with factory integration * feat(brick): implement explosion logic and health management refactor * feat(components): add new paddle behaviors and properties (Bullet, Width); refactor brick to components structure * refactor: migrate paddle and bullet systems to new structure * refactor(paddle): adjust PaddleFactory, Shoot and Width property for move and scaling * feat(wall): add WallFactory and Wall components with Move property for paddle collision * feat(physics): handle paddle-wall collision in CollisionSystem * feat(data): add WALL entity type for collision system * feat(behavior): update BrickExplode logic for new collision handling * feat(paddle-wall): add Move component update and WallFactory with correct sides and spawn registration * (skip ci) refactor: rename components and update imports for consistency Refactored various components by renaming `BehaviorComponent` to `Behavior`, `OptionalTag` to `Optional`, and `PropertyComponent` to `Property`. Updated imports accordingly to maintain consistency across the codebase. * [skip ci] Add and refactor Systems, Core (#15) * [skip ci] feat(core): implement game systems and refactor initialization - Introduced GameSystem, InputSystem, PhysicSystem, and UISystem for better organization and modularity (applies game logic, input handling, physics, and UI settings). - Refactored Bounceverse to utilize new systems for initialization and configuration management. - Updated credits and settings files for improved user experience. * [skip ci] ci: update CI configuration for Spotless checks and builds - Rename linting.yml to spotlessCheck.yml for clarity - Add concurrency settings to optimize CI runs - Modify job conditions to skip CI based on commit messages - Implement automatic code formatting application on failure * [skip ci] feat(core): initialize Video instance in UserSetting Add a new Video instance to the UserSetting class to ensure proper initialization and avoid null references. This change enhances the reliability of video settings management. * [skip ci] refactor: rename spotlessCheck.yml to spotless.yml for consistency * [skip ci] chore: Remove log files * Replace `For*` interface tag by annotation (#16) * [skip ci] refactor: replace `For*` interface with `Suitable*` annotation (remove `Tag` system) * [skip ci] chore: reformat code and optimize import * [skip ci] chore: update JAVA_LANGUAGE to 24_PREVIEW * [skip ci] refactor: Assign new `For*` annotation for components * [skip ci] fix: fix null ref on `Utils.Time.Cooldown#current` * feat: add Attack and Attributes components for entity interactions Introduce Attack and Attributes classes to manage damage and defense mechanics for entities. The Attack class allows entities to inflict damage based on their attributes, while the Attributes class holds general property values like defense. This enhances gameplay dynamics by enabling combat interactions. * fix(paddle): fix freeze paddle * ci: update CI conditions to use startsWith for skip ci Modified CI configuration to use startsWith instead of contains for detecting '[skip ci]' in commit messages, improving clarity and functionality. * chore: correct spelling and rename classes for consistency Renamed `HeathDeath` to `HealthDeath` and fixed spelling in `CanExecute` documentation. These changes improve code readability and maintainability. --------- Co-authored-by: Mai Thành <62001770+thnhmai06@users.noreply.github.com>
* [skip ci] refactor: replace `For*` interface with `Suitable*` annotation (remove `Tag` system) * [skip ci] chore: reformat code and optimize import * [skip ci] chore: update JAVA_LANGUAGE to 24_PREVIEW * [skip ci] refactor: Assign new `For*` annotation for components * [skip ci] fix: fix null ref on `Utils.Time.Cooldown#current`
No description provided.