diff --git a/connector/src/main/java/org/geysermc/connector/utils/ProvidedSkin.java b/connector/src/main/java/org/geysermc/connector/utils/ProvidedSkin.java index 007a9557..71bf2984 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ProvidedSkin.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ProvidedSkin.java @@ -3,6 +3,7 @@ package org.geysermc.connector.utils; import lombok.Getter; import javax.imageio.ImageIO; +import java.awt.Color; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -18,11 +19,11 @@ public class ProvidedSkin { try { for (int y = 0; y < image.getHeight(); y++) { for (int x = 0; x < image.getWidth(); x++) { - int rgba = image.getRGB(x, y); - outputStream.write((rgba >> 16) & 0xFF); - outputStream.write((rgba >> 8) & 0xFF); - outputStream.write(rgba & 0xFF); - outputStream.write((rgba >> 24) & 0xFF); + Color color = new Color(image.getRGB(x, y), true); + outputStream.write(color.getRed()); + outputStream.write(color.getGreen()); + outputStream.write(color.getBlue()); + outputStream.write(color.getAlpha()); } } image.flush(); diff --git a/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java b/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java index 08b9ed1f..988501b8 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java @@ -13,6 +13,7 @@ import org.geysermc.connector.entity.PlayerEntity; import org.geysermc.connector.network.session.GeyserSession; import java.util.Base64; +import java.util.Collections; import java.util.UUID; import java.util.function.Consumer; @@ -48,7 +49,16 @@ public class SkinUtils { public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId, String skinId, byte[] skinData, byte[] capeData, String geometryName, String geometryData) { - SerializedSkin serializedSkin = SerializedSkin.of(skinId, ImageData.of(64, 64, skinData), ImageData.of(64, 32, capeData), geometryName, geometryData, true); + if (skinData == null || skinData.length == 0) { + skinData = SkinProvider.EMPTY_SKIN.getSkinData(); + } + + if (capeData == null || capeData.length == 0) { + capeData = SkinProvider.EMPTY_CAPE.getCapeData(); + } + + SerializedSkin serializedSkin = SerializedSkin.of(skinId, geometryName, ImageData.of(64, 64, skinData), + Collections.emptyList(), ImageData.of(64, 32, capeData), geometryData, "", true, false, false, "", ""); PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid); entry.setName(username);