From 6cf9be128dafc7261ab2f15e97cf2191d3619dbb Mon Sep 17 00:00:00 2001 From: Timongcraft Date: Sun, 27 Oct 2024 21:38:03 +0100 Subject: [PATCH] fix: address comment (from github) --- .../velocitypowered/proxy/tablist/VelocityTabList.java | 6 ++++++ .../proxy/tablist/VelocityTabListEntry.java | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java index a2cc1955c..115261a71 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java @@ -19,6 +19,7 @@ package com.velocitypowered.proxy.tablist; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; +import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.player.ChatSession; import com.velocitypowered.api.proxy.player.TabListEntry; @@ -128,6 +129,11 @@ public class VelocityTabList implements InternalTabList { actions.add(UpsertPlayerInfoPacket.Action.UPDATE_LISTED); playerInfoEntry.setListed(entry.isListed()); } + if (!Objects.equals(previousEntry.getListOrder(), entry.getListOrder()) + && player.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_21_2)) { + actions.add(UpsertPlayerInfoPacket.Action.UPDATE_LIST_ORDER); + playerInfoEntry.setListOrder(entry.getListOrder()); + } if (!Objects.equals(previousEntry.getChatSession(), entry.getChatSession())) { ChatSession from = entry.getChatSession(); if (from != null) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java index 182825538..352d62716 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java @@ -17,6 +17,7 @@ package com.velocitypowered.proxy.tablist; +import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.player.ChatSession; import com.velocitypowered.api.proxy.player.TabList; import com.velocitypowered.api.proxy.player.TabListEntry; @@ -161,9 +162,11 @@ public class VelocityTabListEntry implements TabListEntry { @Override public VelocityTabListEntry setListOrder(int listOrder) { this.listOrder = listOrder; - UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this); - upsertEntry.setListOrder(listOrder); - this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_LIST_ORDER, upsertEntry); + if (tabList.getPlayer().getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_21_2)) { + UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this); + upsertEntry.setListOrder(listOrder); + tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_LIST_ORDER, upsertEntry); + } return this; }