mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 13:26:56 +00:00
fix worldguard hook errors
This commit is contained in:
@@ -112,24 +112,25 @@ public class PlayerManager {
|
||||
public boolean canDamage(UUID attacker, UUID victim, boolean sendDenyMessage, boolean checkVictimSpawnProtection) {
|
||||
|
||||
if (hasLoginProtection(attacker) || hasTeleportProtection(attacker)) return false;
|
||||
|
||||
if (checkVictimSpawnProtection && hasLoginProtection(victim)) return false;
|
||||
|
||||
if (checkVictimSpawnProtection && hasTeleportProtection(victim)) return false;
|
||||
|
||||
SmartCache smartCache = PreventStabby.getPlugin().getSmartCache();
|
||||
|
||||
Player attackerPlayer = Bukkit.getPlayer(attacker);
|
||||
Player victimPlayer = Bukkit.getPlayer(victim);
|
||||
if (!smartCache.getPlayerData(attacker).isPvpEnabled()) {
|
||||
Player attackerPlayer = Bukkit.getPlayer(attacker);
|
||||
if (PreventStabby.worldGuardHookEnabled() && WorldGuardHook.isPlayerForcedToPvp(attackerPlayer)) return true;
|
||||
|
||||
if (!smartCache.getPlayerData(attacker).isPvpEnabled() && (attackerPlayer != null && !isInForcedPvpRegion(attackerPlayer))) {
|
||||
if (sendDenyMessage) {
|
||||
ConfigCache config = PreventStabby.getPlugin().getConfigCache();
|
||||
PluginMessages.sendActionBar(attacker, config.getCannot_attack_attacker());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!smartCache.getPlayerData(victim).isPvpEnabled() && (victimPlayer != null && !isInForcedPvpRegion(victimPlayer))) {
|
||||
if (!smartCache.getPlayerData(victim).isPvpEnabled()) {
|
||||
Player victimPlayer = Bukkit.getPlayer(victim);
|
||||
if (PreventStabby.worldGuardHookEnabled() && WorldGuardHook.isPlayerForcedToPvp(victimPlayer)) return true;
|
||||
|
||||
if (sendDenyMessage) {
|
||||
ConfigCache config = PreventStabby.getPlugin().getConfigCache();
|
||||
PluginMessages.sendActionBar(attacker, config.getCannot_attack_victim());
|
||||
@@ -157,9 +158,4 @@ public class PlayerManager {
|
||||
return Instant.now().getEpochSecond() < smartCache.getPlayerData(uuid).getTeleportTimestamp();
|
||||
}
|
||||
|
||||
public boolean isInForcedPvpRegion(Player player) {
|
||||
if (!WorldGuardHook.isHooked()) return false;
|
||||
return WorldGuardHook.isPlayerForcedToPvp(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user