Skip to content

Commit e726b91

Browse files
committed
Fix: "Invalid skin length" issue, code-of-conduct screen not appearing correctly on server switching, InputMode / UiProfile not being read correctly
Fixes #5995, fixes #5994
1 parent 473a4a5 commit e726b91

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

core/src/main/java/org/geysermc/geyser/session/GeyserSession.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
747747
private boolean allowVibrantVisuals = true;
748748

749749
@Accessors(fluent = true)
750+
@Setter
750751
private boolean hasAcceptedCodeOfConduct = false;
751752

752753
@Accessors(fluent = true)

core/src/main/java/org/geysermc/geyser/session/auth/BedrockClientData.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.io.IOException;
4747
import java.lang.reflect.Type;
4848
import java.nio.charset.StandardCharsets;
49+
import java.util.Base64;
4950
import java.util.UUID;
5051

5152
@Getter
@@ -62,7 +63,8 @@ public final class BedrockClientData {
6263
@SerializedName(value = "SkinId")
6364
private String skinId;
6465
@SerializedName(value = "SkinData")
65-
private String skinData;
66+
@JsonAdapter(value = StringToByteDeserializer.class)
67+
private byte[] skinData;
6668
@SerializedName(value = "SkinImageHeight")
6769
private int skinImageHeight;
6870
@SerializedName(value = "SkinImageWidth")
@@ -79,9 +81,11 @@ public final class BedrockClientData {
7981
@SerializedName(value = "CapeOnClassicSkin")
8082
private boolean capeOnClassicSkin;
8183
@SerializedName(value = "SkinResourcePatch")
82-
private String geometryName;
84+
@JsonAdapter(value = StringToByteDeserializer.class)
85+
private byte[] geometryName;
8386
@SerializedName(value = "SkinGeometryData")
84-
private String geometryData;
87+
@JsonAdapter(value = StringToByteDeserializer.class)
88+
private byte[] geometryData;
8589
@SerializedName(value = "PersonaSkin")
8690
private boolean personaSkin;
8791
@SerializedName(value = "PremiumSkin")
@@ -95,12 +99,15 @@ public final class BedrockClientData {
9599
@JsonAdapter(value = IntToEnumTypeFactory.class)
96100
private DeviceOs deviceOs;
97101
@SerializedName(value = "UIProfile")
102+
@JsonAdapter(value = IntToEnumTypeFactory.class)
98103
private UiProfile uiProfile;
99104
@SerializedName(value = "GuiScale")
100105
private int guiScale;
101106
@SerializedName(value = "CurrentInputMode")
107+
@JsonAdapter(value = IntToEnumTypeFactory.class)
102108
private InputMode currentInputMode;
103109
@SerializedName(value = "DefaultInputMode")
110+
@JsonAdapter(value = IntToEnumTypeFactory.class)
104111
private InputMode defaultInputMode;
105112
@SerializedName("PlatformOnlineId")
106113
private String platformOnlineId;
@@ -144,7 +151,7 @@ public UiProfile getUiProfile() {
144151
private static final class StringToByteDeserializer implements JsonDeserializer<byte[]> {
145152
@Override
146153
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
147-
return json.getAsString().getBytes(StandardCharsets.UTF_8);
154+
return Base64.getDecoder().decode(json.getAsString().getBytes(StandardCharsets.UTF_8));
148155
}
149156
}
150157

core/src/main/java/org/geysermc/geyser/skin/SkinManager.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import com.google.common.cache.CacheBuilder;
3030
import com.google.gson.JsonObject;
3131
import com.google.gson.JsonPrimitive;
32-
import com.google.common.cache.Cache;
33-
import com.google.common.cache.CacheBuilder;
3432
import org.checkerframework.checker.nullness.qual.Nullable;
3533
import org.cloudburstmc.nbt.NbtMap;
3634
import org.cloudburstmc.nbt.NbtType;
@@ -312,11 +310,11 @@ public static void handleBedrockSkin(AvatarEntity playerEntity, BedrockClientDat
312310
}
313311

314312
try {
315-
byte[] skinBytes = Base64.getDecoder().decode(clientData.getSkinData().getBytes(StandardCharsets.UTF_8));
313+
byte[] skinBytes = clientData.getSkinData();
316314
byte[] capeBytes = clientData.getCapeData();
317315

318-
byte[] geometryNameBytes = Base64.getDecoder().decode(clientData.getGeometryName().getBytes(StandardCharsets.UTF_8));
319-
byte[] geometryBytes = Base64.getDecoder().decode(clientData.getGeometryData().getBytes(StandardCharsets.UTF_8));
316+
byte[] geometryNameBytes = clientData.getGeometryName();
317+
byte[] geometryBytes = clientData.getGeometryData();
320318

321319
if (skinBytes.length <= (128 * 128 * 4) && !clientData.isPersonaSkin()) {
322320
SkinProvider.storeBedrockSkin(playerEntity.getUuid(), clientData.getSkinId(), skinBytes);

core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginFinishedTranslator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public void translate(GeyserSession session, ClientboundLoginFinishedPacket pack
7474
session.setToken(null);
7575
session.getClientData().setOriginalString(null);
7676

77+
// Reset code of conduct accepted state, mirrors Java Edition
78+
session.hasAcceptedCodeOfConduct(false);
79+
7780
// configuration phase stuff that the vanilla client replies with after receiving the GameProfilePacket
7881
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket(Key.key("brand"), PluginMessageUtils.getGeyserBrandData()), ProtocolState.CONFIGURATION);
7982
session.sendJavaClientSettings();

core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaStartConfigurationTranslator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public void translate(GeyserSession session, ClientboundStartConfigurationPacket
4444
erosionHandler.close();
4545
}
4646

47+
// Reset code of conduct being accepted
48+
session.hasAcceptedCodeOfConduct(false);
49+
4750
ChunkUtils.sendEmptyChunks(session, session.getPlayerEntity().position().toInt(), session.getServerRenderDistance(), false);
4851
}
4952
}

0 commit comments

Comments
 (0)