Update WebUpdatePlayerList to fetch and apply player skin textures for fake players.

This commit is contained in:
2026-08-26 18:27:11 +02:00
parent 79ded52842
commit d3aa424261
@@ -9,10 +9,8 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.*;
import com.destroystokyo.paper.profile.PlayerProfile;
import lombok.extern.slf4j.Slf4j;
import me.neznamy.tab.api.TabAPI;
import me.neznamy.tab.api.TabPlayer;
@@ -21,6 +19,8 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jspecify.annotations.NonNull;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
@Slf4j
@@ -141,6 +141,31 @@ public final class WebUpdatePlayerList implements WebHandler<PlayerListState> {
fakePlayer.name()
);
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(fakePlayer.uuid());
PlayerProfile playerProfile = offlinePlayer.getPlayerProfile();
URL skinUrl = playerProfile.getTextures().getSkin();
if (skinUrl != null) {
String textureJson = """
{
"textures": {
"SKIN": {
"url": "%s"
}
}
}
""".formatted(skinUrl);
String textureValue = Base64.getEncoder()
.encodeToString(textureJson.getBytes(StandardCharsets.UTF_8));
profile.getProperties().put(
"textures",
new WrappedSignedProperty("textures", textureValue, null)
);
}
PlayerInfoData data = new PlayerInfoData(
fakePlayer.uuid(),
0,