3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-23 23:00:35 +01:00

Clear tab list on server connect

Dieser Commit ist enthalten in:
Desetude 2018-09-30 21:40:22 +01:00
Ursprung 61bd178591
Commit 3e65000ab3
2 geänderte Dateien mit 7 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@ import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.PlayerChatEvent;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.player.TabList;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.connection.VelocityConstants;
@ -238,6 +239,10 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
// The call will handle if the player is not a Forge player appropriately.
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()));
// 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:

Datei anzeigen

@ -16,10 +16,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class VelocityTabList implements TabList {
private final MinecraftConnection connection;
private final Map<UUID, TabListEntry> entries = new HashMap<>();
private final Map<UUID, TabListEntry> entries = new ConcurrentHashMap<>();
public VelocityTabList(MinecraftConnection connection) {
this.connection = connection;