Skip to content
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

GH-886 Sign editor (/sign setline <index> <text> command) #895

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

igoyek
Copy link

@igoyek igoyek commented Jan 22, 2025

No description provided.

Took 11 minutes
@igoyek igoyek requested a review from vLuckyyy January 22, 2025 19:33
@igoyek igoyek self-assigned this Jan 22, 2025
Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

The pull request introduces a sign editing feature for a Minecraft plugin, enhancing user interaction with signs. Key changes include the addition of a new package dedicated to sign editing functionality, along with command classes such as SignEditorCommand and SignSideEditorCommand, which allow players to modify sign text through in-game commands. Translation support is provided for both English and Polish, with new classes like ENSignEditorMessages and PLSignEditorMessages offering localized feedback messages. Additionally, a new interface, SignEditorMessages, standardizes message retrieval related to sign editing. The feature is compatible with Minecraft versions 19.4 and above, ensuring a user-friendly experience for players looking to edit sign content within the plugin.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

@igoyek igoyek linked an issue Jan 22, 2025 that may be closed by this pull request
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: 0

🧹 Nitpick comments (3)
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignEditCommand.java (2)

31-48: Consider extracting the block distance as a constant.

The value 5 in player.getTargetBlock(null, 5) should be defined as a named constant for better maintainability.

+    private static final int SIGN_EDIT_DISTANCE = 5;
     void execute(@Context Player player, @Arg Integer index, @Join String text) {
-        Block targetBlock = player.getTargetBlock(null, 5);
+        Block targetBlock = player.getTargetBlock(null, SIGN_EDIT_DISTANCE);

50-58: Add null check for deserialized text.

The deserialized text should be checked for null to prevent potential NPE.

-        frontSide.setLine(index, this.miniMessage.deserialize(text).toString());
+        String deserializedText = this.miniMessage.deserialize(text).toString();
+        if (deserializedText != null) {
+            frontSide.setLine(index, deserializedText);
+        }
eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (1)

926-927: Fix Polish description in English translation file.

The description comment is in Polish ("Ta sekcja...") but should be in English for consistency.

-    @Description({ " ", "# Ta sekcja odpowiada za wiadomości dotyczące edycji tabliczek"})
+    @Description({ " ", "# This section is responsible for sign editing messages"})
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 046c0df and aa76ccb.

📒 Files selected for processing (5)
  • eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignEditCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java
🔇 Additional comments (3)
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignEditCommand.java (1)

17-27: Clean command setup with proper dependency injection!

eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java (1)

477-483: Well-structured translation interface section!

The SignEditSection follows the established pattern and provides all necessary messages.

eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java (1)

945-954: Polish translations are well-implemented!

The messages are properly translated and maintain consistency with the English version.

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: 0

🧹 Nitpick comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (2)

935-936: Polish comment in English translation file.

The description comment is in Polish. Let's keep it in English for consistency.

-    @Description({ " ", "# Ta sekcja odpowiada za wiadomości dotyczące edycji tabliczek"})
+    @Description({ " ", "# This section is responsible for sign editing messages"})

941-943: Add descriptions for individual messages.

Let's document the placeholders used in these messages to help other developers.

     @Contextual
     public static class SignEditor {
+        @Description("# Message shown when no sign is found at target location")
         public Notice noSignFound = Notice.chat("<red>✘ <dark_red>Sign not found!");
+        @Description("# Message shown when line index is not between 0-3")
         public Notice invalidIndex = Notice.chat("<red>✘ <dark_red>Invalid index!");
+        @Description({" ", "# {LINE} - Line number (0-3)", "# {TEXT} - New text content"})
         public Notice lineSet = Notice.chat("<green>► <white>Line <green>{LINE} <white>set to <green>{TEXT}");
     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aa76ccb and 2c16d2b.

📒 Files selected for processing (4)
  • eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (17)
🔇 Additional comments (4)
eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java (3)

957-959: LGTM! Section declaration looks good.

The new sign editor section is properly declared and documented.


960-962: LGTM! Annotations are correctly applied.

The @Getter and @Contextual annotations are properly used, consistent with other sections.


963-966: LGTM! Messages are well-structured.

The messages follow the plugin's style and include proper placeholders for dynamic content.

eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (1)

935-944: LGTM! The implementation follows the established patterns.

The SignEditor class is well-structured and consistent with other translation sections in the file.

@vLuckyyy vLuckyyy added the ✅ needs testing Issue needs verification. label Jan 23, 2025
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: 2

♻️ Duplicate comments (1)
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignSideEditorCommand.java (1)

34-34: ⚠️ Potential issue

Add null check for target block

Same issue as in SignEditorCommand - need to check if target block is null.

🧹 Nitpick comments (5)
eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (1)

937-938: Consider using English for all comments.

The comment is in Polish ("Ta sekcja odpowiada za...") while the rest of the file uses English comments.

-    @Description({ " ", "# Ta sekcja odpowiada za wiadomości dotyczące edycji tabliczek"})
+    @Description({ " ", "# This section is responsible for sign editor messages"})
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignEditorCommand.java (1)

32-32: Consider making the range a constant

The block range of 5 would be clearer as a named constant.

+    private static final int SIGN_EDIT_RANGE = 5;
+
     @Execute(name = "setline")
     void execute(@Context Player player, @Arg int index, @Join String text) {
-        Block targetBlock = player.getTargetBlock(null, 5);
+        Block targetBlock = player.getTargetBlock(null, SIGN_EDIT_RANGE);
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignSideEditorCommand.java (1)

19-22: Consider merging commands using inheritance

This command shares a lot of code with SignEditorCommand. Consider creating a base class to avoid duplication.

eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/ENSignEditorMessages.java (2)

8-10: Add a quick comment about fluent accessors

Consider adding a brief comment explaining that this class uses fluent-style getters (like messageInstance.noSignFound() instead of messageInstance.getNoSignFound()).


12-14: Make the message fields final

Since these are constant messages, consider making them final:

-    public Notice noSignFound = Notice.chat("<red>✘ <dark_red>Sign not found, please look at the sign!");
-    public Notice invalidIndex = Notice.chat("<red>✘ <dark_red>Invalid index!");
-    public Notice lineSet = Notice.chat("<green>► <white>Line <green>{LINE} <white>set to <green>{TEXT}");
+    public final Notice noSignFound = Notice.chat("<red>✘ <dark_red>Sign not found, please look at the sign!");
+    public final Notice invalidIndex = Notice.chat("<red>✘ <dark_red>Invalid index!");
+    public final Notice lineSet = Notice.chat("<green>► <white>Line <green>{LINE} <white>set to <green>{TEXT}");
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2c16d2b and e3fe988.

📒 Files selected for processing (8)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignEditorCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignSideEditorCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/ENSignEditorMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/PLSignEditorMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/SignEditorMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java (2 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (2 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (17)
🔇 Additional comments (7)
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/PLSignEditorMessages.java (2)

8-11: LGTM! Clean class setup with appropriate annotations.

The class is well-structured with Lombok annotations for clean getter generation.


12-14: Messages are clear and user-friendly.

The Polish translations are well-formatted with consistent styling using MiniMessage format.

eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java (1)

5-6: LGTM! Appropriate imports added.

The imports for sign editor message classes are correctly placed.

eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/SignEditorMessages.java (1)

5-9: Nice and clean interface!

The methods are clear and focused on their purpose.

eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignSideEditorCommand.java (1)

34-34: Consider making the range a constant

Same suggestion as in SignEditorCommand - the block range should be a named constant.

eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/ENSignEditorMessages.java (2)

1-7: Looks good!

The package structure and imports are clean and well-organized.


11-11: Perfect class naming!

Clear implementation of the messages interface with good naming convention.

Copy link
Member

@CitralFlo CitralFlo left a comment

Choose a reason for hiding this comment

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

Is there a limit of chars that sign can have?

followed all instructions
fixed all (i think) issues and critical errors
now its working :), tested

Took 32 minutes
@igoyek igoyek added the 🆕 feature New feature or request label Feb 7, 2025
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: 0

🧹 Nitpick comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignSideEditorCommand.java (2)

52-60: Make line number validation more user-friendly

The line validation could be clearer by showing the valid range in the error message.

Consider adding the valid range to the placeholder:

-                .placeholder("{LINE}", String.valueOf(line))
+                .placeholder("{LINE}", String.valueOf(line))
+                .placeholder("{MAX_LINES}", String.valueOf(signSide.getLines().length))

And update the translation to include the range: "Line {LINE} is invalid. Please use 1-{MAX_LINES}."


43-50: Add distance info to the 'no sign found' message

Help players understand why they can't edit a sign by mentioning the maximum reach distance.

Consider adding the distance to the error message:

             .notice(translation -> translation.signEditor().noSignFound())
+            .placeholder("{MAX_DISTANCE}", "5")

And update the translation to: "No sign found within {MAX_DISTANCE} blocks."

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e3fe988 and 91ea5e3.

📒 Files selected for processing (4)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignEditorCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignSideEditorCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/ENSignEditorMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/PLSignEditorMessages.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/PLSignEditorMessages.java
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/messages/ENSignEditorMessages.java
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignEditorCommand.java
🔇 Additional comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/feature/signeditor/SignSideEditorCommand.java (2)

21-24: Nice work on the command setup!

The command structure is clean and well-organized with clear permissions and version requirements.


26-33: Clean dependency setup!

Good use of dependency injection for the notice service and message formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 feature New feature or request ✅ needs testing Issue needs verification.
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Sign editor (/sign setline <index> <text> command)
5 participants