diff --git a/changelog.md b/changelog.md index b76ca7e..a6afc69 100644 --- a/changelog.md +++ b/changelog.md @@ -20,6 +20,7 @@ These changes will (most likely) be included in the next version. - The `player-time-in-arena` setting has been fixed. - The `soft-restore` setting has been fixed for blocks broken by players. Note that the functionality is still unreliable for non-trivial blocks. - Config-file errors imposed by incorrect usage of `/ma setting` no longer cause "internal errors". Instead, the errors are properly communicated in the command output similar to how the `/ma reload` command works. +- Guardians and elder guardians no longer instantly retarget players when they break line of sight. This should make their behavior work a bit closer to vanilla. - The MagicSpells integration has been removed. This means that the extra `magicspells.yml` config-file (if it exists) no longer does anything and can be removed. ## [0.104.2] - 2020-01-03 diff --git a/src/main/java/com/garbagemule/MobArena/ArenaListener.java b/src/main/java/com/garbagemule/MobArena/ArenaListener.java index 4804196..49ebc28 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaListener.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaListener.java @@ -95,6 +95,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; +import java.util.EnumSet; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -125,6 +126,8 @@ public class ArenaListener private Set banned; + private EnumSet excludeFromRetargeting; + public ArenaListener(Arena arena, MobArena plugin) { this.plugin = plugin; this.arena = arena; @@ -154,6 +157,11 @@ public class ArenaListener this.classLimits = arena.getClassLimitManager(); this.banned = new HashSet<>(); + + this.excludeFromRetargeting = EnumSet.of( + EntityType.ELDER_GUARDIAN, + EntityType.GUARDIAN + ); } void pvpActivate() { @@ -849,6 +857,10 @@ public class ArenaListener private void onMonsterTarget(EntityTargetEvent event, Entity monster, Entity target) { // Null means we lost our target or the target died, so find a new one if (target == null) { + // ... unless the monster is excluded from retargeting + if (excludeFromRetargeting.contains(monster.getType())) { + return; + } event.setTarget(MAUtils.getClosestPlayer(plugin, monster, arena)); return; }