Fix RPlayer skin data

This commit is contained in:
2025-06-28 14:14:55 +02:00
parent d06faa5d18
commit 1bb15d9551
2 changed files with 11 additions and 6 deletions
@@ -40,7 +40,6 @@ import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
@Getter
public class RPlayer extends REntity {
private static int skinPartsIndex() {
@@ -65,7 +64,9 @@ public class RPlayer extends REntity {
private static final Object skinPartsDataWatcher = BountifulWrapper.impl.getDataWatcherObject(skinPartsIndex(), Byte.class);
@Getter
private final UUID actualUUID;
@Getter
private final String name;
public RPlayer(REntityServer server, UUID uuid, String name, Location location) {
@@ -76,8 +77,8 @@ public class RPlayer extends REntity {
}
private GameProfile getGameProfile() {
Property skinData = CoreNetworkHandler.SKIN_DATA_PROMISES.computeIfAbsent(uuid, __ -> {
NetworkSender.sendOrQueue(new PlayerSkinRequestPacket(uuid));
Property skinData = CoreNetworkHandler.SKIN_DATA_PROMISES.computeIfAbsent(actualUUID, __ -> {
NetworkSender.sendOrQueue(new PlayerSkinRequestPacket(actualUUID));
return new Property("textures", null, null);
});
if (skinData.getValue() != null) {
@@ -89,9 +90,12 @@ public class RPlayer extends REntity {
}
}
private GameProfile saved;
@Override
void list(Consumer<Object> packetSink) {
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, getGameProfile(), GameMode.CREATIVE));
saved = getGameProfile();
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, saved, GameMode.CREATIVE));
}
@Override
@@ -108,7 +112,8 @@ public class RPlayer extends REntity {
@Override
void delist(Consumer<Object> packetSink) {
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, getGameProfile(), GameMode.CREATIVE));
if (saved == null) saved = getGameProfile();
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, saved, GameMode.CREATIVE));
}
private static final Class<?> namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket");
@@ -44,7 +44,7 @@ public class NetworkSender implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (!Bukkit.getOnlinePlayers().isEmpty()) {
if (Bukkit.getOnlinePlayers().size() > 1) {
return;
}
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {