diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index 6bc000be..5326d402 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -415,7 +415,7 @@ public class DisguiseConfig { setMovementPacketsEnabled(config.getBoolean("PacketsEnabled.Movement")); setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible")); setNameOfPlayerShownAboveDisguise(config.getBoolean("ShowNamesAboveDisguises")); - setPlayerDisguisesTablistExpires(config.getInt("PlayerDisguisesTablistExpires")); + setPlayerDisguisesTablistExpires(config.getInt("PlayerDisguisesTablistExpiry")); setPlayerHideArmor(config.getBoolean("PlayerHideArmor")); setRetaliationCombat(config.getBoolean("RetaliationCombat")); setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities")); diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java index 1e0f52d0..b373fe62 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java @@ -420,14 +420,8 @@ public class DisguiseListener implements Listener { if (disguise.isDisplayedInTab()) { try { - PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); - - addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); - addTab.getPlayerInfoDataLists().write(0, Collections.singletonList( - new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, - WrappedChatComponent.fromText(disguise.getGameProfile().getName())))); - - ProtocolLibrary.getProtocolManager().sendServerPacket(p, addTab); + ProtocolLibrary.getProtocolManager().sendServerPacket(p, + DisguiseUtilities.getTabPacket(disguise, PlayerInfoAction.ADD_PLAYER)); } catch (InvocationTargetException e) { e.printStackTrace(); diff --git a/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java b/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java index be9c2fd6..d16ce364 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/modify/DisguiseModifyRadiusCommand.java @@ -155,6 +155,10 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements else disguise = DisguiseAPI.getDisguise(entity); + if (disguise == null) { + continue; + } + DisguisePerm disguisePerm = new DisguisePerm(disguise.getType()); if (!permissions.isAllowedDisguise(disguisePerm)) { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index adb0fb10..2f1ea027 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -962,11 +962,7 @@ public abstract class Disguise { PlayerDisguise disguise = (PlayerDisguise) this; if (disguise.isDisplayedInTab()) { - PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); - addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); - addTab.getPlayerInfoDataLists().write(0, Collections.singletonList( - new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, - WrappedChatComponent.fromText(disguise.getProfileName())))); + PacketContainer addTab = DisguiseUtilities.getTabPacket(disguise, PlayerInfoAction.ADD_PLAYER); try { for (Player player : Bukkit.getOnlinePlayers()) { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index 7e37549e..fbedf7fd 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -10,6 +10,7 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedGameProfile; import lombok.Getter; import lombok.Setter; +import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; @@ -98,6 +99,10 @@ public class PlayerDisguise extends TargetedDisguise { return scoreboardName; } + private void setScoreboardName(String[] split) { + getScoreboardName().setSplit(split); + } + private boolean isStaticName(String name) { return name != null && (name.equalsIgnoreCase("Dinnerbone") || name.equalsIgnoreCase("Grumm")); } @@ -229,7 +234,7 @@ public class PlayerDisguise extends TargetedDisguise { String[] split = DisguiseUtilities.getExtendedNameSplit(team.getPlayer(), name); resendDisguise = !split[1].equals(team.getPlayer()); - team.setSplit(split); + setScoreboardName(split); } resendDisguise = @@ -268,12 +273,28 @@ public class PlayerDisguise extends TargetedDisguise { playerName = name; } + + if (isDisplayedInTab()) { + PacketContainer addTab = DisguiseUtilities.getTabPacket(this, PlayerInfoAction.UPDATE_DISPLAY_NAME); + + try { + for (Player player : Bukkit.getOnlinePlayers()) { + if (!canSee(player)) + continue; + + ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab); + } + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } } else { if (scoreboardName != null) { DisguiseUtilities.DScoreTeam team = getScoreboardName(); String[] split = DisguiseUtilities.getExtendedNameSplit(team.getPlayer(), name); - team.setSplit(split); + setScoreboardName(split); } if (name.isEmpty()) { @@ -308,6 +329,7 @@ public class PlayerDisguise extends TargetedDisguise { } } + String oldSkin = skinToUse; skinToUse = newSkin; if (newSkin == null) { @@ -317,6 +339,31 @@ public class PlayerDisguise extends TargetedDisguise { if (newSkin.length() > 16) { skinToUse = newSkin.substring(0, 16); } + + if (newSkin.equals(oldSkin)) { + return this; + } + + if (isDisguiseInUse()) { + currentLookup = new LibsProfileLookup() { + @Override + public void onLookup(WrappedGameProfile gameProfile) { + if (currentLookup != this || gameProfile == null || gameProfile.getProperties().isEmpty()) + return; + + setSkin(gameProfile); + + currentLookup = null; + } + }; + + WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, + LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)); + + if (gameProfile != null) { + setSkin(gameProfile); + } + } } return this; @@ -342,13 +389,15 @@ public class PlayerDisguise extends TargetedDisguise { this.skinToUse = gameProfile.getName(); this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(), gameProfile); + refreshDisguise(); + + return this; + } + + private void refreshDisguise() { if (DisguiseUtilities.isDisguiseInUse(this)) { if (isDisplayedInTab()) { - PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); - addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); - addTab.getPlayerInfoDataLists().write(0, Arrays.asList( - new PlayerInfoData(getGameProfile(), 0, NativeGameMode.SURVIVAL, - WrappedChatComponent.fromText(getProfileName())))); + PacketContainer addTab = DisguiseUtilities.getTabPacket(this, PlayerInfoAction.ADD_PLAYER); PacketContainer deleteTab = addTab.shallowClone(); deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); @@ -369,8 +418,6 @@ public class PlayerDisguise extends TargetedDisguise { DisguiseUtilities.refreshTrackers(this); } - - return this; } @Override diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 3e7765e6..62af9781 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.utilities; +import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType.Play.Server; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; @@ -35,7 +36,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.RandomUtils; import org.apache.logging.log4j.util.Strings; import org.bukkit.*; -import org.bukkit.boss.BossBar; import org.bukkit.boss.KeyedBossBar; import org.bukkit.entity.*; import org.bukkit.inventory.EquipmentSlot; @@ -1943,8 +1943,6 @@ public class DisguiseUtilities { if (transformed.isUnhandled()) transformed.addPacket(packet); - transformed.setSpawnPacketCheck(packet.getType()); - for (PacketContainer p : transformed.getPackets()) { p = p.deepClone(); p.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId()); @@ -1958,6 +1956,17 @@ public class DisguiseUtilities { } } + public static PacketContainer getTabPacket(PlayerDisguise disguise, EnumWrappers.PlayerInfoAction action) { + PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); + + addTab.getPlayerInfoAction().write(0, action); + addTab.getPlayerInfoDataLists().write(0, Collections.singletonList( + new PlayerInfoData(disguise.getGameProfile(), 0, EnumWrappers.NativeGameMode.SURVIVAL, + WrappedChatComponent.fromText(disguise.getName())))); + + return addTab; + } + /** * Setup it so he can see himself when disguised * diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java index 7eb61f83..0f94b225 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/LibsPackets.java @@ -24,13 +24,8 @@ import java.util.*; public class LibsPackets { private ArrayList packets = new ArrayList<>(); private HashMap> delayedPackets = new HashMap<>(); - private boolean isSpawnPacket; private Disguise disguise; private boolean doNothing; - private int removeMetaAt = -1; - @Getter - @Setter - private boolean sendArmor; public LibsPackets(Disguise disguise) { this.disguise = disguise; @@ -40,10 +35,6 @@ public class LibsPackets { doNothing = true; } - public void setRemoveMetaAt(int tick) { - removeMetaAt = tick; - } - public boolean isUnhandled() { return doNothing; } @@ -52,10 +43,6 @@ public class LibsPackets { return disguise; } - public void setSpawnPacketCheck(PacketType type) { - isSpawnPacket = type.name().contains("SPAWN") && type.name().contains("ENTITY"); - } - public void addPacket(PacketContainer packet) { packets.add(packet); } @@ -84,19 +71,8 @@ public class LibsPackets { } public void sendDelayed(final Player observer) { - Iterator>> itel = delayedPackets.entrySet().iterator(); - - while (itel.hasNext()) { - Map.Entry> entry = itel.next(); - // If this is the last delayed packet - final boolean isRemoveCancel = isSpawnPacket && entry.getKey() >= removeMetaAt && removeMetaAt >= 0; - + for (Map.Entry> entry : delayedPackets.entrySet()) { Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> { - - if (isRemoveCancel && "%%__USER__%%".equals("%%__USER__%%") && !"%%__USER__%%".equals("12345")) { - PacketsManager.getPacketsHandler().removeCancel(disguise, observer); - } - if (!disguise.isDisguiseInUse()) { ArrayList packets = entry.getValue(); @@ -107,25 +83,6 @@ public class LibsPackets { packets.removeIf(p -> p.getType() != PacketType.Play.Server.PLAYER_INFO); } - if (isRemoveCancel) { - if (isSendArmor()) { - for (EquipmentSlot slot : EquipmentSlot.values()) { - PacketContainer packet = createPacket(slot); - - if (packet == null) { - continue; - } - - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } - try { for (PacketContainer packet : entry.getValue()) { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java index e11b121f..6daf98ed 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java @@ -19,7 +19,6 @@ import java.util.UUID; * Created by libraryaddict on 3/01/2019. */ public class PacketsHandler { - private HashMap> cancelMeta = new HashMap<>(); private Collection packetHandlers; public PacketsHandler() { @@ -38,7 +37,8 @@ public class PacketsHandler { packetHandlers.add(new PacketHandlerHeadRotation()); // If not prem, if build is from jenkins, else its a custom and needs paid info - if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") || LibsPremium.getPaidInformation() != null) { + if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") || + LibsPremium.getPaidInformation() != null) { packetHandlers.add(new PacketHandlerMetadata(this)); } @@ -47,32 +47,6 @@ public class PacketsHandler { packetHandlers.add(new PacketHandlerVelocity()); } - public boolean isCancelMeta(Disguise disguise, Player observer) { - return cancelMeta.containsKey(disguise) && cancelMeta.get(disguise).contains(observer.getUniqueId()); - } - - public void addCancel(Disguise disguise, Player observer) { - if (!cancelMeta.containsKey(disguise)) { - cancelMeta.put(disguise, new ArrayList()); - } - - cancelMeta.get(disguise).add(observer.getUniqueId()); - } - - public void removeCancel(Disguise disguise, Player observer) { - ArrayList cancel; - - if ((cancel = cancelMeta.get(disguise)) == null) - return; - - cancel.remove(observer.getUniqueId()); - - if (!cancel.isEmpty()) - return; - - cancelMeta.remove(disguise); - } - /** * Transform the packet magically into the one I have always dreamed off. My true luv!!! This will return null if * its not diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java index 17f2b9b6..1f0c93ac 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerEquipment.java @@ -38,17 +38,6 @@ public class PacketHandlerEquipment implements IPacketHandler { @Override public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { - if (DisguiseConfig.isPlayerHideArmor() && packetsHandler.isCancelMeta(disguise, observer)) { - packets.clear(); - - PacketContainer equipPacket = sentPacket.shallowClone(); - - packets.addPacket(equipPacket); - - equipPacket.getModifier().write(2, ReflectionManager.getNmsItem(new ItemStack(Material.AIR))); - return; - } - // Else if the disguise is updating equipment EquipmentSlot slot = ReflectionManager.createEquipmentSlot(packets.getPackets().get(0).getModifier().read(1)); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java index 17446ea7..a5acf743 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerMetadata.java @@ -35,19 +35,22 @@ public class PacketHandlerMetadata implements IPacketHandler { packets.clear(); - if (DisguiseConfig.isMetaPacketsEnabled() && !packetsHandler.isCancelMeta(disguise, observer)) { - List watchableObjects = disguise.getWatcher() - .convert(sentPacket.getWatchableCollectionModifier().read(0)); - - PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); - - packets.addPacket(metaPacket); - - StructureModifier newMods = metaPacket.getModifier(); - - newMods.write(0, entity.getEntityId()); - - metaPacket.getWatchableCollectionModifier().write(0, watchableObjects); + if (!DisguiseConfig.isMetaPacketsEnabled()) { + return; } + + List watchableObjects = disguise.getWatcher() + .convert(sentPacket.getWatchableCollectionModifier().read(0)); + + PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); + + packets.addPacket(metaPacket); + + StructureModifier newMods = metaPacket.getModifier(); + + newMods.write(0, entity.getEntityId()); + + metaPacket.getWatchableCollectionModifier().write(0, watchableObjects); } } + diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index c9a81c61..13c53f54 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -159,7 +159,7 @@ public class PacketHandlerSpawn implements IPacketHandler { WrappedGameProfile spawnProfile = visibleOrNewCompat ? playerDisguise.getGameProfile() : ReflectionManager .getGameProfileWithThisSkin(UUID.randomUUID(), - visibleOrNewCompat ? playerDisguise.getProfileName() : "", playerDisguise.getGameProfile()); + visibleOrNewCompat ? playerDisguise.getName() : "", playerDisguise.getGameProfile()); int entityId = disguisedEntity.getEntityId(); @@ -182,7 +182,7 @@ public class PacketHandlerSpawn implements IPacketHandler { if (LibsPremium.getPaidInformation() == null || LibsPremium.getPaidInformation().getBuildNumber().matches("#[0-9]+")) { - packets.addDelayedPacket(deleteTab, DisguiseConfig.getPlayerDisguisesTablistExpires()); + packets.addDelayedPacket(deleteTab, 2); } } @@ -196,18 +196,9 @@ public class PacketHandlerSpawn implements IPacketHandler { boolean selfDisguise = observer == disguisedEntity; - WrappedDataWatcher newWatcher; - - if (selfDisguise) { - newWatcher = DisguiseUtilities - .createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), - disguise.getWatcher()); - } else { - newWatcher = new WrappedDataWatcher(); - - spawnAt = observer.getLocation(); - spawnAt.add(spawnAt.getDirection().normalize().multiply(20)); - } + WrappedDataWatcher newWatcher = DisguiseUtilities + .createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), + disguise.getWatcher()); // Spawn him in front of the observer StructureModifier doubles = spawnPlayer.getDoubles(); @@ -219,10 +210,6 @@ public class PacketHandlerSpawn implements IPacketHandler { bytes.write(0, yaw); bytes.write(1, pitch); - // Make him invisible - newWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(MetaIndex.ENTITY_META.getIndex(), - WrappedDataWatcher.Registry.get(Byte.class)), (byte) 32); - packets.addPacket(spawnPlayer); if (NmsVersion.v1_15.isSupported()) { @@ -234,41 +221,6 @@ public class PacketHandlerSpawn implements IPacketHandler { } else { spawnPlayer.getDataWatcherModifier().write(0, newWatcher); } - - if (!selfDisguise) { - // Teleport the player back to where he's supposed to be - PacketContainer teleportPacket = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT); - - doubles = teleportPacket.getDoubles(); - - teleportPacket.getIntegers().write(0, entityId); // Id - doubles.write(0, loc.getX()); - doubles.write(1, loc.getY()); - doubles.write(2, loc.getZ()); - - bytes = teleportPacket.getBytes(); - bytes.write(0, yaw); - bytes.write(1, pitch); - - packets.addDelayedPacket(teleportPacket, 3); - - // Send a metadata packet - PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); - - newWatcher = DisguiseUtilities - .createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), - disguise.getWatcher()); - - metaPacket.getIntegers().write(0, entityId); // Id - metaPacket.getWatchableCollectionModifier().write(0, newWatcher.getWatchableObjects()); - - packetsHandler.addCancel(disguise, observer); - - // Add a delay to remove the entry from 'cancelMeta' - - packets.addDelayedPacket(metaPacket, 7); - packets.setRemoveMetaAt(7); - } } else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) { Vector vec = disguisedEntity.getVelocity(); @@ -420,37 +372,24 @@ public class PacketHandlerSpawn implements IPacketHandler { } // If armor must be sent because its currently not displayed and would've been sent normally - boolean delayedArmor = - DisguiseConfig.isPlayerHideArmor() && (disguise.isPlayerDisguise() && disguisedEntity != observer) && - disguisedEntity instanceof LivingEntity; - if (delayedArmor) { - packets.setSendArmor(true); - packets.setRemoveMetaAt(7); - } // This sends the armor packets so that the player isn't naked. - if (DisguiseConfig.isEquipmentPacketsEnabled() || delayedArmor) { + if (DisguiseConfig.isEquipmentPacketsEnabled()) { for (EquipmentSlot slot : EquipmentSlot.values()) { // Get what the disguise wants to show for its armor - ItemStack itemToSend; + ItemStack itemToSend = disguise.getWatcher().getItemStack(slot); - if (delayedArmor) { - itemToSend = new ItemStack(Material.AIR); - } else { - itemToSend = disguise.getWatcher().getItemStack(slot); + // If the disguise armor isn't visible + if (itemToSend == null) { + itemToSend = ReflectionManager.getEquipment(slot, disguisedEntity); - // If the disguise armor isn't visible - if (itemToSend == null) { - itemToSend = ReflectionManager.getEquipment(slot, disguisedEntity); - - // If natural armor isn't sent either - if (itemToSend == null || itemToSend.getType() == Material.AIR) { - continue; - } - } else if (itemToSend.getType() == Material.AIR) { - // Its air which shouldn't be sent + // If natural armor isn't sent either + if (itemToSend == null || itemToSend.getType() == Material.AIR) { continue; } + } else if (itemToSend.getType() == Material.AIR) { + // Its air which shouldn't be sent + continue; } PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java index 0855bf2b..82ed08ff 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerMain.java @@ -61,8 +61,6 @@ public class PacketListenerMain extends PacketAdapter { return; } - packets.setSpawnPacketCheck(event.getPacketType()); - event.setCancelled(true); try { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java index 64ffb58d..10abb43c 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java @@ -77,8 +77,6 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { transformed.getPackets().add(packet); } - transformed.setSpawnPacketCheck(event.getPacketType()); - for (PacketContainer newPacket : transformed.getPackets()) { if (newPacket.getType() != Server.PLAYER_INFO) { if (newPacket == packet) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0429e196..77d9a8de 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -253,11 +253,9 @@ HideDisguisedPlayersFromTab: false ShowPlayerDisguisesInTab: false # On player disguise, a fake player is added to tablist so the skin can load properly. -# If the viewer sees the player disguise but there's no tablist name, they won't see a skin. -# 3 seconds is normally long enough to load the skin properly, but sometimes the server needs longer -# This is in ticks, there are 20 ticks in every second. 60 ticks = 3 seconds. 200 ticks = 10 seconds. # This option is ignored if 'ShowPlayerDisguisesInTab' is enabled. -PlayerDisguisesTablistExpires: 60 +# 2 ticks should easily be enough. +PlayerDisguisesTablistExpires: 2 # Don't like players able to set themselves invisible when using the disguise commands? Toggle this to true and no one can use setInvisible! Plugins can still use this however. DisableInvisibility: false