From efa75e677f2e8f445243159371e0b252fd1b67d4 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 2 Dec 2013 04:37:07 +1300 Subject: [PATCH] More stuff. Self disguises no work :( --- .../libraryaddict/disguise/DisguiseAPI.java | 52 ++++--- .../disguise/disguisetypes/Disguise.java | 11 +- .../disguise/disguisetypes/FlagWatcher.java | 6 +- .../disguise/disguisetypes/MiscDisguise.java | 2 +- .../disguise/disguisetypes/MobDisguise.java | 2 +- .../disguisetypes/PlayerDisguise.java | 2 +- .../disguisetypes/TargetedDisguise.java | 60 ++++++++ .../disguisetypes/TargettedDisguise.java | 51 ------- .../watchers/FallingBlockWatcher.java | 2 +- .../watchers/PaintingWatcher.java | 2 +- .../watchers/SplashPotionWatcher.java | 2 +- .../disguise/utilities/DisguiseUtilities.java | 133 ++++++++++++++---- 12 files changed, 214 insertions(+), 111 deletions(-) create mode 100644 src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java delete mode 100644 src/me/libraryaddict/disguise/disguisetypes/TargettedDisguise.java diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index a800910b..90358359 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -1,9 +1,11 @@ package me.libraryaddict.disguise; import java.lang.reflect.Field; +import java.util.List; + import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.TargettedDisguise; -import me.libraryaddict.disguise.disguisetypes.TargettedDisguise.TargetType; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType; import me.libraryaddict.disguise.events.DisguiseEvent; import me.libraryaddict.disguise.events.UndisguiseEvent; import me.libraryaddict.disguise.utilities.DisguiseUtilities; @@ -26,6 +28,18 @@ public class DisguiseAPI { return hearSelfDisguise; } + public static void disguiseToPlayers(Entity entity, Disguise disguise, List players) { + ((TargetedDisguise) disguise).setTargetType(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS); + ((TargetedDisguise) disguise).getObservers().addAll(players); + disguiseEntity(entity, disguise); + } + + public static void disguiseToEveryoneButThese(Entity entity, Disguise disguise, List players) { + ((TargetedDisguise) disguise).setTargetType(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS); + ((TargetedDisguise) disguise).getObservers().addAll(players); + disguiseEntity(entity, disguise); + } + /** * Disguise the next entity to spawn with this disguise. This may not work however if the entity doesn't actually spawn. */ @@ -39,23 +53,17 @@ public class DisguiseAPI { Field field = ReflectionManager.getNmsClass("Entity").getDeclaredField("entityCount"); field.setAccessible(true); int id = field.getInt(null); - DisguiseUtilities.addDisguise(id, (TargettedDisguise) disguise); + DisguiseUtilities.addDisguise(id, (TargetedDisguise) disguise); } catch (Exception ex) { ex.printStackTrace(); } } - /** - * Disguise this entity with this disguise - */ - public static void disguiseToAll(Entity entity, Disguise disguise) { + private static void disguiseEntity(Entity entity, Disguise disguise) { // If they are trying to disguise a null entity or use a null disguise // Just return. if (entity == null || disguise == null) return; - // You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!! - ((TargettedDisguise) disguise).setTargetType(TargetType.HIDE_FROM_THESE); - ((TargettedDisguise) disguise).getObservers().clear(); // Fire a disguise event DisguiseEvent event = new DisguiseEvent(entity, disguise); Bukkit.getPluginManager().callEvent(event); @@ -73,20 +81,24 @@ public class DisguiseAPI { } // Set the disguise's entity disguise.setEntity(entity); - } // If there was a old disguise - Disguise[] oldDisguises = getDisguises(entity); + } // Stick the disguise in the disguises bin - DisguiseUtilities.addDisguise(entity.getEntityId(), (TargettedDisguise) disguise); + DisguiseUtilities.addDisguise(entity.getEntityId(), (TargetedDisguise) disguise); // Resend the disguised entity's packet - DisguiseUtilities.refreshTrackers(entity); + DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise); // If he is a player, then self disguise himself DisguiseUtilities.setupFakeDisguise(disguise); - // Discard the disguise - for (Disguise oldDisguise : oldDisguises) { - oldDisguise.removeDisguise(); - // Make everyone see this disguise. Remove any old disguises. - DisguiseUtilities.getDisguises().remove(entity.getEntityId()); - } + } + + /** + * Disguise this entity with this disguise + */ + public static void disguiseToAll(Entity entity, Disguise disguise) { + // You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!! + ((TargetedDisguise) disguise).setTargetType(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS); + for (String observer : ((TargetedDisguise) disguise).getObservers()) + ((TargetedDisguise) disguise).unsetViewDisguise(observer); + disguiseEntity(entity, disguise); } /** diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 3cec8cec..fc40d476 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -175,6 +175,7 @@ public abstract class Disguise { final boolean sendMovementPacket = movement; final double vectorY = fallSpeed; final boolean alwaysSendVelocity = alwaysSend; + final TargetedDisguise disguise=(TargetedDisguise) this; // A scheduler to clean up any unused disguises. velocityRunnable = new BukkitRunnable() { private int i = 0; @@ -189,7 +190,7 @@ public abstract class Disguise { i++; if (i % 40 == 0) { i = 0; - DisguiseUtilities.refreshTrackers(getEntity()); + DisguiseUtilities.refreshTrackers(disguise); if (getEntity() instanceof Player && isSelfDisguiseVisible()) { DisguiseUtilities.sendSelfDisguise((Player) getEntity()); } @@ -298,7 +299,7 @@ public abstract class Disguise { .get(entityTrackerEntry); for (Object p : trackedPlayers) { Player player = (Player) ReflectionManager.getBukkitEntity(p); - if (((TargettedDisguise) this).canSee(player)) { + if (((TargetedDisguise) this).canSee(player)) { players.add(player); } } @@ -371,19 +372,19 @@ public abstract class Disguise { velocityRunnable.cancel(); } catch (Exception ex) { } - HashMap> disguises = DisguiseUtilities.getDisguises(); + HashMap> disguises = DisguiseUtilities.getDisguises(); // If this disguise has a entity set if (getEntity() != null) { // If the entity is valid if (getEntity().isValid()) { // If this disguise is active // Remove the disguise from the current disguises. - if (DisguiseUtilities.removeDisguise((TargettedDisguise) this)) { + if (DisguiseUtilities.removeDisguise((TargetedDisguise) this)) { if (getEntity() instanceof Player) { DisguiseUtilities.removeSelfDisguise((Player) getEntity()); } // Better refresh the entity to undisguise it - DisguiseUtilities.refreshTrackers(getEntity()); + DisguiseUtilities.refreshTrackers((TargetedDisguise) this); } } } else { diff --git a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index aabc30cc..18bc51aa 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -42,14 +42,14 @@ public class FlagWatcher { * This is the entity values I need to add else it could crash them.. */ private HashMap backupEntityValues = new HashMap(); - private Disguise disguise; + private TargetedDisguise disguise; private HashMap entityValues = new HashMap(); private boolean hasDied; private org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[5]; private HashSet modifiedEntityAnimations = new HashSet(); public FlagWatcher(Disguise disguise) { - this.disguise = disguise; + this.disguise = (TargetedDisguise) disguise; } @Override @@ -158,7 +158,7 @@ public class FlagWatcher { return armor; } - protected Disguise getDisguise() { + protected TargetedDisguise getDisguise() { return disguise; } diff --git a/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java index 97d6db0a..fa5a647d 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java @@ -11,7 +11,7 @@ import org.bukkit.Art; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; -public class MiscDisguise extends TargettedDisguise { +public class MiscDisguise extends TargetedDisguise { private int data = -1; private int id = -1; diff --git a/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java index 4b05daaf..1afa9991 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java @@ -5,7 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; import org.bukkit.entity.EntityType; -public class MobDisguise extends TargettedDisguise { +public class MobDisguise extends TargetedDisguise { private boolean isAdult; diff --git a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index c2b82b9e..0647d3e5 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -1,6 +1,6 @@ package me.libraryaddict.disguise.disguisetypes; -public class PlayerDisguise extends TargettedDisguise { +public class PlayerDisguise extends TargetedDisguise { private String playerName; public PlayerDisguise(String name) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java new file mode 100644 index 00000000..a38a9269 --- /dev/null +++ b/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java @@ -0,0 +1,60 @@ +package me.libraryaddict.disguise.disguisetypes; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +import me.libraryaddict.disguise.utilities.DisguiseUtilities; + +import org.bukkit.entity.Player; + +public abstract class TargetedDisguise extends Disguise { + public enum TargetType { + HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS, SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; + } + + public void setTargetType(TargetType newTargetType) { + if (DisguiseUtilities.isDisguiseInUse(this)) { + throw new RuntimeException("Cannot set the disguise target after the entity has been disguised"); + } + targetType = newTargetType; + } + + private List disguiseViewers = new ArrayList(); + private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; + + public boolean canSee(Player player) { + return canSee(player.getName()); + } + + public List getObservers() { + return Collections.unmodifiableList(disguiseViewers); + } + + public boolean canSee(String playername) { + boolean contains = disguiseViewers.contains(playername); + if (targetType == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + return !contains; + } + return contains; + } + + public void setViewDisguise(String playername) { + if (!disguiseViewers.contains(playername)) { + disguiseViewers.add(playername); + DisguiseUtilities.checkConflicts(this, playername); + } + } + + public void unsetViewDisguise(String playername) { + if (disguiseViewers.contains(playername)) { + disguiseViewers.remove(playername); + DisguiseUtilities.checkConflicts(this, playername); + } + } + + public TargetType getTargetType() { + return targetType; + } +} diff --git a/src/me/libraryaddict/disguise/disguisetypes/TargettedDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/TargettedDisguise.java deleted file mode 100644 index f0ae3986..00000000 --- a/src/me/libraryaddict/disguise/disguisetypes/TargettedDisguise.java +++ /dev/null @@ -1,51 +0,0 @@ -package me.libraryaddict.disguise.disguisetypes; - -import java.util.HashSet; - -import me.libraryaddict.disguise.utilities.DisguiseUtilities; - -import org.bukkit.entity.Player; - -public abstract class TargettedDisguise extends Disguise { - public enum TargetType { - SHOW_TO_THESE, HIDE_FROM_THESE; - } - - public void setTargetType(TargetType newTargetType) { - if (DisguiseUtilities.isDisguiseInUse(this)) { - throw new RuntimeException("Cannot set the disguise target after the entity has been disguised"); - } - targetType = newTargetType; - } - - private HashSet disguiseViewers = new HashSet(); - private TargetType targetType = TargetType.HIDE_FROM_THESE; - - public boolean canSee(Player player) { - return canSee(player.getName()); - } - - public HashSet getObservers() { - return disguiseViewers; - } - - public boolean canSee(String playername) { - boolean contains = disguiseViewers.contains(playername); - if (targetType == TargetType.HIDE_FROM_THESE) { - return !contains; - } - return contains; - } - - public void setViewDisguise(Player player) { - setViewDisguise(player.getName()); - } - - public void setViewDisguise(String playername) { - disguiseViewers.add(playername); - } - - public TargetType getTargetType() { - return targetType; - } -} diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java index 11d6797f..5a823c61 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java @@ -27,7 +27,7 @@ public class FallingBlockWatcher extends FlagWatcher { public void setBlock(ItemStack block) { this.block = block; if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) { - DisguiseUtilities.refreshTrackers(getDisguise().getEntity()); + DisguiseUtilities.refreshTrackers(getDisguise()); } } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java index 3ae3ee1b..1c27ede2 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java @@ -26,7 +26,7 @@ public class PaintingWatcher extends FlagWatcher { public void setArt(Art newPainting) { this.painting = newPainting; if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) { - DisguiseUtilities.refreshTrackers(getDisguise().getEntity()); + DisguiseUtilities.refreshTrackers(getDisguise()); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java index 44d1c45c..21ff5919 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java @@ -25,7 +25,7 @@ public class SplashPotionWatcher extends FlagWatcher { public void setPotionId(int newPotionId) { this.potionId = newPotionId; if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) { - DisguiseUtilities.refreshTrackers(getDisguise().getEntity()); + DisguiseUtilities.refreshTrackers(getDisguise()); } } diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 01555947..ab842dc9 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -6,10 +6,11 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.TargettedDisguise; -import me.libraryaddict.disguise.disguisetypes.TargettedDisguise.TargetType; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -28,13 +29,13 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher; public class DisguiseUtilities { // Store the entity IDs instead of entitys because then I can disguise entitys even before they exist - private static HashMap> targetedDisguises = new HashMap>(); + private static HashMap> targetedDisguises = new HashMap>(); private static LibsDisguises libsDisguises; // A internal storage of fake entity ID's I can use. // Realistically I could probably use a ID like "4" for everyone, seeing as no one shares the ID private static HashMap selfDisguisesIds = new HashMap(); - public static HashMap> getDisguises() { + public static HashMap> getDisguises() { return targetedDisguises; } @@ -47,7 +48,7 @@ public class DisguiseUtilities { } public static boolean isDisguiseInUse(Disguise disguise) { - if (getDisguises().containsKey(disguise.getEntity().getEntityId()) + if (disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getEntityId()) && getDisguises().get(disguise.getEntity().getEntityId()).contains(disguise)) { return true; } @@ -58,13 +59,13 @@ public class DisguiseUtilities { * @param Resends * the entity to all the watching players, which is where the magic begins */ - public static void refreshTrackers(Entity entity) { + public static void refreshTrackers(TargetedDisguise disguise) { try { - Object world = ReflectionManager.getWorld(entity.getWorld()); + Object world = ReflectionManager.getWorld(disguise.getEntity().getWorld()); Object tracker = world.getClass().getField("tracker").get(world); Object trackedEntities = tracker.getClass().getField("trackedEntities").get(tracker); Object entityTrackerEntry = trackedEntities.getClass().getMethod("get", int.class) - .invoke(trackedEntities, entity.getEntityId()); + .invoke(trackedEntities, disguise.getEntity().getEntityId()); if (entityTrackerEntry != null) { HashSet trackedPlayers = (HashSet) entityTrackerEntry.getClass().getField("trackedPlayers") .get(entityTrackerEntry); @@ -72,11 +73,15 @@ public class DisguiseUtilities { Method updatePlayer = entityTrackerEntry.getClass().getMethod("updatePlayer", ReflectionManager.getNmsClass("EntityPlayer")); HashSet cloned = (HashSet) trackedPlayers.clone(); - for (Object player : cloned) { - if (entity instanceof Player && !((Player) ReflectionManager.getBukkitEntity(player)).canSee((Player) entity)) - continue; - clear.invoke(entityTrackerEntry, player); - updatePlayer.invoke(entityTrackerEntry, player); + for (Object p : cloned) { + Player player = (Player) ReflectionManager.getBukkitEntity(p); + // if (entity instanceof Player && !((Player) ReflectionManager.getBukkitEntity(player)).canSee((Player) + // entity)) + // continue; + if (disguise.canSee(player.getName())) { + clear.invoke(entityTrackerEntry, p); + updatePlayer.invoke(entityTrackerEntry, p); + } } } } catch (Exception ex) { @@ -232,14 +237,89 @@ public class DisguiseUtilities { } } - public static void addDisguise(int entityId, TargettedDisguise disguise) { + public static void addDisguise(int entityId, TargetedDisguise disguise) { + // TODO Make sure that the disguised entity doesn't have the player looking at other girls + // ^ Done? if (!getDisguises().containsKey(entityId)) { - getDisguises().put(entityId, new HashSet()); + getDisguises().put(entityId, new HashSet()); } getDisguises().get(entityId).add(disguise); + checkConflicts(disguise, null); } - public static boolean removeDisguise(TargettedDisguise disguise) { + /** + * If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the + * observers in the disguise don't see any other disguise. + */ + public static void checkConflicts(TargetedDisguise disguise, String name) { + if (DisguiseAPI.isDisguiseInUse(disguise)) { + Iterator disguiseItel = getDisguises().get(disguise.getEntity().getEntityId()).iterator(); + while (disguiseItel.hasNext()) { + TargetedDisguise d = disguiseItel.next(); + if (d != disguise) { + if (d.getTargetType() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) { + // If player is a observer in the loop + if (disguise.getTargetType() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) { + // If player is a observer in the disguise + // Remove them from the loop + if (name != null) { + d.unsetViewDisguise(name); + } else { + for (String playername : disguise.getObservers()) { + d.unsetViewDisguise(playername); + } + } + } else if (disguise.getTargetType() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + // If player is not a observer in the loop + if (name != null) { + if (!disguise.getObservers().contains(name)) { + d.unsetViewDisguise(name); + } + } else { + for (String playername : d.getObservers()) { + if (!disguise.getObservers().contains(playername)) { + d.unsetViewDisguise(playername); + } + } + } + } + } else if (d.getTargetType() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + // Here you add it to the loop if they see the disguise + if (disguise.getTargetType() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) { + // Everyone who is in the disguise needs to be added to the loop + if (name != null) { + d.setViewDisguise(name); + } else { + for (String playername : disguise.getObservers()) { + d.setViewDisguise(playername); + } + } + } else if (disguise.getTargetType() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + // This here is a paradox. + // If fed a name. I can do this. + // But the rest of the time.. Its going to conflict. + System.out.print("Cannot set more than one " + TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS + + " on a entity. Removed the old disguise."); + disguiseItel.remove(); + /* if (name != null) { + if (!disguise.getObservers().contains(name)) { + d.setViewDisguise(name); + } + } else { + for (String playername : d.getObservers()) { + if (!disguise.getObservers().contains(playername)) { + d.setViewDisguise(playername); + } + } + }*/ + } + } + } + } + } + } + + public static boolean removeDisguise(TargetedDisguise disguise) { int entityId = disguise.getEntity().getEntityId(); if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) { if (getDisguises().get(entityId).isEmpty()) { @@ -251,11 +331,12 @@ public class DisguiseUtilities { } @Deprecated - public static TargettedDisguise getDisguise(int entityId) { - TargettedDisguise toReturn = null; + public static TargetedDisguise getDisguise(int entityId) { + TargetedDisguise toReturn = null; if (getDisguises().containsKey(entityId)) { - for (TargettedDisguise disguise : getDisguises().get(entityId)) { - if (disguise.getTargetType() == TargetType.HIDE_FROM_THESE && disguise.getObservers().isEmpty()) { + for (TargetedDisguise disguise : getDisguises().get(entityId)) { + if (disguise.getTargetType() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS + && disguise.getObservers().isEmpty()) { return disguise; } if (toReturn == null) { @@ -266,16 +347,16 @@ public class DisguiseUtilities { return toReturn; } - public static TargettedDisguise[] getDisguises(int entityId) { + public static TargetedDisguise[] getDisguises(int entityId) { if (getDisguises().containsKey(entityId)) { - return getDisguises().get(entityId).toArray(new TargettedDisguise[getDisguises().get(entityId).size()]); + return getDisguises().get(entityId).toArray(new TargetedDisguise[getDisguises().get(entityId).size()]); } - return new TargettedDisguise[0]; + return new TargetedDisguise[0]; } - public static TargettedDisguise getDisguise(Player observer, int entityId) { + public static TargetedDisguise getDisguise(Player observer, int entityId) { if (getDisguises().containsKey(entityId)) { - for (TargettedDisguise disguise : getDisguises().get(entityId)) { + for (TargetedDisguise disguise : getDisguises().get(entityId)) { if (disguise.canSee(observer)) { return disguise; } @@ -291,7 +372,7 @@ public class DisguiseUtilities { Entity e = disguise.getEntity(); // If the disguises entity is null, or the disguised entity isn't a player return if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getEntityId()) - || !getDisguises().get(e).contains(disguise)) + || !getDisguises().get(e.getEntityId()).contains(disguise)) return; Player player = (Player) e; // Remove the old disguise, else we have weird disguises around the place