diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeServerHandler.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeServerHandler.java index 8383e73ca..3740c9e16 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeServerHandler.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeServerHandler.java @@ -22,6 +22,7 @@ import us.myles.ViaVersion.bungee.storage.BungeeStorage; import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -95,6 +96,7 @@ public class BungeeServerHandler implements Listener { if (e.getServer() != null) { if (!e.getServer().getInfo().getName().equals(storage.getCurrentServer())) { + EntityTracker oldEntityTracker = user.get(EntityTracker.class); String serverName = e.getServer().getInfo().getName(); storage.setCurrentServer(serverName); @@ -174,6 +176,12 @@ public class BungeeServerHandler implements Listener { protocol.init(user); } + EntityTracker newTracker = user.get(EntityTracker.class); + if (newTracker != null && oldEntityTracker != null) { + newTracker.setAutoTeam(oldEntityTracker.isAutoTeam()); + newTracker.setCurrentTeam(oldEntityTracker.getCurrentTeam()); + } + Object wrapper = channelWrapper.get(player); setVersion.invoke(wrapper, protocolId); 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 37f9439f5..b5135ba07 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 @@ -137,7 +137,9 @@ public class PlayerPackets { if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) { if (mode == 4) { // since removing add to auto team - entityTracker.sendTeamPacket(true, false); + wrapper.send(Protocol1_9TO1_8.class, true, true); + wrapper.cancel(); + entityTracker.sendTeamPacket(true, true); entityTracker.setCurrentTeam("viaversion"); } else { // since adding remove from auto team @@ -155,7 +157,9 @@ public class PlayerPackets { if (entityTracker.isAutoTeam() && teamName.equals(entityTracker.getCurrentTeam())) { // team was removed - entityTracker.sendTeamPacket(true, false); + wrapper.send(Protocol1_9TO1_8.class, true, true); + wrapper.cancel(); + entityTracker.sendTeamPacket(true, true); entityTracker.setCurrentTeam("viaversion"); } } @@ -211,7 +215,9 @@ public class PlayerPackets { EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); if (Via.getConfig().isAutoTeam()) { entityTracker.setAutoTeam(true); - entityTracker.sendTeamPacket(true, false); + wrapper.send(Protocol1_9TO1_8.class, true, true); + wrapper.cancel(); + entityTracker.sendTeamPacket(true, true); entityTracker.setCurrentTeam("viaversion"); } else { entityTracker.setAutoTeam(false);