Skip to content

Conversation

@vLuckyyy
Copy link
Member

Fixes: #990 #480

Default Commands:
2025-07-22_02 52 38
2025-07-22_02 51 54
2025-07-22_02 51 59
2025-07-22_02 52 05
2025-07-22_02 52 11
2025-07-22_02 52 21

@vLuckyyy vLuckyyy requested a review from a team as a code owner July 22, 2025 00:59
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

Walkthrough

This update adds a complete system for custom commands. It introduces a CustomCommand class to define commands, a Bukkit wrapper to execute them, and a configuration class to set up commands with various message styles like titles and chat. A registry class handles registering these commands with the server using reflection, and a setup class listens for initialization events to trigger the registration. The system is designed with dependency injection and event subscription, allowing commands to be loaded and registered dynamically at startup.

Estimated code review effort

3 (~45 minutes)

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Jul 22, 2025

📦 Development Build Ready

Warning

Do not use this build in production. It is for testing purposes only and may be unstable.

👉 Click here to download the JAR

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandRegistry.java (1)

35-45: Add null safety checks for command properties.

Consider adding validation to ensure command properties aren't null before creating the wrapper, which could prevent runtime issues.

 private void registerCustomCommand(CustomCommand customCommand) {
+    if (customCommand.getCommandName() == null || customCommand.getCommandName().isEmpty()) {
+        return; // Skip invalid commands
+    }
+    
     CustomCommandBukkitWrapper customCommandBukkitWrapper = new CustomCommandBukkitWrapper(
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f69398a and 4928372.

📒 Files selected for processing (5)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandBukkitWrapper.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandConfig.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandRegistry.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandSetup.java (1 hunks)
🧠 Learnings (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandConfig.java (1)

Learnt from: vLuckyyy
PR: #856
File: eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/data/WarpDataConfig.java:19-20
Timestamp: 2025-01-12T13:03:07.239Z
Learning: Configuration classes in EternalCore (those implementing ReloadableConfig and annotated with @ConfigurationFile) don't need thread-safe collections as they are managed by the configuration system which handles synchronization.

🧰 Additional context used
🧠 Learnings (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandConfig.java (1)

Learnt from: vLuckyyy
PR: #856
File: eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/data/WarpDataConfig.java:19-20
Timestamp: 2025-01-12T13:03:07.239Z
Learning: Configuration classes in EternalCore (those implementing ReloadableConfig and annotated with @ConfigurationFile) don't need thread-safe collections as they are managed by the configuration system which handles synchronization.

🔇 Additional comments (4)
eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandSetup.java (1)

8-22: Clean setup implementation!

This class follows the single responsibility principle well. The event-driven initialization approach is a good pattern for plugin startup.

eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommand.java (1)

7-33: Good data model design!

This class serves as a clean data model for custom commands. The public fields work well for configuration classes, and having both constructors gives flexibility.

eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandBukkitWrapper.java (1)

11-40: Solid command wrapper implementation!

The wrapper correctly extends Bukkit's Command and handles execution by sending the configured notice. Returning true is appropriate for these notification-style commands.

eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandConfig.java (1)

16-142: Excellent configuration design with great examples!

This config class provides comprehensive documentation and showcases different notification types beautifully. The example commands demonstrate the flexibility of the Notice system well.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommand.java (1)

21-23: Remove unnecessary static factory method.

The static factory method of doesn't add any value over the existing constructor and creates code duplication.

-public static CustomCommand of(String commandName, List<String> aliases, Notice message) {
-    return new CustomCommand(commandName, aliases, message);
-}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4928372 and e9b8431.

📒 Files selected for processing (3)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandConfig.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandRegistry.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandConfig.java
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/customcommand/CustomCommandRegistry.java

Copy link
Member

@Jakubk15 Jakubk15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I wonder whether it is possible to do through the LiteCommands library instead of using the Bukkit methods

@vLuckyyy
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new feature for creating custom commands via configuration. The implementation is solid and follows the project's structure. I've identified a few areas for improvement, mainly concerning data redundancy in the configuration that could lead to user errors, and some minor code style/readability enhancements. The most significant suggestion is to refactor how command names are handled to use the configuration map key as the single source of truth, which will make the feature more robust and intuitive for server administrators.

@Rollczi Rollczi self-requested a review July 23, 2025 22:06
@vLuckyyy vLuckyyy merged commit 5f25199 into master Jul 23, 2025
2 checks passed
@vLuckyyy vLuckyyy deleted the add-custom-command-feature branch July 23, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom commands

6 participants