Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,

}
11 changes: 6 additions & 5 deletions eternalcombat-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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 +88,11 @@ bukkit {

tasks {
runServer {
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")
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")
}
}

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,14 +55,6 @@ void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
return;
}

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

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

if (this.config.combat.disableFlying) {
if (attackedPlayerByPerson.isFlying()) {
attackedPlayerByPerson.setFlying(false);
Expand Down Expand Up @@ -99,15 +90,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 +127,6 @@ 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