workaround packet order for team packets

This commit is contained in:
creeper123123321 2019-02-23 13:44:41 -03:00
parent b26d2ef906
commit d962ef09ff
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
2 changed files with 17 additions and 3 deletions

View File

@ -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);

View File

@ -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);