From 4d58c717cd456c3c69ec04237dc061dfe63b0f23 Mon Sep 17 00:00:00 2001 From: Myles Date: Thu, 29 Jun 2017 20:04:40 +0100 Subject: [PATCH] Fix auto-team not sending in the right order, #699 --- .../protocol1_9to1_8/packets/PlayerPackets.java | 10 +++------- .../protocol1_9to1_8/packets/WorldPackets.java | 2 +- .../protocol1_9to1_8/storage/EntityTracker.java | 8 ++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java index e8dcc46ad..0a0c03758 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java @@ -136,15 +136,11 @@ public class PlayerPackets { if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) { if (mode == 4) { // since removing add to auto team - Via.getPlatform().runSync(new Runnable() { - @Override - public void run() { - entityTracker.sendTeamPacket(true); - } - }); + entityTracker.sendTeamPacket(true, false); + } else { // since adding remove from auto team - entityTracker.sendTeamPacket(false); + entityTracker.sendTeamPacket(false, true); } } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index 826eee605..37670ed9b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -217,7 +217,7 @@ public class WorldPackets { if (Via.getConfig().isAutoTeam()) { EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); entityTracker.setAutoTeam(true); - entityTracker.sendTeamPacket(true); + entityTracker.sendTeamPacket(true, true); } } }); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java index d8f952987..2824a0a72 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java @@ -241,10 +241,10 @@ public class EntityTracker extends StoredObject { return null; } - public void sendTeamPacket(boolean b) { + public void sendTeamPacket(boolean add, boolean now) { PacketWrapper wrapper = new PacketWrapper(0x41, null, getUser()); wrapper.write(Type.STRING, "viaversion"); // Use viaversion as name - if (b) { + if (add) { // add if (!teamExists) { wrapper.write(Type.BYTE, (byte) 0); // make team @@ -263,9 +263,9 @@ public class EntityTracker extends StoredObject { } else { wrapper.write(Type.BYTE, (byte) 1); // remove team } - teamExists = b; + teamExists = add; try { - wrapper.send(Protocol1_9TO1_8.class); + wrapper.send(Protocol1_9TO1_8.class, true, now); } catch (Exception e) { e.printStackTrace(); }