Fixed switching to non-self disguise freezing players

This commit is contained in:
libraryaddict 2019-08-13 20:32:13 +12:00
parent aec78e2321
commit 0c4262a6ff

View File

@ -1132,7 +1132,6 @@ public class DisguiseUtilities {
return;
}
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
try {
if (selfDisguised.contains(disguise.getEntity().getUniqueId()) && disguise.isDisguiseInUse()) {
@ -1140,6 +1139,8 @@ public class DisguiseUtilities {
selfDisguised.add(disguise.getEntity().getUniqueId());
PacketContainer destroyPacket = getDestroyPacket(DisguiseAPI.getSelfDisguiseId());
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> {
@ -1165,6 +1166,7 @@ public class DisguiseUtilities {
.getNmsMethod("EntityTrackerEntry", "b", ReflectionManager.getNmsClass("EntityPlayer"));
trackedPlayers = (Set) new HashSet(trackedPlayers).clone();
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
for (final Object p : trackedPlayers) {
Player player = (Player) ReflectionManager.getBukkitEntity(p);
@ -1256,8 +1258,7 @@ public class DisguiseUtilities {
// If the tracker exists. Remove himself from his tracker
if (isHashSet(trackedPlayersObj)) {
((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
.get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player));
((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getNmsEntity(player));
} else {
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap")
.get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player));
@ -1548,8 +1549,7 @@ public class DisguiseUtilities {
// Check for code differences in PaperSpigot vs Spigot
if (isHashSet(trackedPlayersObj)) {
((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
.get(entityTrackerEntry)).add(ReflectionManager.getNmsEntity(player));
((Set<Object>) trackedPlayersObj).add(ReflectionManager.getNmsEntity(player));
} else {
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap")
.get(entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true);