Changed the feature somewhat

This commit is contained in:
libraryaddict 2014-01-20 09:28:49 +13:00
parent 58ee6f37b7
commit 2aeb55cff9
3 changed files with 14 additions and 15 deletions

View File

@ -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

View File

@ -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<String> playersToNotSeeDisguise) {

View File

@ -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;
}
}
}