Skip to content

Commit

Permalink
fix: address comment (from github)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timongcraft committed Oct 27, 2024
1 parent ab60261 commit 6cf9be1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

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;
Expand Down Expand Up @@ -128,6 +129,11 @@ public void addEntry(TabListEntry entry1) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -161,9 +162,11 @@ public int getListOrder() {
@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;
}

Expand Down

0 comments on commit 6cf9be1

Please sign in to comment.