Skip to content

Conversation

@Pawelusze
Copy link

@Pawelusze Pawelusze commented Dec 14, 2025

I've added new options to Pearl and Trident that reset the timer when the player uses them.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Pawelusze, 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 significantly expands the combat system by introducing new, highly configurable mechanics for both Ender Pearls and Tridents. The core addition is the ability to reset a player's combat timer when they throw an Ender Pearl or use a Trident, providing more dynamic and strategic combat scenarios. Furthermore, it establishes a comprehensive set of combat-specific settings for Tridents, including options to restrict their use during combat and implement cooldowns, aligning them with existing pearl-related features.

Highlights

  • Trident Combat Mechanics: Introduced new combat-related features for tridents, including options to disable throwing during combat, apply cooldowns, and reset the combat timer upon use.
  • Pearl Combat Timer Reset: Added a new configurable option to reset a player's combat timer when they throw an Ender Pearl, enhancing combat engagement.
  • Enhanced Configurability: All new trident and pearl timer reset functionalities are fully configurable via the PluginConfig, allowing server administrators to tailor combat behavior.
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 introduces new features for handling tridents in combat and adds an option to reset the combat timer upon using ender pearls or tridents. The implementation is largely correct, but I've identified a critical issue: the fightTridentService is used without being initialized, which will lead to a NullPointerException. I've also found several copy-paste errors in the new trident-related classes, including incorrect naming and comments that refer to 'pearls' instead of 'tridents'. My review includes suggestions to fix these issues to ensure the code is correct and maintainable. Additionally, I've pointed out an unused import that should be removed.

Comment on lines 10 to 49
public class FightTridentServiceImpl implements FightTridentService {
private final FightTridentSettings tridentSettings;
private final Cache<UUID, Instant> pearlStartTimes;

public FightTridentServiceImpl(FightTridentSettings pearlSettings) {
this.tridentSettings = pearlSettings;
this.pearlStartTimes = Caffeine.newBuilder()
.expireAfterWrite(pearlSettings.tridentThrowDelay)
.build();
}

@Override
public void markDelay(UUID uuid) {
this.pearlStartTimes.put(uuid, Instant.now());
}

@Override
public boolean hasDelay(UUID uuid) {
return this.pearlStartTimes.getIfPresent(uuid) != null;
}

@Override
public Duration getRemainingDelay(UUID uuid) {
Instant startTime = this.pearlStartTimes.getIfPresent(uuid);
if (startTime == null) {
return Duration.ZERO;
}

Duration elapsed = Duration.between(startTime, Instant.now());
Duration remaining = this.tridentSettings.tridentThrowDelay.minus(elapsed);

return remaining.isNegative() ? Duration.ZERO : remaining;
}

@Override
public Instant getDelay(UUID uuid) {
Instant startTime = this.pearlStartTimes.getIfPresent(uuid);
return startTime != null ? startTime.plus(this.tridentSettings.tridentThrowDelay) : Instant.MIN;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This class appears to have been copied from a pearl-related implementation, but some names were not updated. The field pearlStartTimes and constructor parameter pearlSettings should be renamed to tridentStartTimes and tridentSettings respectively to avoid confusion and improve maintainability. I've applied these changes in the suggestion.

public class FightTridentServiceImpl implements FightTridentService {
    private final FightTridentSettings tridentSettings;
    private final Cache<UUID, Instant> tridentStartTimes;

    public FightTridentServiceImpl(FightTridentSettings tridentSettings) {
        this.tridentSettings = tridentSettings;
        this.tridentStartTimes = Caffeine.newBuilder()
            .expireAfterWrite(tridentSettings.tridentThrowDelay)
            .build();
    }

    @Override
    public void markDelay(UUID uuid) {
        this.tridentStartTimes.put(uuid, Instant.now());
    }

    @Override
    public boolean hasDelay(UUID uuid) {
        return this.tridentStartTimes.getIfPresent(uuid) != null;
    }

    @Override
    public Duration getRemainingDelay(UUID uuid) {
        Instant startTime = this.tridentStartTimes.getIfPresent(uuid);
        if (startTime == null) {
            return Duration.ZERO;
        }

        Duration elapsed = Duration.between(startTime, Instant.now());
        Duration remaining = this.tridentSettings.tridentThrowDelay.minus(elapsed);

        return remaining.isNegative() ? Duration.ZERO : remaining;
    }

    @Override
    public Instant getDelay(UUID uuid) {
        Instant startTime = this.tridentStartTimes.getIfPresent(uuid);
        return startTime != null ? startTime.plus(this.tridentSettings.tridentThrowDelay) : Instant.MIN;
    }
}

Comment on lines 10 to 39
public class FightTridentSettings extends OkaeriConfig {

@Comment({
"# Set true, If you want to disable throwing trident during combat",
"# This will work globally, but can be overridden by region settings"
})
public boolean tridentThrowDisabledDuringCombat = true;

@Comment("# Set true, If you want add cooldown to pearls")
public boolean tridentCooldownEnabled = false;

@Comment("# Set true, If you want to reset timer when player uses trident")
public boolean tridentResetsTimerEnabled = true;

@Comment({
"# Block throwing trident with delay?",
"# If you set this to for example 3s, player will have to wait 3 seconds before throwing another pearl"
})
public Duration tridentThrowDelay = Duration.ofSeconds(3);

@Comment("# Message sent when player tries to throw trident, but are disabled")
public Notice tridentThrowBlockedDuringCombat = BukkitNotice.builder()
.chat("<red>Throwing trident is prohibited during combat!")
.build();

@Comment("# Message sent when player tries to throw ender pearl, but has delay")
public Notice tridentThrowBlockedDelayDuringCombat = BukkitNotice.builder()
.chat("<red>You must wait {TIME} before next throw!")
.build();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Several comments in this file seem to be copied from a pearl-related settings file and were not updated. They incorrectly refer to "pearls" or "ender pearls" instead of "tridents". I've corrected them in the suggestion below.

public class FightTridentSettings extends OkaeriConfig {

    @Comment({
        "# Set true, If you want to disable throwing trident during combat",
        "# This will work globally, but can be overridden by region settings"
    })
    public boolean tridentThrowDisabledDuringCombat = true;

    @Comment("# Set true, If you want add cooldown to tridents")
    public boolean tridentCooldownEnabled = false;

    @Comment("# Set true, If you want to reset timer when player uses trident")
    public boolean tridentResetsTimerEnabled = true;

    @Comment({
        "# Block throwing trident with delay?",
        "# If you set this to for example 3s, player will have to wait 3 seconds before throwing another trident"
    })
    public Duration tridentThrowDelay = Duration.ofSeconds(3);

    @Comment("# Message sent when player tries to throw trident, but are disabled")
    public Notice tridentThrowBlockedDuringCombat = BukkitNotice.builder()
        .chat("<red>Throwing trident is prohibited during combat!")
        .build();

    @Comment("# Message sent when player tries to throw trident, but has delay")
    public Notice tridentThrowBlockedDelayDuringCombat = BukkitNotice.builder()
        .chat("<red>You must wait {TIME} before next throw!")
        .build();
}

@Pawelusze Pawelusze changed the title I've added new options to Pearl and Trident that reset the timer when… GH-303 New feature to trident and pearls Dec 14, 2025
@Pawelusze Pawelusze changed the title GH-303 New feature to trident and pearls GH-303 New feature for trident and pearls Dec 14, 2025
@Pawelusze Pawelusze changed the title GH-303 New feature for trident and pearls GH-303 New features for Trident and Pearls Dec 14, 2025
@Jakubk15 Jakubk15 linked an issue Dec 14, 2025 that may be closed by this pull request
@Jakubk15 Jakubk15 changed the title GH-303 New features for Trident and Pearls GH-266 New features for Trident and Pearls Dec 14, 2025

if (this.settings.pearlResetsTimerEnabled) {
Duration combatTime = this.config.settings.combatTimerDuration;
this.fightManager.tag(playerId, combatTime, CauseOfTag.CUSTOM);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
this.fightManager.tag(playerId, combatTime, CauseOfTag.CUSTOM);
this.fightManager.tag(playerId, combatTime, CauseOfTag.NON_PLAYER);

Refer to the javadocs for CauseOfTag

Comment on lines +14 to +15
public FightTridentServiceImpl(FightTridentSettings pearlSettings) {
this.tridentSettings = pearlSettings;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public FightTridentServiceImpl(FightTridentSettings pearlSettings) {
this.tridentSettings = pearlSettings;
public FightTridentServiceImpl(FightTridentSettings tridentSettings) {
this.tridentSettings = tridentSettings;

import java.time.Duration;
import java.util.UUID;

public class FightTridentController implements Listener {
Copy link
Member

Choose a reason for hiding this comment

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

The functionality of this class does not correspond to what we settled at in issue discussion. Your implementation will prevent throwing all tridents whatsoever, while we want to simply stop throwing tridents with the Riptide enchantment. Requesting changes.

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.

Resolve reviews and the Riptide issue mentioned by Jakubek

public FightTridentServiceImpl(FightTridentSettings pearlSettings) {
this.tridentSettings = pearlSettings;
this.tridentStartTimes = Caffeine.newBuilder()
.expireAfterWrite(pearlSettings.tridentThrowDelay)
Copy link
Member

Choose a reason for hiding this comment

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

pearlSettings -> tridentSettings

.chat("<red>Throwing trident is prohibited during combat!")
.build();

@Comment("# Message sent when player tries to throw trident, but has delay")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Comment("# Message sent when player tries to throw trident, but has delay")
@Comment("# Message marking delay between trident throws")

})
public Duration tridentThrowDelay = Duration.ofSeconds(3);

@Comment("# Message sent when player tries to throw trident, but are disabled")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Comment("# Message sent when player tries to throw trident, but are disabled")
@Comment("# Message sent to the player when throwing trident is disabled")

Comment on lines +25 to +26
"# Block throwing trident with delay?",
"# If you set this to for example 3s, player will have to wait 3 seconds before throwing trident"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"# Block throwing trident with delay?",
"# If you set this to for example 3s, player will have to wait 3 seconds before throwing trident"
"# Should throwing trident be on cooldown?",
"# Setting this option to 3s will make players wait 3 seconds between trident throws"

public boolean tridentCooldownEnabled = false;

@Comment("# Set true, If you want to reset timer when player uses trident")
public boolean tridentResetsTimerEnabled = true;
Copy link
Member

Choose a reason for hiding this comment

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

default could be false - meaning throwing trident without pvp will not result in punishment

@Comment("# Set true, If you want add cooldown to trident")
public boolean tridentCooldownEnabled = false;

@Comment("# Set true, If you want to reset timer when player uses trident")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Comment("# Set true, If you want to reset timer when player uses trident")
@Comment("# Set to true, so the users will get combat log when they throw tridents")

})
public boolean tridentThrowDisabledDuringCombat = true;

@Comment("# Set true, If you want add cooldown to trident")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Comment("# Set true, If you want add cooldown to trident")
@Comment("# Set to true so throwing trident will result in cooldown - delay between throws")

"# Set true, If you want to disable throwing trident during combat",
"# This will work globally, but can be overridden by region settings"
})
public boolean tridentThrowDisabledDuringCombat = true;
Copy link
Member

Choose a reason for hiding this comment

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

Could be set to false as default

public class FightTridentSettings extends OkaeriConfig {

@Comment({
"# Set true, If you want to disable throwing trident during combat",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"# Set true, If you want to disable throwing trident during combat",
"#Set to true to disable throwing tridents during combat.",

public boolean pearlCooldownEnabled = false;

@Comment("# Set true, If you want to reset timer when player throws ender pearl")
public boolean pearlResetsTimerEnabled = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public boolean pearlResetsTimerEnabled = true;
public boolean pearlResetsTimer = true;

maybe just it?

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.

Follow friend's instructions :)

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.

Ender Pearl & Trident Combat Reset

4 participants