Skip to content

GH-233 Fix pearl cooldown#233

Merged
vLuckyyy merged 3 commits intomasterfrom
fix-pearl-cooldown
Jul 11, 2025
Merged

GH-233 Fix pearl cooldown#233
vLuckyyy merged 3 commits intomasterfrom
fix-pearl-cooldown

Conversation

@vLuckyyy
Copy link
Copy Markdown
Member

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 24, 2025

Walkthrough

This update changes how ender pearl throwing is managed during combat. The system now listens for projectile launches instead of player interactions, allowing better control over pearl throws. Cooldown handling is moved into its own method, and a new setting lets you enable or disable pearl cooldowns. The configuration for blocking pearl throws during combat is renamed and its default is now enabled. Internally, the way cooldown times are tracked is updated for more accurate timing. The damage event logic is also simplified for easier maintenance.


📜 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 487fc97 and cff1750.

📒 Files selected for processing (3)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java (1 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlServiceImpl.java (1 hunks)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java (1 hunks)
👮 Files not reviewed due to content moderation or server errors (3)
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlServiceImpl.java
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (24)
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java (6)

15-19: Good rename for clarity!

The new name pearlThrowDisabledDuringCombat is much clearer than the old name. Changing the default to true makes sense for combat balance.


21-22: Nice addition of cooldown toggle!

Adding the pearlCooldownEnabled setting gives users more control over pearl behavior. Good to see it defaults to false for backward compatibility.


15-22: Good configuration improvements!

The field rename to pearlThrowDisabledDuringCombat is much clearer than the old name. Adding the separate pearlCooldownEnabled flag gives good control granularity. Defaulting the combat restriction to true makes sense for game balance.


26-26: Comment cleanup looks good.

Removing the note about disabling delay by setting to zero simplifies the documentation.


15-19: Good configuration naming improvement.

The rename from pearlThrowBlocked to pearlThrowDisabledDuringCombat is much clearer, and the expanded comment helps explain the global vs region behavior.


21-22: Nice addition of cooldown toggle.

Adding pearlCooldownEnabled gives users better control over pearl behavior. Good default of false to maintain backwards compatibility.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlServiceImpl.java (8)

13-13: Good variable rename!

pearlStartTimes is much clearer than pearlDelays for what's actually being stored.


34-42: Clean logic in remaining delay calculation!

The new approach calculating remaining time dynamically is much better. The null check and negative duration handling look solid.


47-48: Simple and correct expiration calculation!

Using start time plus delay duration to get expiration is straightforward and correct.


13-13: Cache approach change looks good.

Switching from storing expiration times to start times gives more flexibility for dynamic calculations.


34-42: Verify the delay calculation logic.

The new calculation logic looks correct, but let me double-check the math:

  1. Get start time from cache
  2. Calculate elapsed time since start
  3. Subtract elapsed from total delay duration
  4. Return zero if negative

The logic handles edge cases properly by returning Duration.ZERO for both null start times and negative remaining times.


47-48: Simple and correct delay calculation.

Using startTime.plus(delay) to get the expiration time is clean and straightforward.


13-13: Smart change to track start times.

Switching from expiration times to start times allows for more accurate remaining delay calculations.


34-42: Solid remaining delay calculation.

The logic properly handles edge cases - null start times return zero duration, and negative remaining times are clamped to zero.

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java (10)

38-66: Much better event handling approach!

Switching to ProjectileLaunchEvent is more reliable than PlayerInteractEvent. The logic flow with early returns is clean and easy to follow.


74-81: Nice simplification of damage logic!

Combining all the conditions into one if-statement makes the code much cleaner and easier to read.


83-103: Well-structured cooldown handling!

Good separation of concerns by moving cooldown logic to its own method. The tick calculation looks correct (50ms per tick), and the flow handles both delay checking and setting properly.


38-52: Good switch to ProjectileLaunchEvent.

Using ProjectileLaunchEvent instead of PlayerInteractEvent should be more accurate for catching actual pearl throws. The type checks and early returns look solid.


54-66: Clean combat restriction logic.

The logic flow is clear: cancel if pearls are disabled during combat, otherwise handle cooldowns if enabled. Good separation of concerns.


74-81: Simplified damage handler is cleaner.

Combining the conditions into one if statement with early return makes the logic easier to follow than the previous nested approach.


83-103: Let’s double-check all millisecond-to-tick conversions and other uses of setCooldown for consistency:

#!/bin/bash
# Find all Duration.toMillis() usages
rg -n "toMillis()" --type java

# Look for any division by 50 (ms → ticks)
rg -A3 -B3 'toMillis.*/.*50' --type java

# Find all setCooldown calls
rg -n "setCooldown(" --type java

38-66: Great switch to ProjectileLaunchEvent.

Using ProjectileLaunchEvent instead of PlayerInteractEvent is much better - it catches the actual pearl throw rather than just the interaction. The logic flow is clear too.


74-81: Nice cleanup of the damage logic.

Combining the conditions into a single if statement makes this much easier to read and understand.


83-103: Well-structured cooldown handling.

The cooldown method is cleanly separated and handles both the delay check and the actual cooldown application properly. Good integration with the service layer.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@vLuckyyy vLuckyyy changed the title Fix pearl cooldown GH-233 Fix pearl cooldown Jul 11, 2025
@vLuckyyy vLuckyyy merged commit 7a152e0 into master Jul 11, 2025
2 checks passed
@vLuckyyy vLuckyyy deleted the fix-pearl-cooldown branch July 11, 2025 17:07
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.

1 participant