Skip to content
Open
8 changes: 7 additions & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object Versions {
const val ADVENTURE_PLATFORM_BUKKIT = "4.4.1"
const val ADVENTURE_API = "4.25.0"

const val LITE_COMMANDS = "3.10.5"
const val LITE_COMMANDS = "3.10.2" //downgrade bc 3.10.5 does not support folia
const val OKAERI_CONFIGS_SERDES_COMMONS = "5.0.13"
const val OKAERI_CONFIGS_SERDES_BUKKIT = "5.0.13"

Expand All @@ -25,8 +25,14 @@ object Versions {
const val WORLD_GUARD_BUKKIT = "7.0.14"

const val PLACEHOLDER_API = "2.11.6"
const val LANDS_API = "7.17.2"
const val PAPERLIB = "1.0.8"

const val WORLDEDIT = "3ISh7ADm" //cannot use numeric version bc of duplicated version on modrinth
const val PACKETEVENTS = "2.11.1"
const val WORLDGUARD = "7.0.15-beta-01"
const val LUCKPERMS = "5.5.17"

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

public enum CancelTagReason {

TAGOUT
TAGOUT,
PERMISSION_BYPASS,
ADMIN,
CREATIVE_MODE,

}
17 changes: 13 additions & 4 deletions eternalcombat-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
import xyz.jpenilla.runpaper.task.RunServer

plugins {
`eternalcombat-java`
Expand Down Expand Up @@ -59,7 +60,7 @@ dependencies {
compileOnly("me.clip:placeholderapi:${Versions.PLACEHOLDER_API}")

// Lands
compileOnly("com.github.angeschossen:LandsAPI:7.17.2")
compileOnly("com.github.angeschossen:LandsAPI:${Versions.LANDS_API}")

// Multification
implementation("com.eternalcode:multification-bukkit:${Versions.MULTIFICATION}")
Expand Down Expand Up @@ -88,10 +89,18 @@ bukkit {

tasks {
runServer {
minecraftVersion("1.21.10")

downloadPlugins.modrinth("WorldEdit", Versions.WORLDEDIT)
downloadPlugins.modrinth("PacketEvents", "${Versions.PACKETEVENTS}+spigot")
downloadPlugins.modrinth("WorldGuard", Versions.WORLDGUARD)
downloadPlugins.modrinth("LuckPerms", "v${Versions.LUCKPERMS}-bukkit")
}

runPaper.folia.registerTask() {
minecraftVersion("1.21.8")
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.url("https://cdn.modrinth.com/data/DKY9btbd/versions/PO4MKx7e/worldguard-bukkit-7.0.14-dist.jar")

downloadPlugins.modrinth("PacketEvents", "${Versions.PACKETEVENTS}+spigot")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import com.eternalcode.combat.bridge.BridgeService;
import com.eternalcode.combat.crystalpvp.RespawnAnchorListener;
import com.eternalcode.combat.crystalpvp.EndCrystalListener;
import com.eternalcode.combat.fight.controller.FightBypassAdminController;
import com.eternalcode.combat.fight.controller.FightBypassCreativeController;
import com.eternalcode.combat.fight.controller.FightBypassPermissionController;
import com.eternalcode.combat.fight.drop.DropKeepInventoryService;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.drop.DropService;
Expand Down Expand Up @@ -172,13 +175,16 @@ public void onEnable() {
eventManager.subscribe(
new FightTagController(this.fightManager, pluginConfig),
new FightUnTagController(this.fightManager, pluginConfig, logoutService),
new FightBypassAdminController(server, pluginConfig),
new FightBypassPermissionController(server),
new FightBypassCreativeController(server, pluginConfig),
new FightActionBlockerController(this.fightManager, noticeService, pluginConfig, server),
new FightPearlController(pluginConfig.pearl, noticeService, this.fightManager, this.fightPearlService),
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()),
new FightEffectController(pluginConfig.effect, this.fightEffectService, this.fightManager, server),
new FightTagOutController(this.fightTagOutService),
new FightMessageController(this.fightManager, noticeService, pluginConfig, this.getServer()),
new FightMessageController(this.fightManager, noticeService, pluginConfig, server),
new BorderTriggerController(borderService, () -> pluginConfig.border, fightManager, server, scheduler),
new ParticleController(borderService, () -> pluginConfig.border.particle, scheduler, server),
new BorderBlockController(borderService, () -> pluginConfig.border.block, scheduler, server),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.eternalcode.combat.fight.controller;

import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CancelTagReason;
import com.eternalcode.combat.fight.event.FightTagEvent;
import java.util.UUID;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;

public class FightBypassAdminController implements Listener {

private final Server server;
private final PluginConfig config;

public FightBypassAdminController(Server server, PluginConfig config) {
this.server = server;
this.config = config;
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onFightTagEvent(FightTagEvent event) {
UUID uniqueId = event.getPlayer();

Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}

if (this.config.admin.excludeAdminsFromCombat && player.isOp()) {
event.setCancelReason(CancelTagReason.ADMIN);
event.setCancelled(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.eternalcode.combat.fight.controller;

import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CancelTagReason;
import com.eternalcode.combat.fight.event.FightTagEvent;
import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;

public class FightBypassCreativeController implements Listener {

private final Server server;
private final PluginConfig config;

public FightBypassCreativeController(Server server, PluginConfig config) {
this.server = server;
this.config = config;
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onFightTagEvent(FightTagEvent event) {
UUID uniqueId = event.getPlayer();

Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}

if (this.config.admin.excludeCreativePlayersFromCombat && player.getGameMode() == GameMode.CREATIVE) {
event.setCancelReason(CancelTagReason.CREATIVE_MODE);
event.setCancelled(true);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.eternalcode.combat.fight.controller;

import com.eternalcode.combat.fight.event.CancelTagReason;
import com.eternalcode.combat.fight.event.FightTagEvent;
import java.util.UUID;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;

public class FightBypassPermissionController implements Listener {

private static final String BYPASS_PERMISSION = "eternalcombat.bypass";

private final Server server;

public FightBypassPermissionController(Server server) {
this.server = server;
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onFightTagEvent(FightTagEvent event) {
UUID uniqueId = event.getPlayer();

Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}

if (player.hasPermission(BYPASS_PERMISSION)) {
event.setCancelReason(CancelTagReason.PERMISSION_BYPASS);
event.setCancelled(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfTag;
import org.bukkit.GameMode;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
Expand Down Expand Up @@ -56,11 +55,11 @@ void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
return;
}

if (this.cannotBeTagged(attacker)) {
return;
}
UUID attackedUniqueId = attackedPlayerByPerson.getUniqueId();
UUID attackerUniqueId = attacker.getUniqueId();

if (this.cannotBeTagged(attackedPlayerByPerson)) {
// enderpearl on folia counts as attack on self
if (attackedUniqueId.equals(attackerUniqueId)) {
return;
}
Comment on lines +58 to 64
Copy link
Member

Choose a reason for hiding this comment

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

I assume this won't only be the cause for Ender Pearls, right? The if condition will also be met when, for example, a player shoots an arrow into the air and it hits them?

Copy link
Member Author

Choose a reason for hiding this comment

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

True, I couldn't figure out other scenarios.
The ender pearl scenario does not even contain the type / cause / source using bukkit methods. I will verify that and complete a fix.

Thanks for the scenario!


Expand All @@ -77,8 +76,6 @@ void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}

Duration combatTime = this.config.settings.combatTimerDuration;
UUID attackedUniqueId = attackedPlayerByPerson.getUniqueId();
UUID attackerUniqueId = attacker.getUniqueId();

this.fightManager.tag(attackedUniqueId, combatTime, CauseOfTag.PLAYER, attackerUniqueId);
this.fightManager.tag(attackerUniqueId, combatTime, CauseOfTag.PLAYER, attackedUniqueId);
Expand All @@ -99,15 +96,6 @@ void onEntityDamage(EntityDamageEvent event) {
return;
}

if (this.cannotBeTagged(player)) {
return;
}

boolean hasBypass = player.hasPermission("eternalcombat.bypass");
if (hasBypass) {
return;
}

Duration combatTime = this.config.settings.combatTimerDuration;
UUID uuid = player.getUniqueId();

Expand Down Expand Up @@ -145,18 +133,5 @@ private boolean isPlayerInDisabledWorld(Player player) {
return this.config.settings.ignoredWorlds.contains(worldName);
}

private boolean cannotBeTagged(Player player) {
if (this.config.admin.excludeAdminsFromCombat && player.hasPermission("eternalcombat.bypass")) {
return true;
}

if (this.config.admin.excludeAdminsFromCombat && player.isOp()) {
return true;
}

return this.config.admin.excludeCreativePlayersFromCombat && player.getGameMode() == GameMode.CREATIVE;
}



}
Loading