From cd26d621e57ba1386fc14fe4763b09527ee38e02 Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Thu, 17 Mar 2022 20:58:39 +0100 Subject: [PATCH] allow damaging mounts with non-player riders --- .../me/youhavetrouble/preventstabby/util/Util.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/youhavetrouble/preventstabby/util/Util.java b/src/main/java/me/youhavetrouble/preventstabby/util/Util.java index 5f12159..f097a2a 100644 --- a/src/main/java/me/youhavetrouble/preventstabby/util/Util.java +++ b/src/main/java/me/youhavetrouble/preventstabby/util/Util.java @@ -38,11 +38,6 @@ public static boolean processMountAttack(UUID attacker, Entity mount) { ConfigCache config = PreventStabby.getPlugin().getConfigCache(); - if (!PreventStabby.getPlugin().getPlayerManager().getPlayerPvPState(attacker)) { - PluginMessages.sendActionBar(attacker, config.getCannot_attack_mounts_attacker()); - return true; - } - Set playerPassengersWithPvpEnabled = new HashSet<>(); boolean hasPlayerPassengers = false; @@ -54,7 +49,14 @@ public static boolean processMountAttack(UUID attacker, Entity mount) { playerPassengersWithPvpEnabled.add(player.getUniqueId()); } - if (hasPlayerPassengers && playerPassengersWithPvpEnabled.isEmpty()) { + if (!hasPlayerPassengers) return false; + + if (!PreventStabby.getPlugin().getPlayerManager().getPlayerPvPState(attacker)) { + PluginMessages.sendActionBar(attacker, config.getCannot_attack_mounts_attacker()); + return true; + } + + if (playerPassengersWithPvpEnabled.isEmpty()) { PluginMessages.sendActionBar(attacker, config.getCannot_attack_mounts_victim()); return true; }