mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-11 21:06:55 +00:00
check for worldguard force pvp region within pvp check
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.youhavetrouble</groupId>
|
<groupId>me.youhavetrouble</groupId>
|
||||||
<artifactId>PreventStabby</artifactId>
|
<artifactId>PreventStabby</artifactId>
|
||||||
<version>2.0.0-rc-2</version>
|
<version>2.0.0-rc-3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>PreventStabby</name>
|
<name>PreventStabby</name>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package me.youhavetrouble.preventstabby.data;
|
|||||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||||
import me.youhavetrouble.preventstabby.api.event.PlayerEnterCombatEvent;
|
import me.youhavetrouble.preventstabby.api.event.PlayerEnterCombatEvent;
|
||||||
import me.youhavetrouble.preventstabby.api.event.PlayerLeaveCombatEvent;
|
import me.youhavetrouble.preventstabby.api.event.PlayerLeaveCombatEvent;
|
||||||
|
import me.youhavetrouble.preventstabby.hooks.WorldGuardHook;
|
||||||
import me.youhavetrouble.preventstabby.util.PluginMessages;
|
import me.youhavetrouble.preventstabby.util.PluginMessages;
|
||||||
import me.youhavetrouble.preventstabby.util.PvpState;
|
import me.youhavetrouble.preventstabby.util.PvpState;
|
||||||
import org.bukkit.Bukkit;
|
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) {
|
String message = switch (victimClassifier) {
|
||||||
case PLAYER -> plugin.getConfigCache().cannot_attack_attacker;
|
case PLAYER -> plugin.getConfigCache().cannot_attack_attacker;
|
||||||
case PET -> plugin.getConfigCache().cannot_attack_pets_victim;
|
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));
|
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) {
|
String message = switch (victimClassifier) {
|
||||||
case PLAYER -> plugin.getConfigCache().cannot_attack_victim;
|
case PLAYER -> plugin.getConfigCache().cannot_attack_victim;
|
||||||
case PET -> plugin.getConfigCache().cannot_attack_pets_attacker;
|
case PET -> plugin.getConfigCache().cannot_attack_pets_attacker;
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ public class WorldGuardHook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlayerForcedToPvp(Player player) {
|
public static boolean isPlayerForcedToPvp(Player player) {
|
||||||
|
if (player == null) return false;
|
||||||
|
if (!PreventStabby.worldGuardHookEnabled()) return false;
|
||||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
RegionQuery query = container.createQuery();
|
RegionQuery query = container.createQuery();
|
||||||
org.bukkit.Location loc = player.getLocation();
|
org.bukkit.Location loc = player.getLocation();
|
||||||
|
|||||||
Reference in New Issue
Block a user