From 2aeb55cff929817549cf088775b1a379eddc93d9 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 20 Jan 2014 09:28:49 +1300 Subject: [PATCH] Changed the feature somewhat --- config.yml | 2 ++ src/me/libraryaddict/disguise/DisguiseAPI.java | 11 ----------- .../libraryaddict/disguise/DisguiseListener.java | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/config.yml b/config.yml index 5cd189da..2a4ee9c2 100644 --- a/config.yml +++ b/config.yml @@ -47,4 +47,6 @@ NameAboveHeadAlwaysVisible: true # This may have conflicts with some plugins, such as nocheatplus ModifyBoundingBox: false # This prevents disguised players from being targeted by monsters. +# This doesn't prevent their targeting you if already targeting when disguised +# They will just ignore you unless provoked. MonstersIgnoreDisguises: false \ No newline at end of file diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index e2cd1594..06272c73 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -14,7 +14,6 @@ import me.libraryaddict.disguise.utilities.PacketsManager; import me.libraryaddict.disguise.utilities.ReflectionManager; import org.bukkit.Bukkit; -import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -64,16 +63,6 @@ public class DisguiseAPI { DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise); // If he is a player, then self disguise himself DisguiseUtilities.setupFakeDisguise(disguise); - // If the disguised is a player and you can't target disguised players.. - if (isMonstersIgnoreDisguises() && entity instanceof Player) { - for (Entity monster : entity.getWorld().getEntities()) { - if (monster instanceof Creature) { - if (((Creature) monster).getTarget() == entity) { - ((Creature) monster).setTarget(null); - } - } - } - } } public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List playersToNotSeeDisguise) { diff --git a/src/me/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java index 912035ad..c61ffcb6 100644 --- a/src/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/me/libraryaddict/disguise/DisguiseListener.java @@ -15,7 +15,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -113,9 +112,18 @@ public class DisguiseListener implements Listener { @EventHandler public void onTarget(EntityTargetEvent event) { - if (DisguiseAPI.isMonstersIgnoreDisguises() && event.getReason() != TargetReason.CUSTOM && event.getTarget() != null - && event.getTarget() instanceof Player && DisguiseAPI.isDisguised(event.getTarget())) { - event.setCancelled(true); + if (DisguiseAPI.isMonstersIgnoreDisguises() && event.getTarget() != null && event.getTarget() instanceof Player + && DisguiseAPI.isDisguised(event.getTarget())) { + switch (event.getReason()) { + case TARGET_ATTACKED_ENTITY: + case TARGET_ATTACKED_OWNER: + case OWNER_ATTACKED_TARGET: + case CUSTOM: + break; + default: + event.setCancelled(true); + break; + } } }