Dont delay a teleportion

This commit is contained in:
libraryaddict 2020-10-16 19:34:37 +13:00
parent bae41272dd
commit a39ca29aef

View File

@ -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(); PlayerDisguise disguise = skin.getDisguise().get();
Entity entity = disguise.getEntity(); Entity entity = disguise.getEntity();
WrappedDataWatcher watcher = DisguiseUtilities WrappedDataWatcher watcher = DisguiseUtilities
@ -241,10 +241,11 @@ public class PlayerSkinHandler implements Listener {
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true) .createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true)
.createPacket(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(); PlayerDisguise disguise = skin.getDisguise().get();
PacketContainer teleport = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT); PacketContainer teleport = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
@ -284,7 +285,7 @@ public class PlayerSkinHandler implements Listener {
mods.write(4, yaw); mods.write(4, yaw);
mods.write(5, pitch); 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) { private void doPacketRemoval(Player player, PlayerSkin skin) {
@ -294,11 +295,6 @@ public class PlayerSkinHandler implements Listener {
return; return;
} }
if (skin.isSleepPackets()) {
addTeleport(player, skin);
addMetadata(player, skin);
}
try { try {
for (Map.Entry<Integer, ArrayList<PacketContainer>> entry : skin.getSleptPackets().entrySet()) { for (Map.Entry<Integer, ArrayList<PacketContainer>> entry : skin.getSleptPackets().entrySet()) {
if (entry.getKey() == 0) { 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()) { if (skin.isDoTabList()) {
PacketContainer packetContainer = PacketContainer packetContainer =
DisguiseUtilities.getTabPacket(disguise, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER); DisguiseUtilities.getTabPacket(disguise, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);