Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3fa5bfa
I've added new options to Pearl and Trident that reset the timer when…
Pawelusze Dec 14, 2025
fa7e220
I made the corrections that gemini noticed
Pawelusze Dec 14, 2025
e48a01f
The improvements suggested by the team have been implemented
Pawelusze Dec 29, 2025
f4bdbb7
Implemented suggestions from the team
Pawelusze Dec 29, 2025
51d4e34
Bump packetevents version to support future MC versions
Jakubk15 Dec 29, 2025
2e899de
Make tridents throw check work on all tridents, regardless of enchant…
Jakubk15 Dec 29, 2025
0be6867
Merge remote-tracking branch 'origin/feature/add-reset-timer' into fe…
Pawelusze Jan 4, 2026
ab4e804
Implemented suggestions from the team and fixed `FightTridentControll…
Pawelusze Feb 2, 2026
5ec350a
Corrected comments and field names
Pawelusze Feb 3, 2026
ee6cac5
Implemented CitralFlo suggestions
Pawelusze Feb 4, 2026
68fb2ef
Implemented CitralFlo suggestions again
Pawelusze Feb 5, 2026
5efe39b
Merge branch 'master' into feature/add-reset-timer
CitralFlo Feb 6, 2026
0841c22
Follow igoyek's review from 21.10.25
CitralFlo Feb 6, 2026
76e84ab
CR
Rollczi Feb 7, 2026
07ab306
Simplify naming - extract logic to service for Pearls
CitralFlo Feb 7, 2026
795c7b6
make it more logical
CitralFlo Feb 7, 2026
984449b
Refactor trident-related classes and services for improved clarity an…
CitralFlo Feb 7, 2026
3b0bd15
Rename trident cooldown methods to improve clarity and update comment…
CitralFlo Feb 7, 2026
486789d
Fixes after tests - everything should be working now!
CitralFlo Feb 8, 2026
70b3c7b
Remove commented line
CitralFlo Feb 8, 2026
996e95c
Add cooldown to enderpearl - hack by:https://www.spigotmc.org/threads…
CitralFlo Feb 8, 2026
3b19294
Bump minecraft version in runServer task to 1.21.11
Jakubk15 Feb 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Versions {

const val ETERNALCODE_COMMONS = "1.3.1"
const val MULTIFICATION = "1.2.2"
const val PACKETS_EVENTS = "2.9.5"
const val PACKETS_EVENTS = "2.11.1"

const val ADVENTURE_PLATFORM_BUKKIT = "4.4.1"
const val ADVENTURE_API = "4.25.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.eternalcode.combat.fight.trident;

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

public interface FightTridentService {

Instant getDelay(UUID uuid);

Duration getRemainingDelay(UUID uuid);

boolean hasDelay(UUID uuid);

void markDelay(UUID uuid);
}
4 changes: 2 additions & 2 deletions eternalcombat-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ bukkit {

tasks {
runServer {
minecraftVersion("1.21.8")
minecraftVersion("1.21.10")
downloadPlugins.url("https://cdn.modrinth.com/data/1u6JkXh5/versions/Jk1z2u7n/worldedit-bukkit-7.3.16.jar")
downloadPlugins.url("https://github.com/retrooper/packetevents/releases/download/v2.9.5/packetevents-spigot-2.9.5.jar")
downloadPlugins.modrinth("packetevents", "${Versions.PACKETS_EVENTS}+spigot")
downloadPlugins.url("https://cdn.modrinth.com/data/DKY9btbd/versions/PO4MKx7e/worldguard-bukkit-7.0.14-dist.jar")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import com.eternalcode.combat.fight.knockback.KnockbackService;
import com.eternalcode.combat.fight.tagout.FightTagOutService;
import com.eternalcode.combat.fight.pearl.FightPearlService;
import com.eternalcode.combat.fight.trident.FightTridentController;
import com.eternalcode.combat.fight.trident.FightTridentService;
import com.eternalcode.combat.fight.trident.FightTridentServiceImpl;
import com.eternalcode.combat.handler.InvalidUsageHandlerImpl;
import com.eternalcode.combat.handler.MissingPermissionHandlerImpl;
import com.eternalcode.combat.config.ConfigService;
Expand Down Expand Up @@ -78,6 +81,7 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {

private FightManager fightManager;
private FightPearlService fightPearlService;
private FightTridentService fightTridentService;
private FightTagOutService fightTagOutService;
private FightEffectService fightEffectService;

Expand Down Expand Up @@ -106,6 +110,7 @@ public void onEnable() {

this.fightManager = new FightManagerImpl(eventManager);
this.fightPearlService = new FightPearlServiceImpl(pluginConfig.pearl);
this.fightTridentService = new FightTridentServiceImpl(pluginConfig.trident);
this.fightTagOutService = new FightTagOutServiceImpl();
this.fightEffectService = new FightEffectServiceImpl();

Expand Down Expand Up @@ -173,7 +178,8 @@ public void onEnable() {
new FightTagController(this.fightManager, pluginConfig),
new FightUnTagController(this.fightManager, pluginConfig, logoutService),
new FightActionBlockerController(this.fightManager, noticeService, pluginConfig, server),
new FightPearlController(pluginConfig.pearl, noticeService, this.fightManager, this.fightPearlService),
new FightPearlController(pluginConfig, noticeService, this.fightManager, this.fightPearlService),
new FightTridentController(pluginConfig, noticeService, this.fightManager, this.fightTridentService),
new UpdaterNotificationController(updaterService, pluginConfig, this.audienceProvider, miniMessage),
new KnockbackRegionController(noticeService, this.regionProvider, this.fightManager, knockbackService, server),
new FightEffectController(pluginConfig.effect, this.fightEffectService, this.fightManager, this.getServer()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.eternalcode.combat.fight.effect.FightEffectSettings;
import com.eternalcode.combat.fight.knockback.KnockbackSettings;
import com.eternalcode.combat.fight.pearl.FightPearlSettings;
import com.eternalcode.combat.fight.trident.FightTridentSettings;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import java.time.Duration;
Expand Down Expand Up @@ -35,6 +36,13 @@ public class PluginConfig extends OkaeriConfig {
})
public FightPearlSettings pearl = new FightPearlSettings();

@Comment({
" ",
"# Settings related to Trident",
"# Configure cooldowns, restrictions, and other behaviors for Trident during combat."
})
public FightTridentSettings trident = new FightTridentSettings();

@Comment({
" ",
"# Custom effects applied during combat.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.eternalcode.combat.fight.pearl;

import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfTag;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.combat.util.DurationUtil;
import java.time.Duration;
Expand All @@ -14,22 +16,21 @@
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;

public class FightPearlController implements Listener {

private final FightPearlSettings settings;
private final PluginConfig pluginConfig;
private final NoticeService noticeService;
private final FightManager fightManager;
private final FightPearlService fightPearlService;

public FightPearlController(
FightPearlSettings settings,
PluginConfig pluginConfig,
NoticeService noticeService,
FightManager fightManager,
FightPearlService fightPearlService
) {
this.settings = settings;
this.pluginConfig = pluginConfig;
this.noticeService = noticeService;
this.fightManager = fightManager;
this.fightPearlService = fightPearlService;
Expand All @@ -51,23 +52,28 @@ public void onPearlThrow(ProjectileLaunchEvent event) {
return;
}

if (this.settings.pearlThrowDisabledDuringCombat) {
if (this.pluginConfig.pearl.pearlThrowDisabledDuringCombat) {
event.setCancelled(true);
this.noticeService.create()
.player(playerId)
.notice(this.settings.pearlThrowBlockedDuringCombat)
.notice(this.pluginConfig.pearl.pearlThrowBlockedDuringCombat)
.send();
return;
}

if (this.settings.pearlCooldownEnabled) {
if (this.pluginConfig.pearl.pearlCooldownEnabled) {
handlePearlCooldown(event, player, playerId);
}

if (this.pluginConfig.pearl.pearlResetsTimerEnabled) {
Duration combatTime = this.pluginConfig.settings.combatTimerDuration;
this.fightManager.tag(playerId, combatTime, CauseOfTag.CUSTOM);
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPearlDamage(EntityDamageByEntityEvent event) {
if (this.settings.pearlThrowDamageEnabled) {
if (this.pluginConfig.pearl.pearlThrowDamageEnabled) {
return;
}

Expand All @@ -81,7 +87,7 @@ public void onPearlDamage(EntityDamageByEntityEvent event) {
}

private void handlePearlCooldown(ProjectileLaunchEvent event, Player player, UUID playerId) {
if (this.settings.pearlThrowDelay.isZero()) {
if (this.pluginConfig.pearl.pearlThrowDelay.isZero()) {
return;
}

Expand All @@ -91,14 +97,14 @@ private void handlePearlCooldown(ProjectileLaunchEvent event, Player player, UUI

this.noticeService.create()
.player(playerId)
.notice(this.settings.pearlThrowBlockedDelayDuringCombat)
.notice(this.pluginConfig.pearl.pearlThrowBlockedDelayDuringCombat)
.placeholder("{TIME}", DurationUtil.format(remainingDelay))
.send();
return;
}

this.fightPearlService.markDelay(playerId);
int cooldownTicks = (int) (this.settings.pearlThrowDelay.toMillis() / 50);
int cooldownTicks = (int) (this.pluginConfig.pearl.pearlThrowDelay.toMillis() / 50);
player.setCooldown(Material.ENDER_PEARL, cooldownTicks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class FightPearlSettings extends OkaeriConfig {
@Comment("# Set true, If you want add cooldown to pearls")
public boolean pearlCooldownEnabled = false;

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

@Comment({
"# Block throwing pearls with delay?",
"# If you set this to for example 3s, player will have to wait 3 seconds before throwing another pearl"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.eternalcode.combat.fight.trident;

import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfTag;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.combat.util.DurationUtil;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRiptideEvent;

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

public class FightTridentController implements Listener {

private final PluginConfig pluginConfig;
private final NoticeService noticeService;
private final FightManager fightManager;
private final FightTridentService fightTridentService;

public FightTridentController(
PluginConfig pluginConfig,
NoticeService noticeService,
FightManager fightManager,
FightTridentService fightTridentService
) {
this.pluginConfig = pluginConfig;
this.noticeService = noticeService;
this.fightManager = fightManager;
this.fightTridentService = fightTridentService;
}

@EventHandler
public void onRiptide(PlayerRiptideEvent event) {
Player player = event.getPlayer();
UUID playerId = player.getUniqueId();

if (!this.fightManager.isInCombat(playerId)) {
return;
}

if (this.pluginConfig.trident.tridentRiptideDisabledDuringCombat) {
return;
}

if (this.pluginConfig.trident.tridentCooldownEnabled) {
this.handleTridentCooldown(player, playerId);
}

if (this.pluginConfig.trident.tridentResetsTimerEnabled) {
Duration combatTime = pluginConfig.settings.combatTimerDuration;
this.fightManager.tag(playerId, combatTime, CauseOfTag.CUSTOM);
}
}

@EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
if (event.getFrom().distanceSquared(event.getTo()) == 0) {
return;
}

Player player = event.getPlayer();
UUID playerId = player.getUniqueId();

if (!this.fightManager.isInCombat(playerId)) {
return;
}

if (!player.isRiptiding()) {
return;
}

if (this.pluginConfig.trident.tridentRiptideDisabledDuringCombat) {
event.setCancelled(true);

this.noticeService.create()
.player(playerId)
.notice(this.pluginConfig.trident.tridentRiptideBlockedDuringCombat)
.send();
}
}

private void handleTridentCooldown(Player player, UUID playerId) {
if (this.pluginConfig.trident.tridentRiptideDelay.isZero()) {
return;
}

if (this.fightTridentService.hasDelay(playerId)) {
Duration remainingDelay = this.fightTridentService.getRemainingDelay(playerId);

this.noticeService.create()
.player(playerId)
.notice(this.pluginConfig.trident.tridentRiptideBlockedDelayDuringCombat)
.placeholder("{TIME}", DurationUtil.format(remainingDelay))
.send();
return;
}

this.fightTridentService.markDelay(playerId);
int cooldownTicks = (int) (this.pluginConfig.trident.tridentRiptideDelay.toMillis() / 50);
player.setCooldown(Material.TRIDENT, cooldownTicks);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.eternalcode.combat.fight.trident;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;

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

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.tridentRiptideDelay)
.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.tridentRiptideDelay.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.tridentRiptideDelay) : Instant.MIN;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.eternalcode.combat.fight.trident;

import com.eternalcode.multification.bukkit.notice.BukkitNotice;
import com.eternalcode.multification.notice.Notice;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;

import java.time.Duration;

public class FightTridentSettings extends OkaeriConfig {

@Comment({
"# Set to true to disable riptide usage during combat",
"# This setting works globally, but can be overridden by region settings"
})
public boolean tridentRiptideDisabledDuringCombat = true;

@Comment("# Set to true so throwing trident will result in cooldown - delay between uses")
public boolean tridentCooldownEnabled = false;

@Comment("# Set to true so the users will get combat log when they use riptide")
public boolean tridentResetsTimerEnabled = false;

@Comment({
"# Should riptide enchantment be on cooldown?",
"# Setting this option to 3s will make players wait 3 seconds between trident throws"
})
public Duration tridentRiptideDelay = Duration.ofSeconds(3);

@Comment("# Message shown when riptide is blocked during combat")
public Notice tridentRiptideBlockedDuringCombat = BukkitNotice.builder()
.chat("<red>Using riptide is prohibited during combat!")
.build();

@Comment("# Message sent to the player when riptide is on cooldown")
public Notice tridentRiptideBlockedDelayDuringCombat = BukkitNotice.builder()
.chat("<red>You must wait {TIME} before next usage!")
.build();
}