Closed stefanrybacki closed 8 months ago
Hello OP and anyone else trying to figure out how to get this thing to work! I looked into it, and the reason this seems to be happening is that lazymc expects a different status response schema from the one it actually gets in 1.20.4 servers:
{"version":{"name":"1.19.4","protocol":762},"enforcesSecureChat":true,"description":{"text":"A Minecraft Server"},"players":{"max":20,"online":0}}
{"version":{"name":"1.20.4","protocol":765},"description":"A Minecraft Server","players":{"max":20,"online":0}}
As you can see, description
in 1.19.4 is a JSON object (specifically, it's supposed to be the same type a chat message is, at least according to this third-party protocol documentation), but in 1.20.4 it is a plain string. This results in a silent decode failure at https://github.com/timvisee/lazymc/blob/37fdb9c12a1d56a07ce412252189b19428505788/src/monitor.rs#L187
Honestly, the error should've been bubbled all the way up, or at least logged properly, so nobody has to spend a couple hours tracking down what goes wrong, but whatever…
The decoding is done by a package called rust-minecraft-protocol. It seems that timvisee attempted to add some sort of multi-version support to it, but I'm too lazy to figure out how to make use of it in and whatnot, so here's the diff you have to apply to the crate (make sure you're on the lazymc-multiver
branch):
diff --git a/protocol/src/data/server_status.rs b/protocol/src/data/server_status.rs
index 151eb55..17e1339 100644
--- a/protocol/src/data/server_status.rs
+++ b/protocol/src/data/server_status.rs
@@ -7,7 +7,7 @@ use uuid::Uuid;
pub struct ServerStatus {
pub version: ServerVersion,
pub players: OnlinePlayers,
- pub description: Message,
+ pub description: String,
pub favicon: Option<String>,
}
Then you need to patch lazymc itself:
diff --git a/src/status.rs b/src/status.rs
index 54bf985..453484d 100644
--- a/src/status.rs
+++ b/src/status.rs
@@ -232,11 +232,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 {
+ match server_state {
server::State::Stopped | server::State::Started => &config.motd.sleeping,
server::State::Starting => &config.motd.starting,
server::State::Stopping => &config.motd.stopping,
- }))
+ }.to_string()
}
};
These changes will probably break lazymc for any server that's below 1.20.4, but at least it now works with the current version.
I'm thinking that lazymc's status handling probably needs a rewrite to account for multiple possible schemas, but I'm not the person to do it.
hi, just wanted to say thanks for this, it works for me with versions 1.20.4+
Thank you @sudhir-chandra, that saved me from installing a rust environment in a VM and building a new version on my own :)
@Lahvuun's method throws a probing error when starting, but it's seems to work perfectly fine as quick and dirty workaround until a proper fix arrives,
I ran into this issue as well,
@Lahvuun 's solution (I downloaded his BIN) fixed it for me
the provided binary didn't function on my alpine linux machine (perhaps because using musl
instead of glibc
? unsure). i applied Lahvuun's patches (thank you) to repo forks, which can be built with:
$ cargo install -f --git https://git.cozy.software/slime/lazymc --rev c3d1618ba8
I also had this issue and unfortunately sudhir-chandra's bin did not solve it for me. For that, I looked up alternatives and found out about Minecraft Server Hibernation which worked for me on 1.20.4
I've just released lazymc 0.2.11 which support Minecraft 1.20.3 and up.
Just found your project, thank you for that.
However, I am not able to get it to work correctly. I set up lazymc as stated in the documentation and the logs seem to indicate the setup is correct. But, when connecting I always run into the connection timeout even though the server is running.
Any ideas what could be the culprit here (it seems lazymc does not recognize the server to be ready loading, as it detects a too long start)?
Here are the logs from lazymc:
Thanks in advance