mirror of
https://github.com/EternalCodeTeam/EternalCombat.git
synced 2026-11-05 01:00:11 -05:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e899de8e1 | ||
|
|
51d4e346cb | ||
|
|
e48a01fb98 | ||
|
|
fa7e220111 | ||
|
|
3fa5bfa4a0 |
No files matched your search
@@ -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"
|
||||
|
||||
+16
@@ -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);
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ import com.eternalcode.combat.fight.firework.FireworkController;
|
||||
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;
|
||||
@@ -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;
|
||||
|
||||
@@ -106,6 +110,7 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
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();
|
||||
|
||||
@@ -173,7 +178,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
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.pearl, noticeService, this.fightManager, this.fightPearlService, pluginConfig),
|
||||
new FightTridentController(pluginConfig.trident, noticeService, this.fightManager, this.fightTridentService, pluginConfig),
|
||||
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()),
|
||||
|
||||
+8
@@ -5,6 +5,7 @@ import com.eternalcode.combat.fight.drop.DropSettings;
|
||||
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;
|
||||
@@ -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.",
|
||||
|
||||
+11
-2
@@ -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;
|
||||
@@ -14,7 +16,6 @@ import org.bukkit.event.Listener;
|
||||
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 {
|
||||
|
||||
@@ -22,17 +23,20 @@ public class FightPearlController implements Listener {
|
||||
private final NoticeService noticeService;
|
||||
private final FightManager fightManager;
|
||||
private final FightPearlService fightPearlService;
|
||||
private final PluginConfig config;
|
||||
|
||||
public FightPearlController(
|
||||
FightPearlSettings settings,
|
||||
NoticeService noticeService,
|
||||
FightManager fightManager,
|
||||
FightPearlService fightPearlService
|
||||
FightPearlService fightPearlService,
|
||||
PluginConfig config
|
||||
) {
|
||||
this.settings = settings;
|
||||
this.noticeService = noticeService;
|
||||
this.fightManager = fightManager;
|
||||
this.fightPearlService = fightPearlService;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@@ -63,6 +67,11 @@ public class FightPearlController implements Listener {
|
||||
if (this.settings.pearlCooldownEnabled) {
|
||||
handlePearlCooldown(event, player, playerId);
|
||||
}
|
||||
|
||||
if (this.settings.pearlResetsTimer) {
|
||||
Duration combatTime = this.config.settings.combatTimerDuration;
|
||||
this.fightManager.tag(playerId, combatTime, CauseOfTag.NON_PLAYER);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
||||
+3
@@ -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 pearlResetsTimer = 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"
|
||||
|
||||
+107
@@ -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.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerRiptideEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightTridentController implements Listener {
|
||||
|
||||
private final FightTridentSettings settings;
|
||||
private final NoticeService noticeService;
|
||||
private final FightManager fightManager;
|
||||
private final FightTridentService fightTridentService;
|
||||
private final PluginConfig config;
|
||||
|
||||
public FightTridentController(
|
||||
FightTridentSettings settings,
|
||||
NoticeService noticeService,
|
||||
FightManager fightManager,
|
||||
FightTridentService fightTridentService,
|
||||
PluginConfig config
|
||||
) {
|
||||
this.settings = settings;
|
||||
this.noticeService = noticeService;
|
||||
this.fightManager = fightManager;
|
||||
this.fightTridentService = fightTridentService;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onTridentInteract(PlayerInteractEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if (item == null || item.getType() != Material.TRIDENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
UUID playerId = player.getUniqueId();
|
||||
|
||||
if (!this.fightManager.isInCombat(playerId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.settings.tridentThrowDisabledDuringCombat) {
|
||||
event.setCancelled(true);
|
||||
this.noticeService.create()
|
||||
.player(playerId)
|
||||
.notice(this.settings.tridentThrowBlockedDuringCombat)
|
||||
.send();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.settings.tridentCooldownEnabled) {
|
||||
this.handleTridentCooldown(event, player, playerId);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onTridentRiptide(PlayerRiptideEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID playerId = player.getUniqueId();
|
||||
|
||||
if (!this.fightManager.isInCombat(playerId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.settings.tridentResetsTimer) {
|
||||
Duration combatTime = this.config.settings.combatTimerDuration;
|
||||
this.fightManager.tag(playerId, combatTime, CauseOfTag.NON_PLAYER);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTridentCooldown(PlayerInteractEvent event, Player player, UUID playerId) {
|
||||
if (this.settings.tridentThrowDelay.isZero()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.fightTridentService.hasDelay(playerId)) {
|
||||
event.setCancelled(true);
|
||||
Duration remainingDelay = this.fightTridentService.getRemainingDelay(playerId);
|
||||
|
||||
this.noticeService.create()
|
||||
.player(playerId)
|
||||
.notice(this.settings.tridentThrowBlockedDelayDuringCombat)
|
||||
.placeholder("{TIME}", DurationUtil.format(remainingDelay))
|
||||
.send();
|
||||
return;
|
||||
}
|
||||
|
||||
this.fightTridentService.markDelay(playerId);
|
||||
int cooldownTicks = (int) (this.settings.tridentThrowDelay.toMillis() / 50);
|
||||
player.setCooldown(Material.TRIDENT, cooldownTicks);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.eternalcode.combat.fight.trident;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightTridentServiceImpl implements FightTridentService {
|
||||
private final FightTridentSettings tridentSettings;
|
||||
private final Cache<@NotNull 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;
|
||||
}
|
||||
}
|
||||
|
||||
+39
@@ -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 throwing tridents during combat.",
|
||||
"# This will work globally, but can be overridden by region settings"
|
||||
})
|
||||
public boolean tridentThrowDisabledDuringCombat = false;
|
||||
|
||||
@Comment("# Set to true so throwing trident will result in cooldown - delay between throws")
|
||||
public boolean tridentCooldownEnabled = false;
|
||||
|
||||
@Comment("# Set to true, so the users will get combat log when they throw tridents")
|
||||
public boolean tridentResetsTimer = false;
|
||||
|
||||
@Comment({
|
||||
"# Should throwing trident be on cooldown?",
|
||||
"# Setting this option to 3s will make players wait 3 seconds between trident throws"
|
||||
})
|
||||
public Duration tridentThrowDelay = Duration.ofSeconds(3);
|
||||
|
||||
@Comment("# Message sent to the player when throwing trident is disabled")
|
||||
public Notice tridentThrowBlockedDuringCombat = BukkitNotice.builder()
|
||||
.chat("<red>Throwing trident is prohibited during combat!")
|
||||
.build();
|
||||
|
||||
@Comment("# Message marking delay between trident throws")
|
||||
public Notice tridentThrowBlockedDelayDuringCombat = BukkitNotice.builder()
|
||||
.chat("<red>You must wait {TIME} before next throw!")
|
||||
.build();
|
||||
}
|
||||
Reference in new issue
Block a user