From bd73b657c7ce4334db367eb83a5d601073272800 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Thu, 16 Nov 2023 15:18:15 +0200 Subject: [PATCH] fix: minecraft id naming inconsistencies (#152) * fix: minecraft id naming inconsistencies * fix: minecraft legacy beta 1.8 being wrongly id named in definitions * docs: Update CHANGELOG to document minecraft legacy renames * docs: Update CHANGELOG to note removal of legacy versions game names being prefixed with 'v' --- CHANGELOG.md | 1 + crates/lib/src/games/definitions.rs | 6 +++--- .../protocol/{legacy_v1_5.rs => legacy_v1_4.rs} | 6 +++--- .../protocol/{legacy_v1_3.rs => legacy_vb1_8.rs} | 6 +++--- .../lib/src/protocols/minecraft/protocol/mod.rs | 16 ++++++++-------- crates/lib/src/protocols/minecraft/types.rs | 4 ++-- 6 files changed, 20 insertions(+), 19 deletions(-) rename crates/lib/src/protocols/minecraft/protocol/{legacy_v1_5.rs => legacy_v1_4.rs} (96%) rename crates/lib/src/protocols/minecraft/protocol/{legacy_v1_3.rs => legacy_vb1_8.rs} (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 907cda26..1ce4b4e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Game: - - Left 4 Dead: `left4dead` -> `l4d`. - - 7 Days to Die: `7d2d` in definitions and `sd2d` in game declaration -> `sdtd`. - - Quake 3 Arena: `quake3arena` -> `q3a`. +- Minecraft Legacy 1.5 and 1.3 were renamed to 1.4 and beta 1.8 respectively to show the lowest version they support, this change includes Structs, Enum and game id renames, also removed the "v" from the game definition name. Protocols: - Valve: Removed `SteamApp` due to it not being really useful at all, replaced all instances with `Engine`. diff --git a/crates/lib/src/games/definitions.rs b/crates/lib/src/games/definitions.rs index b620ea00..bcefc0df 100644 --- a/crates/lib/src/games/definitions.rs +++ b/crates/lib/src/games/definitions.rs @@ -41,9 +41,9 @@ pub static GAMES: Map<&'static str, Game> = phf_map! { "minecraftbedrock" => game!("Minecraft (bedrock)", 19132, Protocol::Minecraft(Some(Server::Bedrock))), "minecraftpocket" => game!("Minecraft (pocket)", 19132, Protocol::Minecraft(Some(Server::Bedrock))), "minecraftjava" => game!("Minecraft (java)", 25565, Protocol::Minecraft(Some(Server::Java))), - "minecraftlegacy16" => game!("Minecraft (legacy v1.6)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6)))), - "minecraftlegacy15" => game!("Minecraft (legacy v1.4-1.5)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_5)))), - "minecraftlegacy13" => game!("Minecraft (legacy vB1.8-1.3)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_3)))), + "minecraftlegacy16" => game!("Minecraft (legacy 1.6)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6)))), + "minecraftlegacy14" => game!("Minecraft (legacy 1.4)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_4)))), + "minecraftlegacyb18" => game!("Minecraft (legacy b1.8)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::VB1_8)))), "alienswarm" => game!("Alien Swarm", 27015, Protocol::Valve(Engine::new(630))), "aoc" => game!("Age of Chivalry", 27015, Protocol::Valve(Engine::new(17510))), "a2oa" => game!("ARMA 2: Operation Arrowhead", 2304, Protocol::Valve(Engine::new(33930))), diff --git a/crates/lib/src/protocols/minecraft/protocol/legacy_v1_5.rs b/crates/lib/src/protocols/minecraft/protocol/legacy_v1_4.rs similarity index 96% rename from crates/lib/src/protocols/minecraft/protocol/legacy_v1_5.rs rename to crates/lib/src/protocols/minecraft/protocol/legacy_v1_4.rs index c94738d0..ba4733ec 100644 --- a/crates/lib/src/protocols/minecraft/protocol/legacy_v1_5.rs +++ b/crates/lib/src/protocols/minecraft/protocol/legacy_v1_4.rs @@ -13,12 +13,12 @@ use crate::{ }; use std::net::SocketAddr; -pub struct LegacyV1_5 { +pub struct LegacyV1_4 { socket: TcpSocket, retry_count: usize, } -impl LegacyV1_5 { +impl LegacyV1_4 { fn new(address: &SocketAddr, timeout_settings: Option) -> GDResult { let socket = TcpSocket::new(address)?; socket.apply_timeout(&timeout_settings)?; @@ -75,7 +75,7 @@ impl LegacyV1_5 { favicon: None, previews_chat: None, enforces_secure_chat: None, - server_type: Server::Legacy(LegacyGroup::V1_5), + server_type: Server::Legacy(LegacyGroup::V1_4), }) } diff --git a/crates/lib/src/protocols/minecraft/protocol/legacy_v1_3.rs b/crates/lib/src/protocols/minecraft/protocol/legacy_vb1_8.rs similarity index 96% rename from crates/lib/src/protocols/minecraft/protocol/legacy_v1_3.rs rename to crates/lib/src/protocols/minecraft/protocol/legacy_vb1_8.rs index 5658912b..426f42ee 100644 --- a/crates/lib/src/protocols/minecraft/protocol/legacy_v1_3.rs +++ b/crates/lib/src/protocols/minecraft/protocol/legacy_vb1_8.rs @@ -14,12 +14,12 @@ use std::net::SocketAddr; use byteorder::BigEndian; -pub struct LegacyV1_3 { +pub struct LegacyVB1_8 { socket: TcpSocket, retry_count: usize, } -impl LegacyV1_3 { +impl LegacyVB1_8 { fn new(address: &SocketAddr, timeout_settings: Option) -> GDResult { let socket = TcpSocket::new(address)?; socket.apply_timeout(&timeout_settings)?; @@ -72,7 +72,7 @@ impl LegacyV1_3 { favicon: None, previews_chat: None, enforces_secure_chat: None, - server_type: Server::Legacy(LegacyGroup::V1_3), + server_type: Server::Legacy(LegacyGroup::VB1_8), }) } diff --git a/crates/lib/src/protocols/minecraft/protocol/mod.rs b/crates/lib/src/protocols/minecraft/protocol/mod.rs index 79fa6ab7..d2c7762a 100644 --- a/crates/lib/src/protocols/minecraft/protocol/mod.rs +++ b/crates/lib/src/protocols/minecraft/protocol/mod.rs @@ -4,9 +4,9 @@ use crate::{ protocol::{ bedrock::Bedrock, java::Java, - legacy_v1_3::LegacyV1_3, - legacy_v1_5::LegacyV1_5, + legacy_v1_4::LegacyV1_4, legacy_v1_6::LegacyV1_6, + legacy_vb1_8::LegacyVB1_8, }, BedrockResponse, JavaResponse, @@ -20,9 +20,9 @@ use std::net::SocketAddr; mod bedrock; mod java; -mod legacy_v1_3; -mod legacy_v1_5; +mod legacy_v1_4; mod legacy_v1_6; +mod legacy_vb1_8; /// Queries a Minecraft server with all the protocol variants one by one (Java /// -> Bedrock -> Legacy (1.6 -> 1.4 -> Beta 1.8)). @@ -61,11 +61,11 @@ pub fn query_legacy(address: &SocketAddr, timeout_settings: Option GDResult { match group { LegacyGroup::V1_6 => LegacyV1_6::query(address, timeout_settings), - LegacyGroup::V1_5 => LegacyV1_5::query(address, timeout_settings), - LegacyGroup::V1_3 => LegacyV1_3::query(address, timeout_settings), + LegacyGroup::V1_4 => LegacyV1_4::query(address, timeout_settings), + LegacyGroup::VB1_8 => LegacyVB1_8::query(address, timeout_settings), } } diff --git a/crates/lib/src/protocols/minecraft/types.rs b/crates/lib/src/protocols/minecraft/types.rs index 0d1da2cf..82618eb3 100644 --- a/crates/lib/src/protocols/minecraft/types.rs +++ b/crates/lib/src/protocols/minecraft/types.rs @@ -35,9 +35,9 @@ pub enum LegacyGroup { /// 1.6 V1_6, /// 1.4 - 1.5 - V1_5, + V1_4, /// Beta 1.8 - 1.3 - V1_3, + VB1_8, } /// Information about a player.