Skip to content

Conversation

@Rollczi
Copy link
Member

@Rollczi Rollczi commented Jan 18, 2025

No description provided.

Jakubk15 and others added 3 commits January 18, 2025 17:46
# Conflicts:
#	eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpInventory.java
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 18, 2025

Walkthrough

This pull request introduces several modifications to the warp-related components in the EternalCore project. Key changes include renaming the isExist method to exists across multiple classes for consistency. The createWarp and findWarp methods have also had their parameters renamed to enhance clarity. A new configuration option, recalculateWarpSlots, has been added to the Warp class. The WarpInventory class has been refactored to improve code organization, including the introduction of a private method for calculating slot positions and adjustments to the removeWarp method to incorporate new logic.

Additionally, the removeItem method in the Translation interface has been updated to return the removed warp inventory item, enhancing its functionality. Overall, these updates focus on improving clarity and flexibility in warp management.


📜 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 a311f22 and 5cd0173.

📒 Files selected for processing (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java

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.

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 (5)
eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java (1)

346-348: Consider enhancing the configuration description

The description could be more detailed to help users understand when they might want to enable this option. For example, explain the benefits and potential impact of recalculating slots after warp deletion.

-    @Description("# Should item slots be recalculated after warp deletion")
+    @Description({
+        "# Should item slots be recalculated after warp deletion",
+        "# When enabled, warp slots in the GUI will be reorganized after a warp is deleted",
+        "# This helps maintain a clean layout but may change existing warp positions"
+    })
eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/command/SetWarpCommand.java (1)

Line range hint 22-22: Consider moving MAX_WARPS_IN_GUI to configuration

The hardcoded value of 56 might be better placed in the configuration file for easier customization.

eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpInventory.java (3)

25-27: Remove unused import

The Comparator import isn't being used anywhere in the code.

import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;

247-259: Consider adding a method comment

Nice job extracting this logic into a separate method! Adding a brief comment explaining the slot calculation would make it even better.

+    /**
+     * Calculates the next available slot based on the border configuration.
+     * @param warpSection The warp inventory section containing border settings
+     * @return The calculated slot number
+     */
     private int getSlot(Translation.WarpSection.WarpInventorySection warpSection) {

283-294: Consider simplifying the shift logic

The slot shifting could be simplified using a stream operation.

     private void shiftWarpItems(WarpInventoryItem removed, Translation.WarpSection.WarpInventorySection warpSection) {
         int removedSlot = removed.warpItem.slot;
-        List<WarpInventoryItem> iterator = warpSection.items().values().stream()
+        warpSection.items().values().stream()
             .filter(item -> item.warpItem.slot > removedSlot)
-            .toList();
-
-        int currentShift = removedSlot;
-        for (WarpInventoryItem item : iterator) {
-            int nextShift = item.warpItem.slot;
-            item.warpItem.slot = currentShift;
-            currentShift = nextShift;
-        }
+            .forEach(item -> item.warpItem.slot--);
     }
📜 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 95005c5.

📒 Files selected for processing (7)
  • eternalcore-api/src/main/java/com/eternalcode/core/feature/warp/WarpService.java (2 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java (2 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpInventory.java (7 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpServiceImpl.java (2 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/command/DelWarpCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/command/SetWarpCommand.java (1 hunks)
  • eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java (1 hunks)
🔇 Additional comments (10)
eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java (1)

179-184: Nice improvement to the removeItem method!

Returning the removed item is a helpful change that makes it easier to track what was removed.

eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java (2)

13-13: LGTM!

Clean import addition.


351-351: LGTM!

Simple formatting improvement.

eternalcore-api/src/main/java/com/eternalcode/core/feature/warp/WarpService.java (1)

21-21: Nice improvement to method naming!

The change from isExist to exists follows better Java naming conventions.

eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/command/DelWarpCommand.java (1)

40-40: Looking good!

Method call properly updated to match the new interface.

eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/command/SetWarpCommand.java (1)

47-47: Perfect update!

Method call correctly updated to use the new name.

eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpServiceImpl.java (1)

94-96: Clean implementation!

The method rename is properly implemented with the same functionality.

eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpInventory.java (3)

44-44: Nice rename!

Renaming from warpManager to warpService better describes its role.

Also applies to: 55-55, 64-64


168-168: LGTM!

The change is consistent with the service rename.


262-268: LGTM!

Good addition of the config check and consistent method name usage.

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/warp/WarpInventory.java (3)

97-98: Consider a more professional constant name

Instead of UGLY_BORDER_ROW_COUNT, consider using a more descriptive name like SINGLE_BORDER_ROW_COUNT.


249-261: Add comments explaining the slot calculations

The math for calculating slots is complex. Consider adding comments to explain what each calculation does and why.


281-293: Consider simplifying with Java streams

The shifting logic could be more concise using Java streams with map and collect.

-        int currentShift = removedSlot;
-        for (WarpInventoryItem item : itemsToShift) {
-            int nextShift = item.warpItem.slot;
-            item.warpItem.slot = currentShift;
-            currentShift = nextShift;
-        }
+        AtomicInteger currentShift = new AtomicInteger(removedSlot);
+        itemsToShift.forEach(item -> {
+            int nextShift = item.warpItem.slot;
+            item.warpItem.slot = currentShift.get();
+            currentShift.set(nextShift);
+        });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1287f6a and a311f22.

📒 Files selected for processing (1)
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpInventory.java (8 hunks)
🔇 Additional comments (2)
eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpInventory.java (2)

41-42: Nice improvements to naming and constants!

The rename to warpService and the new border constants make the code clearer.

Also applies to: 46-46, 57-57, 66-66


222-229: ⚠️ Potential issue

Fix the exists check logic

The early return condition seems backwards. The method returns if the warp exists, but it should probably return if it doesn't exist.

-        if (!this.warpService.exists(warp.getName())) {
+        if (this.warpService.exists(warp.getName())) {

Likely invalid or redundant comment.

@Jakubk15 Jakubk15 changed the title Warp fix GH-893 Warp fix Jan 22, 2025
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.

Love the hate for ugly ass borders <3

@vLuckyyy vLuckyyy changed the title GH-893 Warp fix GH-893 Improve auto warp gui. Fix some bugs. Jan 30, 2025
@vLuckyyy vLuckyyy changed the title GH-893 Improve auto warp gui. Fix some bugs. GH-893 Enhance Auto-Warp GUI and Fix Related Bugs Jan 30, 2025
@vLuckyyy vLuckyyy merged commit 93dd186 into master Jan 30, 2025
3 checks passed
@vLuckyyy vLuckyyy deleted the warp-fix branch January 30, 2025 19:45
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.

6 participants