From a39ca29aef8dc23e35f4f09a9baf620041f3e06a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 16 Oct 2020 19:34:37 +1300 Subject: [PATCH] Dont delay a teleportion --- .../listeners/PlayerSkinHandler.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java index a5fe0ed3..6f8e1146 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PlayerSkinHandler.java @@ -231,7 +231,7 @@ public class PlayerSkinHandler implements Listener { } } - private void addMetadata(Player player, PlayerSkin skin) { + private void addMetadata(Player player, PlayerSkin skin) throws InvocationTargetException { PlayerDisguise disguise = skin.getDisguise().get(); Entity entity = disguise.getEntity(); WrappedDataWatcher watcher = DisguiseUtilities @@ -241,10 +241,11 @@ public class PlayerSkinHandler implements Listener { .createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true) .createPacket(entity.getEntityId(), watcher, true); - skin.getSleptPackets().computeIfAbsent(4, (a) -> new ArrayList<>()).add(metaPacket); + ProtocolLibrary.getProtocolManager().sendServerPacket(player, metaPacket, false); + } - private void addTeleport(Player player, PlayerSkin skin) { + private void addTeleport(Player player, PlayerSkin skin) throws InvocationTargetException { PlayerDisguise disguise = skin.getDisguise().get(); PacketContainer teleport = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT); @@ -284,7 +285,7 @@ public class PlayerSkinHandler implements Listener { mods.write(4, yaw); mods.write(5, pitch); - skin.getSleptPackets().computeIfAbsent(0, (a) -> new ArrayList<>()).add(teleport); + ProtocolLibrary.getProtocolManager().sendServerPacket(player, teleport, false); } private void doPacketRemoval(Player player, PlayerSkin skin) { @@ -294,11 +295,6 @@ public class PlayerSkinHandler implements Listener { return; } - if (skin.isSleepPackets()) { - addTeleport(player, skin); - addMetadata(player, skin); - } - try { for (Map.Entry> entry : skin.getSleptPackets().entrySet()) { if (entry.getKey() == 0) { @@ -325,6 +321,11 @@ public class PlayerSkinHandler implements Listener { } } + if (skin.isSleepPackets()) { + addTeleport(player, skin); + addMetadata(player, skin); + } + if (skin.isDoTabList()) { PacketContainer packetContainer = DisguiseUtilities.getTabPacket(disguise, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);