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 de975f900..6d901e74e 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 @@ -132,20 +132,33 @@ public class PlayerPackets { String[] players = wrapper.read(Type.STRING_ARRAY); // Players final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); String myName = wrapper.user().get(ProtocolInfo.class).getUsername(); + String teamName = wrapper.get(Type.STRING, 0); for (String player : players) { if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) { if (mode == 4) { // since removing add to auto team entityTracker.sendTeamPacket(true, false); - + entityTracker.setCurrentTeam("viaversion"); } else { // since adding remove from auto team entityTracker.sendTeamPacket(false, true); + entityTracker.setCurrentTeam(teamName); } } } wrapper.write(Type.STRING_ARRAY, players); } + + if (mode == 1) { // Remove team + final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); + String teamName = wrapper.get(Type.STRING, 0); + if (entityTracker.isAutoTeam() + && teamName.equals(entityTracker.getCurrentTeam())) { + // team was removed + entityTracker.sendTeamPacket(true, false); + entityTracker.setCurrentTeam("viaversion"); + } + } } }); } @@ -190,6 +203,19 @@ public class PlayerPackets { } } ); + + // Scoreboard will be cleared when join game is received + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + if (Via.getConfig().isAutoTeam()) { + EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); + entityTracker.setAutoTeam(true); + entityTracker.sendTeamPacket(true, false); + entityTracker.setCurrentTeam("viaversion"); + } + } + }); } }); 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 1d1a284db..5e45bdade 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 @@ -211,23 +211,6 @@ public class WorldPackets { } }); - // Server Difficulty Packet - protocol.registerOutgoing(State.PLAY, 0x41, 0x0D, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - if (Via.getConfig().isAutoTeam()) { - EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); - entityTracker.setAutoTeam(true); - entityTracker.sendTeamPacket(true, true); - } - } - }); - } - }); - // Block Change Packet protocol.registerOutgoing(State.PLAY, 0x23, 0x0B, new PacketRemapper() { @Override @@ -240,6 +223,7 @@ public class WorldPackets { protocol.registerOutgoing(State.PLAY, 0x25, 0x08); // Block Break Animation Packet protocol.registerOutgoing(State.PLAY, 0x24, 0x0A); // Block Action Packet + protocol.registerOutgoing(State.PLAY, 0x41, 0x0D); // Server Difficulty Packet protocol.registerOutgoing(State.PLAY, 0x22, 0x10); // Multi Block Change Packet protocol.registerOutgoing(State.PLAY, 0x27, 0x1C); // Explosion Packet protocol.registerOutgoing(State.PLAY, 0x2A, 0x22); // Particle Packet 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 9a9dce713..212bae1e2 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 @@ -53,6 +53,8 @@ public class EntityTracker extends StoredObject { private GameMode gameMode; @Setter private int mainHand; + @Setter + private String currentTeam; public EntityTracker(UserConnection user) { super(user);