13
0
geforkt von Mirrors/Velocity

Do tab list clearing into one packet

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-30 18:27:07 -04:00
Ursprung 49b09713f8
Commit b6a9299f9f
2 geänderte Dateien mit 12 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -240,11 +240,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
player.getConnection().setCanSendLegacyFMLResetPacket(true);
} else {
// Clear tab list to avoid duplicate entries
TabList tabList = player.getTabList();
tabList.getEntries().forEach(entry -> tabList.removeEntry(entry.getProfile().idAsUuid()));
player.getTabList().clearAll();
// Ah, this is the meat and potatoes of the whole venture!
//
// In order to handle switching to another server, you will need to send three packets:
//
// - The join game packet from the backend server
@ -271,7 +268,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
serverBossBars.clear();
// Tell the server about this client's plugin messages. Velocity will forward them on to the client.
// Tell the server about this client's plugin message channels.
Collection<String> toRegister = new HashSet<>(clientPluginMsgChannels);
if (player.getProtocolVersion() >= ProtocolConstants.MINECRAFT_1_13) {
toRegister.addAll(server.getChannelRegistrar().getModernChannelIds());

Datei anzeigen

@ -10,12 +10,7 @@ import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
import net.kyori.text.Component;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class VelocityTabList implements TabList {
@ -60,6 +55,15 @@ public class VelocityTabList implements TabList {
return Optional.ofNullable(entry);
}
public void clearAll() { // Note: this method is called upon server switch
List<PlayerListItem.Item> items = new ArrayList<>();
for (TabListEntry value : entries.values()) {
items.add(PlayerListItem.Item.from(value));
}
entries.clear();
connection.delayedWrite(new PlayerListItem(PlayerListItem.Action.REMOVE_PLAYER, items));
}
@Override
public Collection<TabListEntry> getEntries() {
return Collections.unmodifiableCollection(this.entries.values());