Skip to content

Commit

Permalink
allow damaging mounts with non-player riders
Browse files Browse the repository at this point in the history
  • Loading branch information
YouHaveTrouble committed Mar 17, 2022
1 parent 4c08041 commit cd26d62
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/me/youhavetrouble/preventstabby/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<UUID> playerPassengersWithPvpEnabled = new HashSet<>();

boolean hasPlayerPassengers = false;
Expand All @@ -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;
}
Expand Down

0 comments on commit cd26d62

Please sign in to comment.