Send self disguise in the same tracker refresh entry..

This commit is contained in:
libraryaddict 2014-06-21 07:58:37 +12:00
parent bd317b4cce
commit 992e416edf
2 changed files with 8 additions and 11 deletions

View File

@ -3,7 +3,6 @@ package me.libraryaddict.disguise.disguisetypes;
import java.util.UUID;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
@ -102,9 +101,6 @@ public class PlayerDisguise extends TargetedDisguise {
setSkin(gameProfile);
if (DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) {
DisguiseUtilities.refreshTrackers(PlayerDisguise.this);
if (getEntity() instanceof Player && isSelfDisguiseVisible()) {
DisguiseUtilities.sendSelfDisguise((Player) getEntity(), PlayerDisguise.this);
}
}
}
}

View File

@ -345,9 +345,6 @@ public class DisguiseUtilities {
}
if (DisguiseAPI.isDisguiseInUse(disguise)) {
DisguiseUtilities.refreshTrackers(disguise);
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
}
}
}
});
@ -518,6 +515,9 @@ public class DisguiseUtilities {
*/
public static void refreshTrackers(TargetedDisguise disguise) {
try {
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player) {
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
}
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
if (entityTrackerEntry != null) {
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
@ -532,7 +532,7 @@ public class DisguiseUtilities {
// if (entity instanceof Player && !((Player) ReflectionManager.getBukkitEntity(player)).canSee((Player)
// entity))
// continue;
if (player == disguise.getEntity() || disguise.canSee(player.getName())) {
if (disguise.canSee(player.getName())) {
clear.invoke(entityTrackerEntry, p);
updatePlayer.invoke(entityTrackerEntry, p);
}
@ -609,9 +609,10 @@ public class DisguiseUtilities {
/**
* Sends the self disguise to the player
*/
public static void sendSelfDisguise(final Player player, final Disguise disguise) {
public static void sendSelfDisguise(final Player player, final TargetedDisguise disguise) {
try {
if (!player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible()) {
if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible()
|| !disguise.canSee(player)) {
return;
}
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player);
@ -748,7 +749,7 @@ public class DisguiseUtilities {
return;
}
selfDisguised.add(player.getUniqueId());
sendSelfDisguise(player, disguise);
sendSelfDisguise(player, (TargetedDisguise) disguise);
if (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()) {
if (PacketsManager.isInventoryListenerEnabled()) {
player.updateInventory();