diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4046777..e973c8d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,7 @@ before_script: - cargo check --verbose - cargo check --no-default-features --verbose - cargo check --no-default-features --features rcon --verbose + - cargo check --no-default-features --features lobby --verbose check: <<: *check-base check-macos: @@ -68,6 +69,7 @@ check-windows: script: - cargo check --locked --verbose - cargo check --locked --no-default-features --features rcon --verbose + - cargo check --locked --no-default-features --features lobby --verbose # Build using Rust stable on Linux build-x86_64-linux-gnu: @@ -231,6 +233,7 @@ test-cargo-x86_64-linux-gnu: - cargo test --locked --verbose - cargo test --locked --no-default-features --verbose - cargo test --locked --no-default-features --features rcon --verbose + - cargo test --locked --no-default-features --features lobby --verbose # Run the unit tests through Cargo on Windows test-cargo-x86_64-windows: @@ -244,6 +247,7 @@ test-cargo-x86_64-windows: script: - cargo test --locked --verbose - cargo test --locked --no-default-features --features rcon --verbose + - cargo test --locked --no-default-features --features lobby --verbose # Release binaries on GitLab as generic package release-gitlab-generic-package: diff --git a/Cargo.toml b/Cargo.toml index bf3d249..13b9b38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,17 @@ exclude = [ edition = "2021" [features] -default = ["rcon"] +default = ["rcon", "lobby"] + +# RCON support +# Allow use of RCON to manage (stop) server. +# Required on Windows. rcon = ["rust_rcon"] +# Lobby support +# Add lobby join method, keeps client in fake lobby world until server is ready. +lobby = ["named-binary-tag", "quartz_nbt", "uuid"] + [dependencies] anyhow = "1.0" bytes = "1.1" @@ -46,9 +54,9 @@ version-compare = "0.1" rust_rcon = { package = "rcon", version = "0.5", optional = true } # Feature: lobby -named-binary-tag = "0.6" -quartz_nbt = "0.2" -uuid = { version = "0.7", features = ["v3"] } +named-binary-tag = { version = "0.6", optional = true } +quartz_nbt = { version = "0.2", optional = true } +uuid = { version = "0.7", optional = true, features = ["v3"] } [target.'cfg(unix)'.dependencies] libc = "0.2" diff --git a/src/main.rs b/src/main.rs index 1faac2e..29dd3a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ extern crate log; pub(crate) mod action; pub(crate) mod cli; pub(crate) mod config; +#[cfg(feature = "lobby")] pub(crate) mod lobby; pub(crate) mod mc; pub(crate) mod monitor; diff --git a/src/mc/mod.rs b/src/mc/mod.rs index c528f81..8a26720 100644 --- a/src/mc/mod.rs +++ b/src/mc/mod.rs @@ -3,4 +3,5 @@ pub mod rcon; pub mod server_properties; /// Minecraft ticks per second. +#[allow(unused)] pub const TICKS_PER_SECOND: u32 = 20; diff --git a/src/proto.rs b/src/proto.rs index 3642412..eafede0 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -113,6 +113,7 @@ impl Client { } /// Set compression value. + #[allow(unused)] pub fn set_compression(&self, threshold: i32) { trace!(target: "lazymc", "Client now uses compression threshold of {}", threshold); self.compression.store(threshold, Ordering::Relaxed); @@ -144,6 +145,7 @@ pub enum ClientState { Login, /// State to play on the server. + #[allow(unused)] Play, } diff --git a/src/status.rs b/src/status.rs index 6c1ae23..e2f83b9 100644 --- a/src/status.rs +++ b/src/status.rs @@ -16,6 +16,7 @@ use tokio::net::TcpStream; use tokio::time; use crate::config::*; +#[cfg(feature = "lobby")] use crate::lobby; use crate::proto::{self, Client, ClientInfo, ClientState, RawPacket}; use crate::server::{self, Server, State}; @@ -198,6 +199,7 @@ pub async fn serve( } // Lobby method, keep client in lobby while server starts + #[cfg(feature = "lobby")] Method::Lobby => { trace!(target: "lazymc", "Using lobby method to occupy joining client"); @@ -209,9 +211,14 @@ pub async fn serve( // Start lobby lobby::serve(client, client_info, inbound, config, server, queue).await?; return Ok(()); - // TODO: do not consume client here, allow other join method on fail } + + // Lobby method, keep client in lobby while server starts + #[cfg(not(feature = "lobby"))] + Method::Lobby => { + error!(target: "lazymc", "Lobby join method not supported in this lazymc build"); + } } }