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-916 Refactor packages in item-edit related commands. #916

Merged
merged 3 commits into from
Feb 13, 2025

Conversation

vLuckyyy
Copy link
Member

Continuation of: #906

Date: January 18th
Time: 12:08 PM
Location: Virtual team gathering (read: me + Rollczi, which basically means the whole team, right?)

On this day, in an atmosphere of utmost seriousness (and zero consultation with the rest of the team), we made the decision to restructure the packages. Why? Because the previous PL and EN files, along with the Translation interface, looked like a pile of crap. Especially for the poor developer who had to wade through 2k lines of code just to add one message. Well, a programmer's life is no fairy tale.

Pull request #906 was merged without any review, because we don’t have time for such silly formalities – much like prosecutor Michał Ostrowski doesn’t have time for meticulous investigations.

And today? Today I decided to continue this epic saga of crappy code. I moved the lore package, the ItemFlag command, and ItemName from the essentials package to the itemedit package. It's kind of like an immigrant moving from Germany to Poland – everything has to find a new place.

Now it looks like this:

image

Copy link
Contributor

coderabbitai bot commented Feb 13, 2025

Walkthrough

This update restructures the item editing functionality across several components. Package declarations have been revised, moving classes from an "essentials" context to a dedicated "itemedit" context. The commands for managing item flags, lore, and names now refer to updated translation messages, ensuring consistency within the new context. In addition, new methods have been introduced—such as a method for removing a specific lore line—and changes have been made to the suggestions and validation logic for item lore. New classes and interfaces for item editing messages have been added, and existing translation interfaces and implementations have been updated accordingly. The overall control flow in the commands remains unchanged, with the focus being on aligning feedback messages and structural organization with the dedicated item editing features.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dbb8000 and 5dd21d0.

📒 Files selected for processing (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemLoreArgument.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemLoreArgument.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (17)

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.

@vLuckyyy vLuckyyy changed the title Lore name flag to itemedit Refactor packages in item-edit related commands. Feb 13, 2025
@vLuckyyy vLuckyyy changed the title Refactor packages in item-edit related commands. GH-916 Refactor packages in item-edit related commands. Feb 13, 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 (3)
eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/messages/PLItemEditMessages.java (2)

9-12: Add a class-level comment explaining the fluent accessor pattern.

A brief comment would help other developers understand why fluent accessors are used here.

+/**
+ * Polish messages for item editing operations.
+ * Uses fluent accessors for a more readable message chain syntax.
+ */
 @Getter
 @Accessors(fluent = true)
 @Contextual
 public class PLItemEditMessages implements ItemEditMessages {

17-18: Add meaningful descriptions for all messages.

Some messages have empty descriptions (" "). Adding context would help with maintenance and localization.

For example:

-    @Description(" ")
+    @Description("Message shown when item name is cleared")
     public Notice itemClearNameMessage = Notice.chat("<green>► <white>Wyczyszczono nazwę przedmiotu!");

Also applies to: 23-24, 33-34, 36-37, 39-40

eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemLoreCommand.java (1)

48-49: Smart expansion.
Automatically ensuring the list grows is handy, but watch out for extremely large line values.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 34aa32c and dbb8000.

📒 Files selected for processing (10)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemFlagCommand.java (3 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemLoreArgument.java (3 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemLoreCommand.java (2 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemNameCommand.java (3 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/messages/ENItemEditMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/messages/ItemEditMessages.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/messages/PLItemEditMessages.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)
🔇 Additional comments (24)
eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java (2)

8-8: LGTM!

The import for PLItemEditMessages aligns with the restructuring of item editing functionality into a dedicated package.


115-116: LGTM!

The new section for item editing messages is well-documented and properly integrated into the translation structure.

eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/messages/PLItemEditMessages.java (2)

1-8: Nice package organization!

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


14-40: Great message formatting consistency!

The use of consistent colors and symbols (► for success, ✖ for errors) makes the messages clear and user-friendly.

eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemLoreArgument.java (3)

1-1: Nice package organization!

Moving this to the itemedit package makes perfect sense and helps keep related code together.


20-20: Good user experience improvement!

Changing suggestions to start from 1 instead of 0 makes more sense for users, as they typically think in terms of line 1, line 2, etc., rather than starting from 0.


33-38:

❓ Verification inconclusive

Verify the index conversion logic.

The code now accepts numbers starting from 1 (user-friendly) and converts them to 0-based indices (for internal use). While this is a good approach, let's make sure all related code expects 0-based indices.


🏁 Script executed:

#!/bin/bash
# Search for any lore-related operations that might need similar index adjustments
rg -l "lore" | xargs rg "(?i)(get|set|remove|add).*lore.*index"

Length of output: 63


Please confirm index conversion consistency

The update in ItemLoreArgument.java correctly adjusts a 1-based number to a 0-based index. Since our search didn't return any instances of lore-related index manipulations elsewhere, it's important to manually verify that all parts of the code handling lore indices use the 0-based convention.

  • Ensure that any methods or operations involving lore indices (like get, set, remove, or add) are updated or already expect 0-based indices.
  • Confirm that this conversion doesn’t inadvertently affect other parts of the system.
eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemLoreCommand.java (9)

1-1: No worries here.
The package name is clear and matches the new structure nicely.


8-11: Looks tidy.
Imports are simple and fit well with the command setup.

Also applies to: 13-14


52-52: Nice approach.
Using MiniMessage for rich text keeps lore formatting flexible.


58-58: Good feedback.
Notifying the user with the new message context is a solid choice.


64-66: Straightforward command.
Clearly named for removing lore, which makes it easy to understand.


67-96: Thoughtful edge cases.
Gracefully handles missing lore and invalid lines. This keeps things user-friendly.


99-99: Good clarity.
A dedicated clear command is intuitive for players.


104-104: Consistent messaging.
Using the same no-item notice preserves a unified player experience.


112-112: Helpful final note.
Clear message on lore removal completion.

eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/messages/ItemEditMessages.java (1)

1-23: Well-organized interface.
Grouping all item edit notices in one place is a neat step for clarity.

eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/messages/ENItemEditMessages.java (1)

1-41: Great localization setup.
Providing descriptive placeholders and straightforward text will help users quickly grasp changes.

eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemFlagCommand.java (2)

1-1: Looking good! Package and imports are properly organized.

The move from essentials to itemedit package makes the code structure clearer.

Also applies to: 7-7, 9-9


46-47: Nice update to the translation calls!

The translation calls now use itemEdit() instead of item(), which aligns with the new package structure.

Also applies to: 53-53, 69-69

eternalcore-core/src/main/java/com/eternalcode/core/feature/itemedit/ItemNameCommand.java (2)

1-1: Package move and new import look good!

The code is now in a more logical location with the required imports.

Also applies to: 13-13


49-49: Translation calls updated correctly!

The message handling now uses the new itemEdit() context.

Also applies to: 69-69

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

8-8: Good addition of the new translation section!

The new itemEdit() method with its description helps organize item-related messages better.

Also applies to: 227-228

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

8-8: Nice implementation of the new translation section!

The English translation now properly supports the new item editing messages.

Also applies to: 118-119

@vLuckyyy vLuckyyy merged commit f49c85d into master Feb 13, 2025
3 checks passed
@vLuckyyy vLuckyyy deleted the lore-name-flag-to-itemedit branch February 13, 2025 19:59
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.

4 participants