From 0eec1e0b554573a6b1f4f072cea078e9308d11ab Mon Sep 17 00:00:00 2001 From: timvisee Date: Sat, 16 Mar 2024 17:51:56 +0100 Subject: [PATCH] Use 1.20.3 protocol version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- res/lazymc.toml | 4 ++-- src/monitor.rs | 5 ++--- src/proto/mod.rs | 4 ++-- src/server.rs | 2 +- src/status.rs | 15 +++++++-------- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c2183d..e3e2503 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -771,7 +771,7 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "minecraft-protocol" version = "0.1.0" -source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=b00328e#b00328e67c3c968ddd03a40202ba233ea0411a64" +source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=4f93bb3#4f93bb3438d25fd23410d7c30964971e59cfb327" dependencies = [ "byteorder", "minecraft-protocol-derive", @@ -784,7 +784,7 @@ dependencies = [ [[package]] name = "minecraft-protocol-derive" version = "0.0.0" -source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=b00328e#b00328e67c3c968ddd03a40202ba233ea0411a64" +source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=4f93bb3#4f93bb3438d25fd23410d7c30964971e59cfb327" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index bc3a7b9..cd3c3cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ dotenv = "0.15" flate2 = { version = "1.0", default-features = false, features = ["default"] } futures = { version = "0.3", default-features = false, features = ["executor"] } log = "0.4" -minecraft-protocol = { git = "https://github.com/timvisee/rust-minecraft-protocol", rev = "b00328e" } +minecraft-protocol = { git = "https://github.com/timvisee/rust-minecraft-protocol", rev = "4f93bb3" } named-binary-tag = "0.6" nix = { version = "0.28", features = ["process", "signal"] } notify = "4.0" diff --git a/res/lazymc.toml b/res/lazymc.toml index 1706d28..65c9047 100644 --- a/res/lazymc.toml +++ b/res/lazymc.toml @@ -18,8 +18,8 @@ # Server version & protocol hint. # Sent to clients until actual server version is known. # See: https://git.io/J1Fvx -#version = "1.19.3" -#protocol = 761 +#version = "1.20.3" +#protocol = 765 [server] # Server address. Internal IP and port of server started by lazymc to proxy to. diff --git a/src/monitor.rs b/src/monitor.rs index f9a5365..4d3a973 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -3,11 +3,10 @@ use std::sync::Arc; use std::time::Duration; use bytes::BytesMut; -use minecraft_protocol::data::server_status::ServerStatus; use minecraft_protocol::decoder::Decoder; use minecraft_protocol::version::v1_14_4::handshake::Handshake; -use minecraft_protocol::version::v1_14_4::status::{ - PingRequest, PingResponse, StatusRequest, StatusResponse, +use minecraft_protocol::version::v1_20_3::status::{ + PingRequest, PingResponse, ServerStatus, StatusRequest, StatusResponse, }; use rand::Rng; use tokio::io::AsyncWriteExt; diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 9e00ea1..1249a04 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -9,7 +9,7 @@ pub mod packets; /// in the configuration. /// /// Should be kept up-to-date with latest supported Minecraft version by lazymc. -pub const PROTO_DEFAULT_VERSION: &str = "1.19.3"; +pub const PROTO_DEFAULT_VERSION: &str = "1.20.3"; /// Default minecraft protocol version. /// @@ -17,7 +17,7 @@ pub const PROTO_DEFAULT_VERSION: &str = "1.19.3"; /// in the configuration. /// /// Should be kept up-to-date with latest supported Minecraft version by lazymc. -pub const PROTO_DEFAULT_PROTOCOL: u32 = 761; +pub const PROTO_DEFAULT_PROTOCOL: u32 = 765; /// Compression threshold to use. // TODO: read this from server.properties instead diff --git a/src/server.rs b/src/server.rs index b626eae..7748fda 100644 --- a/src/server.rs +++ b/src/server.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use futures::FutureExt; -use minecraft_protocol::data::server_status::ServerStatus; +use minecraft_protocol::version::v1_20_3::status::ServerStatus; use tokio::process::Command; use tokio::sync::watch; #[cfg(feature = "rcon")] diff --git a/src/status.rs b/src/status.rs index 0ec8477..dc631ab 100644 --- a/src/status.rs +++ b/src/status.rs @@ -1,13 +1,12 @@ use std::sync::Arc; use bytes::BytesMut; -use minecraft_protocol::data::chat::{Message, Payload}; -use minecraft_protocol::data::server_status::*; +use minecraft_protocol::data::server_status::{OnlinePlayers, ServerVersion}; use minecraft_protocol::decoder::Decoder; use minecraft_protocol::encoder::Encoder; use minecraft_protocol::version::v1_14_4::handshake::Handshake; use minecraft_protocol::version::v1_14_4::login::LoginStart; -use minecraft_protocol::version::v1_14_4::status::StatusResponse; +use minecraft_protocol::version::v1_20_3::status::{ServerStatus, StatusResponse}; use tokio::fs; use tokio::io::AsyncWriteExt; use tokio::net::TcpStream; @@ -232,11 +231,11 @@ async fn server_status(client_info: &ClientInfo, config: &Config, server: &Serve if config.motd.from_server && status.is_some() { status.as_ref().unwrap().description.clone() } else { - Message::new(Payload::text(match server_state { - server::State::Stopped | server::State::Started => &config.motd.sleeping, - server::State::Starting => &config.motd.starting, - server::State::Stopping => &config.motd.stopping, - })) + match server_state { + server::State::Stopped | server::State::Started => config.motd.sleeping.clone(), + server::State::Starting => config.motd.starting.clone(), + server::State::Stopping => config.motd.stopping.clone(), + } } };