From 2c74177492d06babc1dbc384606642f3cd2a7cd9 Mon Sep 17 00:00:00 2001 From: Niek Vincent Date: Mon, 23 Oct 2023 00:00:41 +0200 Subject: [PATCH 1/3] Add DeviceOS and UIProfile enums Add additional enums for the Device Operating System and UI Profile that are part of the extra LoginPacket data --- .../bedrock/data/OperatingSystem.java | 26 +++++++++++++++++++ .../bedrock/data/UserInterfaceType.java | 13 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/OperatingSystem.java create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/OperatingSystem.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/OperatingSystem.java new file mode 100644 index 000000000..58bc4a790 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/OperatingSystem.java @@ -0,0 +1,26 @@ +package org.cloudburstmc.protocol.bedrock.data; + +public enum OperatingSystem { + + UNDEFINED, + ANDROID, + IOS, + OSX, + AMAZON, + GEAR_VR, + HOLOLENS, + UWP, + WIN_32, + DEDICATED, + APPLE_TV, + PLAYSTATION, + NINTENDO_SWITCH, + XBOX, + WINDOWS_PHONE; + + private static final OperatingSystem[] VALUES = values(); + + public static OperatingSystem from(int id) { + return id < VALUES.length ? VALUES[id] : VALUES[0]; + } +} diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java new file mode 100644 index 000000000..66778a225 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java @@ -0,0 +1,13 @@ +package org.cloudburstmc.protocol.bedrock.data; + +public enum UserInterfaceType { + + CLASSIC, + POCKET; + + private static final UserInterfaceType[] VALUES = values(); + + public static UserInterfaceType from(int id) { + return VALUES[id]; + } +} From 1288f489301affe63f7b5b8d15893cbd390f0e2d Mon Sep 17 00:00:00 2001 From: Niek Vincent Date: Mon, 23 Oct 2023 16:41:42 +0200 Subject: [PATCH 2/3] Renamed enum classes --- .../{OperatingSystem.java => BuildPlatform.java} | 6 +++--- .../protocol/bedrock/data/UserInterfaceProfile.java | 13 +++++++++++++ .../protocol/bedrock/data/UserInterfaceType.java | 13 ------------- 3 files changed, 16 insertions(+), 16 deletions(-) rename bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/{OperatingSystem.java => BuildPlatform.java} (69%) create mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java delete mode 100644 bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/OperatingSystem.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/BuildPlatform.java similarity index 69% rename from bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/OperatingSystem.java rename to bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/BuildPlatform.java index 58bc4a790..dc8251394 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/OperatingSystem.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/BuildPlatform.java @@ -1,6 +1,6 @@ package org.cloudburstmc.protocol.bedrock.data; -public enum OperatingSystem { +public enum BuildPlatform { UNDEFINED, ANDROID, @@ -18,9 +18,9 @@ public enum OperatingSystem { XBOX, WINDOWS_PHONE; - private static final OperatingSystem[] VALUES = values(); + private static final BuildPlatform[] VALUES = values(); - public static OperatingSystem from(int id) { + public static BuildPlatform from(int id) { return id < VALUES.length ? VALUES[id] : VALUES[0]; } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java new file mode 100644 index 000000000..b5000af92 --- /dev/null +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java @@ -0,0 +1,13 @@ +package org.cloudburstmc.protocol.bedrock.data; + +public enum UserInterfaceProfile { + + CLASSIC, + POCKET; + + private static final UserInterfaceProfile[] VALUES = values(); + + public static UserInterfaceProfile from(int id) { + return VALUES[id]; + } +} diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java deleted file mode 100644 index 66778a225..000000000 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceType.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.cloudburstmc.protocol.bedrock.data; - -public enum UserInterfaceType { - - CLASSIC, - POCKET; - - private static final UserInterfaceType[] VALUES = values(); - - public static UserInterfaceType from(int id) { - return VALUES[id]; - } -} From 9c13ca78f0b2aa451016b0ac5a8d53cb11085db5 Mon Sep 17 00:00:00 2001 From: Niek Vincent Date: Mon, 23 Oct 2023 18:18:05 +0200 Subject: [PATCH 3/3] Changed the enum values to match official naming Changed the enumerator names to match the internal naming used in the game code, added JavaDoc comments with a human friendly naming and included a lower boundary check for the BuildPlatform.from method --- .../protocol/bedrock/data/BuildPlatform.java | 37 ++++++++++++++++--- .../bedrock/data/UserInterfaceProfile.java | 3 +- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/BuildPlatform.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/BuildPlatform.java index dc8251394..9fa59582c 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/BuildPlatform.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/BuildPlatform.java @@ -3,24 +3,49 @@ public enum BuildPlatform { UNDEFINED, - ANDROID, + /** + * Android + */ + GOOGLE, IOS, + /** + * Mac OS + */ OSX, + /** + * Kindle, FireTV + */ AMAZON, GEAR_VR, HOLOLENS, + /** + * Windows Store version + */ UWP, + /** + * Educational edition + */ WIN_32, DEDICATED, - APPLE_TV, - PLAYSTATION, - NINTENDO_SWITCH, + /** + * Apple TV + */ + TV_OS, + /** + * Playstation + */ + SONY, + /** + * Nintendo Switch + */ + NX, XBOX, - WINDOWS_PHONE; + WINDOWS_PHONE, + LINUX; private static final BuildPlatform[] VALUES = values(); public static BuildPlatform from(int id) { - return id < VALUES.length ? VALUES[id] : VALUES[0]; + return id > 0 && id < VALUES.length ? VALUES[id] : VALUES[0]; } } diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java index b5000af92..c9cbf4b4e 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/data/UserInterfaceProfile.java @@ -3,7 +3,8 @@ public enum UserInterfaceProfile { CLASSIC, - POCKET; + POCKET, + NONE; private static final UserInterfaceProfile[] VALUES = values();