Player is no longer invisible to himself when undisguising

This commit is contained in:
Andrew 2013-08-01 19:56:27 +12:00
parent ec69f17aa3
commit 0981a0a88a

View File

@ -61,13 +61,13 @@ import com.comphenix.protocol.reflect.StructureModifier;
public class DisguiseAPI { public class DisguiseAPI {
private static HashMap<Entity, Disguise> disguises = new HashMap<Entity, Disguise>(); private static HashMap<Entity, Disguise> disguises = new HashMap<Entity, Disguise>();
private static boolean hearSelfDisguise;
private static LibsDisguises libsDisguises; private static LibsDisguises libsDisguises;
private static PacketListener packetListener; private static PacketListener packetListener;
private static HashMap<Integer, Integer> selfDisguisesIds = new HashMap<Integer, Integer>();
private static boolean sendVelocity; private static boolean sendVelocity;
private static boolean soundsEnabled; private static boolean soundsEnabled;
private static HashMap<Integer, Integer> selfDisguisesIds = new HashMap<Integer, Integer>();
private static boolean viewDisguises; private static boolean viewDisguises;
private static boolean hearSelfDisguise;
private static PacketListener viewDisguisesListener; private static PacketListener viewDisguisesListener;
private synchronized static Disguise access(Entity entity, Disguise... args) { private synchronized static Disguise access(Entity entity, Disguise... args) {
@ -83,6 +83,10 @@ public class DisguiseAPI {
return null; return null;
} }
public static boolean canHearSelfDisguise() {
return hearSelfDisguise;
}
/** /**
* @param Player * @param Player
* - The player to disguise * - The player to disguise
@ -124,16 +128,6 @@ public class DisguiseAPI {
} }
} }
public static void setHearSelfDisguise(boolean replaceSound) {
if (hearSelfDisguise != replaceSound) {
hearSelfDisguise = replaceSound;
}
}
public static boolean canHearSelfDisguise() {
return hearSelfDisguise;
}
private static Disguise get(Entity obj) { private static Disguise get(Entity obj) {
return access(obj); return access(obj);
} }
@ -452,13 +446,28 @@ public class DisguiseAPI {
ex.printStackTrace(); ex.printStackTrace();
} }
selfDisguisesIds.remove(player.getEntityId()); selfDisguisesIds.remove(player.getEntityId());
}
EntityPlayer entityplayer = ((CraftPlayer) player).getHandle(); EntityPlayer entityplayer = ((CraftPlayer) player).getHandle();
EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) entityplayer.world).tracker.trackedEntities.get(player EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) entityplayer.world).tracker.trackedEntities
.getEntityId()); .get(player.getEntityId());
if (tracker != null) { if (tracker != null) {
tracker.trackedPlayers.remove(entityplayer); tracker.trackedPlayers.remove(entityplayer);
} }
PacketContainer packetMetadata = new PacketContainer(Packets.Server.ENTITY_METADATA);
StructureModifier<Object> mods = packetMetadata.getModifier();
mods.write(0, player.getEntityId());
mods.write(1, entityplayer.getDataWatcher().c());
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packetMetadata);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public static void setHearSelfDisguise(boolean replaceSound) {
if (hearSelfDisguise != replaceSound) {
hearSelfDisguise = replaceSound;
}
} }
private static void setupPlayer(Player player) { private static void setupPlayer(Player player) {