From 6e4ceb37a96cec26b22083e23accca623ac56233 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 31 Aug 2020 10:02:50 +1200 Subject: [PATCH] Fix error for self disguises refreshing or something --- .../PacketListenerViewSelfDisguise.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) 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 e73a68f1..ee39ad73 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 @@ -34,8 +34,9 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { @Override public void onPacketSending(final PacketEvent event) { - if (event.isCancelled()) + if (event.isCancelled()) { return; + } try { final Player observer = event.getPlayer(); @@ -70,15 +71,15 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { } // Here I grab the packets to convert them to, So I can display them as if the disguise sent them. - LibsPackets transformed = PacketsManager.getPacketsHandler() - .transformPacket(packet, disguise, observer, observer); + LibsPackets transformed = + PacketsManager.getPacketsHandler().transformPacket(packet, disguise, observer, observer); if (transformed.isUnhandled()) { transformed.getPackets().add(packet); } for (PacketContainer newPacket : transformed.getPackets()) { - if (newPacket.getType() != Server.PLAYER_INFO && + if (newPacket.getType() != Server.PLAYER_INFO && newPacket.getType() != Server.ENTITY_DESTROY && newPacket.getIntegers().read(0) == observer.getEntityId()) { if (newPacket == packet) { newPacket = newPacket.shallowClone(); @@ -89,15 +90,14 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { try { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, newPacket, false); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { e.printStackTrace(); } } for (ArrayList packets : transformed.getDelayedPackets()) { for (PacketContainer newPacket : packets) { - if (newPacket.getType() == Server.PLAYER_INFO) { + if (newPacket.getType() == Server.PLAYER_INFO || newPacket.getType() == Server.ENTITY_DESTROY) { continue; } @@ -139,20 +139,21 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { List watchableList = new ArrayList<>(); byte b = 1 << 5; - if (observer.isSprinting()) + if (observer.isSprinting()) { b = (byte) (b | 1 << 3); + } WrappedWatchableObject watch = ReflectionManager.createWatchable(MetaIndex.ENTITY_META, b); - if (watch != null) + if (watch != null) { watchableList.add(watch); + } metaPacket.getWatchableCollectionModifier().write(0, watchableList); try { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, metaPacket); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { e.printStackTrace(); } } else if (event.getPacketType() == Server.ANIMATION) { @@ -179,8 +180,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { // Clear old velocity, this should only occur once. DisguiseUtilities.setPlayerVelocity(null); } - } - catch (Throwable ex) { + } catch (Throwable ex) { event.setCancelled(true); ex.printStackTrace(); }