Skip to content

Conversation

@vLuckyyy
Copy link
Member

@vLuckyyy vLuckyyy commented Feb 2, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The updates focus on standardizing naming conventions and improving in-code documentation across several components of the plugin. Key configuration settings have been renamed for greater clarity, such as switching from names like shouldReceivePluginUpdates to notifyAboutUpdates and combatDuration to combatTimerDuration. Similar improvements have been made to variables related to region management, combat tagging, action blocking during combat, and notification handling. These changes update references within the logic for region handling, event processing, and command execution, while keeping the underlying functionality intact. The overall modifications are centered on making the code more readable and maintainable by aligning variable names and comments with their intended purposes.


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
Copy link
Member Author

vLuckyyy commented Feb 2, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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)
eternalcombat-plugin/src/main/java/com/eternalcode/combat/bridge/BridgeService.java (1)

33-33: Update the parameter name for consistency

The parameter name blockedRegions is still using the old naming style. Consider updating it to match the new naming pattern.

-            () -> this.regionProvider = new WorldGuardRegionProvider(this.pluginConfig.settings.blockedRegions, this.pluginConfig),
+            () -> this.regionProvider = new WorldGuardRegionProvider(this.pluginConfig.settings.restrictedRegions, this.pluginConfig),
eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/RegionController.java (1)

29-71: Consider simplifying the move handler

A few friendly suggestions to make this code even better:

  1. The coordinate comparison could use a simpler check like !locationTo.equals(locationFrom)
  2. The knockback calculation could be moved to a helper method for better organization

Here's how you could refactor it:

+ private Vector calculateKnockback(Player player, Region region) {
+     Location centerOfRegion = region.getCenter();
+     Location subtract = player.getLocation().subtract(centerOfRegion);
+     Vector knockbackVector = new Vector(subtract.getX(), 0, subtract.getZ()).normalize();
+     Vector configuredVector = new Vector(
+         this.pluginConfig.settings.regionKnockbackMultiplier,
+         0.5,
+         this.pluginConfig.settings.regionKnockbackMultiplier);
+     return knockbackVector.multiply(configuredVector);
+ }

  @EventHandler
  void onPlayerMove(PlayerMoveEvent event) {
      Player player = event.getPlayer();
      
      if (!this.fightManager.isInCombat(player.getUniqueId())) {
          return;
      }

-     Location locationTo = event.getTo();
-     int xTo = locationTo.getBlockX();
-     int yTo = locationTo.getBlockY();
-     int zTo = locationTo.getBlockZ();
-
-     Location locationFrom = event.getFrom();
-     int xFrom = locationFrom.getBlockX();
-     int yFrom = locationFrom.getBlockY();
-     int zFrom = locationFrom.getBlockZ();
-
-     if (xTo != xFrom || yTo != yFrom || zTo != zFrom) {
+     if (!event.getTo().equals(event.getFrom())) {
          Optional<Region> regionOptional = this.regionProvider.getRegion(event.getTo());
          if (regionOptional.isEmpty()) {
              return;
          }

          Region region = regionOptional.get();
-         Location centerOfRegion = region.getCenter();
-         Location subtract = player.getLocation().subtract(centerOfRegion);
-
-         Vector knockbackVector = new Vector(subtract.getX(), 0, subtract.getZ()).normalize();
-         Vector configuredVector = new Vector(
-             this.pluginConfig.settings.regionKnockbackMultiplier,
-             0.5,
-             this.pluginConfig.settings.regionKnockbackMultiplier);
-
-         player.setVelocity(knockbackVector.multiply(configuredVector));
+         player.setVelocity(calculateKnockback(player, region));

          this.announcer.create()
              .player(player.getUniqueId())
              .notice(this.pluginConfig.messages.cantEnterOnRegion)
              .send();
      }
  }
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightTagController.java (1)

66-76: Consider extracting flight disable logic

The code for disabling flight is repeated for both players. We could make this cleaner by moving it to a helper method.

Here's a simpler way to write this:

+    private void disablePlayerFlight(Player player) {
+        if (player.isFlying()) {
+            player.setFlying(false);
+            player.setAllowFlight(false);
+        }
+    }
+
     if (this.config.settings.disableFlying) {
-        if (attackedPlayerByPerson.isFlying()) {
-            attackedPlayerByPerson.setFlying(false);
-            attackedPlayerByPerson.setAllowFlight(false);
-        }
-
-        if (attacker.isFlying()) {
-            attacker.setFlying(false);
-            attacker.setAllowFlight(false);
-        }
+        this.disablePlayerFlight(attackedPlayerByPerson);
+        this.disablePlayerFlight(attacker);
     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c7f93d9 and 604789f.

📒 Files selected for processing (9)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/bridge/BridgeService.java (1 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java (2 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTagCommand.java (2 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java (8 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightTagController.java (6 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightUnTagController.java (1 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/RegionController.java (1 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/WorldGuardRegionProvider.java (1 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/updater/UpdaterNotificationController.java (1 hunks)
🔇 Additional comments (17)
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightUnTagController.java (1)

37-37: Nice improvement to the config property name! 👍

The new name releaseAttackerOnVictimDeath makes it super clear what this setting does. It's a good match with the other naming updates across the project.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTagCommand.java (2)

56-56: Nice rename!

The new name combatTimerDuration is clearer than the old combatDuration. It better explains that this setting controls how long the combat timer lasts.


79-79: Good consistency!

You've used the same improved name here too. Keeping names consistent helps everyone understand the code better.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/bridge/BridgeService.java (1)

35-35: LGTM! Good naming update

The change from blockedRegionRadius to restrictedRegionRadius makes the config naming more consistent.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java (4)

36-36: Nice work on making the block placing code clearer!

The renamed properties make it much easier to understand what's happening. The changes from shouldPreventBlockPlacing to disableBlockPlacing and specificBlocksToPreventPlacing to restrictedBlockTypes are more straightforward.

Also applies to: 50-50, 59-60, 73-74


81-83: The block placement mode check looks good!

The logic is clear and the new property names blockPlacementMode and blockPlacementYCoordinate are easy to understand.


88-88: Great consistency in the disable flags!

All the action-blocking flags now follow the same pattern with disable prefix:

  • disableElytraUsage
  • disableFlying
  • disableElytraOnDamage
  • disableInventoryAccess

This makes the code more predictable and easier to read.

Also applies to: 108-108, 128-128, 144-144


175-175: Command restriction changes look good!

The switch from blocked commands to restricted commands is a nice improvement in clarity:

  • restrictedCommands instead of blockedCommands
  • commandRestrictionMode instead of commandBlockingMode

Also applies to: 178-178

eternalcombat-plugin/src/main/java/com/eternalcode/combat/updater/UpdaterNotificationController.java (1)

36-36: LGTM! Property name updated correctly.

The configuration property has been updated to use the new name notifyAboutUpdates.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/WorldGuardRegionProvider.java (1)

51-51: LGTM! Property name updated correctly.

The configuration property has been updated to use the new name preventPvpInRegions.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java (3)

23-26: Documentation improvements look great!

The comments are now more descriptive and provide better context for each configuration section.

Also applies to: 29-33, 36-40, 43-47


56-56: Variable names are now more intuitive.

The renamed variables better describe their purpose:

  • notifyAboutUpdates instead of shouldReceivePluginUpdates
  • combatTimerDuration instead of combatDuration
  • preventPvpInRegions instead of shouldPreventPvpRegions
    And many more similar improvements.

Also applies to: 62-62, 68-68, 83-83, 89-89, 95-95, 101-101, 108-108, 115-115, 121-121, 127-127, 137-137, 149-149, 155-155, 161-161, 167-167, 173-173, 179-179, 191-191, 197-197, 203-203, 210-210, 222-222


258-404: Message documentation is now more comprehensive.

Each message now has clear documentation explaining:

  • When the message is displayed
  • What placeholders are available
  • The purpose of the message
eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/RegionController.java (1)

58-62: Nice naming improvement!

The change from blockedRegionKnockMultiplier to regionKnockbackMultiplier makes the config setting clearer and easier to understand.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightTagController.java (3)

38-38: Nice work on the clearer config names!

The new names like ignoredProjectileTypes and combatTimerDuration make it easier to understand what these settings do.

Also applies to: 54-54


84-84: Good improvements to the damage logging names!

The renamed settings like enableDamageCauseLogging and loggedDamageCauses better explain their purpose.

Also applies to: 104-105


134-134: Great choice of words for the exclusion settings!

Using terms like ignoredWorlds and excludeAdminsFromCombat makes the settings more intuitive.

Also applies to: 138-138, 142-142

@vLuckyyy vLuckyyy changed the title V2.0/config refactor GH-202 V2.0/config refactor Feb 2, 2025
Copy link
Contributor

@igoyek igoyek 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 👍

…ig/implementation/PluginConfig.java

Co-authored-by: Jakub Kędziora <[email protected]>
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.

We are planning on creating more features in the future. I would consider splitting Configuration file just like in EternalCore.

@vLuckyyy vLuckyyy linked an issue Feb 7, 2025 that may be closed by this pull request
@vLuckyyy
Copy link
Member Author

vLuckyyy commented Feb 7, 2025

image

@vLuckyyy vLuckyyy merged commit a6984e2 into 2.0 Feb 8, 2025
2 checks passed
@vLuckyyy vLuckyyy deleted the v2.0/config-refactor branch February 8, 2025 21:27
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.

Refresh default messages & Refactor Config structure.

7 participants