Skip to content

fix: prevent delayed knockback teleport from overriding /back after death. Reported on Discord.#344

Open
vLuckyyy wants to merge 2 commits intomasterfrom
fix/back-location-after-death
Open

fix: prevent delayed knockback teleport from overriding /back after death. Reported on Discord.#344
vLuckyyy wants to merge 2 commits intomasterfrom
fix/back-location-after-death

Conversation

@vLuckyyy
Copy link
Member

@vLuckyyy vLuckyyy commented Feb 15, 2026

This PR fixes a race condition in EternalCombat where a delayed knockback/teleport could still run after player death and overwrite the location used by /back (Essentials/HuskHomes). It also fixes region checks to include world validation (World), not only coordinates.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @vLuckyyy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug reported on Discord where delayed knockback teleports could interfere with player actions, specifically the /back command, after a player's death. The changes introduce robust checks within the knockback mechanism to ensure that teleports are only executed if the player is still alive and actively engaged in combat. Additionally, the region containment logic has been improved to correctly handle locations across different worlds, enhancing the overall reliability of region-based mechanics.

Highlights

  • Delayed Knockback Fix: Implemented checks in the KnockbackService to prevent delayed knockback teleports from occurring if a player is no longer in combat or has died, addressing an issue where it could override the /back command.
  • Region World Check: Enhanced the Region.contains method to verify that the target location is in the same world as the region, preventing incorrect region interactions across different worlds.
  • Dependency Injection Update: The KnockbackService constructor was updated to include FightManager as a dependency, allowing it to access player combat status.
  • New Test Case: Added a new unit test to ensure the Region.contains method correctly handles locations from different worlds.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • eternalcombat-api/src/main/java/com/eternalcode/combat/region/Region.java
    • Imported org.bukkit.World.
    • Modified the contains method to include checks for null locations and world equality.
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java
    • Updated the instantiation of KnockbackService to pass the FightManager instance.
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/knockback/KnockbackService.java
    • Imported com.eternalcode.combat.fight.FightManager.
    • Added FightManager as a dependency in the constructor.
    • Modified the knockbackLater method to include checks for player combat status and death before executing the knockback.
    • Modified the forceKnockbackLater method to include checks for player combat status and death before executing the knockback.
  • eternalcombat-plugin/test/com/eternalcode/combat/region/RegionContainsWorldCheckTest.java
    • Added a new test file to verify the world check functionality in the Region.contains method.
Activity
  • No specific activity (comments, reviews) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully addresses the issue of delayed knockback teleports occurring after a player's death, which could interfere with /back functionality. The changes in KnockbackService now correctly check if a player is still in combat and alive before applying knockback. Additionally, the Region.contains method has been improved to correctly handle locations in different worlds, and a test has been added for this case.

However, I've identified a significant issue in KnockbackService where Player objects are captured in delayed tasks. This can lead to errors if a player logs out and back in before the task executes. I've provided suggestions to resolve this by fetching the player object from the server at execution time to ensure the code's stability.

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

Comments