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-830 Teleport to default home feature #858

Merged
merged 4 commits into from
Oct 14, 2024
Merged

Conversation

igoyek
Copy link
Contributor

@igoyek igoyek commented Oct 6, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced home management allowing players with multiple homes to teleport to their default home more efficiently.
    • Updated notifications for players with multiple homes, now including a list of home names.
  • Bug Fixes

    • Improved logic for retrieving homes to reduce reliance on previous methods, ensuring better performance.

@igoyek igoyek requested a review from vLuckyyy October 6, 2024 15:52
@igoyek igoyek added the 🆕 feature New feature or request label Oct 6, 2024
@igoyek igoyek self-assigned this Oct 6, 2024
Took 2 minutes
Copy link
Member

@Rollczi Rollczi left a comment

Choose a reason for hiding this comment

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

Ficzer jest już w eternacore

Copy link
Member

@Rollczi Rollczi left a comment

Choose a reason for hiding this comment

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

A dobra, już czaję koncept ale boolean w config jest trochę useless. Jak coś jest default to powinno tepać tam i tyle po wpisaniu /home

Copy link

coderabbitai bot commented Oct 8, 2024

Walkthrough

The changes in the HomeCommand.java file involve significant modifications to the HomeCommand class. A new dependency, PluginConfiguration.Homes, is introduced and injected into the constructor. The logic in the execute method is updated to handle multiple homes for a player, allowing retrieval of a home based on a default name. Additionally, the notification sent to players with multiple homes is enhanced to include a list of home names. Overall, these changes improve the management and teleportation functionality related to player homes.

Changes

File Path Change Summary
.../feature/home/command/HomeCommand.java - Constructor updated to include PluginConfiguration.Homes.
- Logic in execute method modified to handle multiple homes, retrieve the first home, and utilize Optional<Home> for teleportation.
- Player notification updated to include a list of home names.

Poem

In the land of homes so bright,
A rabbit hops with pure delight.
With multiple homes, oh what a sight,
Teleporting swiftly, day or night!
Configuration set, the path is clear,
Hopping home, with friends so near! 🐇🏡✨


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 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.

Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 38ba610 and e4208ef.

📒 Files selected for processing (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/home/command/HomeCommand.java (3 hunks)
🧰 Additional context used
🔇 Additional comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/feature/home/command/HomeCommand.java (2)

55-56: Ensure deterministic retrieval of firstHome.

Using playerHomes.iterator().next() may not consistently return the same home if playerHomes is backed by an unordered collection, such as a HashSet. This could lead to unpredictable behavior when teleporting the player to their first home.

Please confirm that playerHomes is an ordered collection (e.g., a List) to ensure that firstHome is consistent across calls.


64-71: Previous review comment applies: Simplify code by using firstHome instead of configuration.

The suggestion to remove the dependency on homesConfig.defaultHomeName and use firstHome is still valid. This can simplify the code and reduce reliance on external configuration.

Note: CitralFlo previously commented: "please remove Boolean from config and make use of existing firstHome value on line 81 if possible simplifying the code."

Copy link
Member

@vLuckyyy vLuckyyy left a comment

Choose a reason for hiding this comment

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

If you have tested, everything in my opinion is good

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.

LGTM

@EternalCodeTeam EternalCodeTeam deleted a comment from Rollczi Oct 12, 2024
@EternalCodeTeam EternalCodeTeam deleted a comment from Rollczi Oct 12, 2024
Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e4208ef and 49542ea.

📒 Files selected for processing (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/home/command/HomeCommand.java (3 hunks)
🧰 Additional context used
🔇 Additional comments (5)
eternalcore-core/src/main/java/com/eternalcode/core/feature/home/command/HomeCommand.java (5)

4-4: LGTM: New imports are appropriate for the changes.

The added imports for PluginConfiguration and java.util.Optional are necessary and correctly support the new functionality in the HomeCommand class.

Also applies to: 16-17


24-24: LGTM: New field for homes configuration.

The addition of the homesConfig field is appropriate for storing home-related configuration. It's correctly declared as private and final, adhering to good encapsulation practices.


31-31: LGTM: Constructor updated to include homes configuration.

The constructor has been correctly updated to include the new homesConfig parameter, which is then properly assigned to the class field. This change adheres to dependency injection principles and ensures the HomeCommand class has access to the necessary configuration.

Also applies to: 36-36


55-70: LGTM: Improved handling of multiple homes and default home concept.

The changes to the execute method enhance the functionality by introducing a default home concept and improving the handling of multiple homes. The logic is more flexible and user-friendly, allowing for default home teleportation when applicable.


66-70: Address previous review comments.

Regarding past review comments:

  1. The suggestion to provide a fallback to firstHome when the default home is not found is still valid. This aligns with the refactoring suggestion in the previous comment.

  2. The comment about removing Boolean from config and using firstHome doesn't seem directly applicable to the current code. There's no visible Boolean config or firstHome usage in the provided snippet. If this was implemented elsewhere, please ensure it's consistent with the current implementation.

Please review these past suggestions and ensure they're addressed or clarify if they're no longer applicable.

@vLuckyyy vLuckyyy merged commit 5e22eb2 into master Oct 14, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 feature New feature or request
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants