mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 05:16:55 +00:00
check for worldguard force pvp region within pvp check
This commit is contained in:
@@ -3,6 +3,7 @@ package me.youhavetrouble.preventstabby.data;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.api.event.PlayerEnterCombatEvent;
|
||||
import me.youhavetrouble.preventstabby.api.event.PlayerLeaveCombatEvent;
|
||||
import me.youhavetrouble.preventstabby.hooks.WorldGuardHook;
|
||||
import me.youhavetrouble.preventstabby.util.PluginMessages;
|
||||
import me.youhavetrouble.preventstabby.util.PvpState;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -174,7 +175,7 @@ public class PlayerManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (!attackerPlayerData.isPvpEnabled()) {
|
||||
if (!attackerPlayerData.isPvpEnabled() && !WorldGuardHook.isPlayerForcedToPvp(Bukkit.getPlayer(attackerId))) {
|
||||
String message = switch (victimClassifier) {
|
||||
case PLAYER -> plugin.getConfigCache().cannot_attack_attacker;
|
||||
case PET -> plugin.getConfigCache().cannot_attack_pets_victim;
|
||||
@@ -184,7 +185,7 @@ public class PlayerManager {
|
||||
return new DamageCheckResult(false, attackerId, victimId, message, victimClassifier.equals(Target.EntityClassifier.PLAYER));
|
||||
}
|
||||
|
||||
if (!victimPlayerData.isPvpEnabled()) {
|
||||
if (!victimPlayerData.isPvpEnabled() && !WorldGuardHook.isPlayerForcedToPvp(Bukkit.getPlayer(victimId))) {
|
||||
String message = switch (victimClassifier) {
|
||||
case PLAYER -> plugin.getConfigCache().cannot_attack_victim;
|
||||
case PET -> plugin.getConfigCache().cannot_attack_pets_attacker;
|
||||
|
||||
@@ -52,6 +52,8 @@ public class WorldGuardHook {
|
||||
}
|
||||
|
||||
public static boolean isPlayerForcedToPvp(Player player) {
|
||||
if (player == null) return false;
|
||||
if (!PreventStabby.worldGuardHookEnabled()) return false;
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
org.bukkit.Location loc = player.getLocation();
|
||||
|
||||
Reference in New Issue
Block a user