Compare commits
2 commits
e403d93dc2
...
8a9ae9f735
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a9ae9f735 | |||
| 6fab222d1e |
2 changed files with 8 additions and 6 deletions
|
|
@ -119,6 +119,7 @@
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
default = my-crate;
|
default = my-crate;
|
||||||
|
deps = cargoArtifacts;
|
||||||
} // lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
|
} // lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
|
||||||
my-crate-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // {
|
my-crate-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // {
|
||||||
inherit cargoArtifacts;
|
inherit cargoArtifacts;
|
||||||
|
|
|
||||||
13
src/main.rs
13
src/main.rs
|
|
@ -20,6 +20,8 @@ mod opaque_error;
|
||||||
mod packets;
|
mod packets;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
|
static BYE_MESSAGE: &str = concat!("§dTami§r with §d<3§r §8(rev: ", env!("COMMIT_HASH"), ")§r");
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// ---- Tracing setup ----
|
// ---- Tracing setup ----
|
||||||
|
|
@ -160,7 +162,6 @@ async fn handle_status<T: MinecraftServerHandle>(
|
||||||
let commit_hash: &'static str = env!("COMMIT_HASH");
|
let commit_hash: &'static str = env!("COMMIT_HASH");
|
||||||
let mut status_struct = StatusStructNew::create();
|
let mut status_struct = StatusStructNew::create();
|
||||||
status_struct.version.protocol = handshake.protocol_version.get_int();
|
status_struct.version.protocol = handshake.protocol_version.get_int();
|
||||||
let bye_message = format!(" - §dTami§r with §d<3§r §8(rev: {commit_hash})§r");
|
|
||||||
|
|
||||||
let server = match api
|
let server = match api
|
||||||
.query_server(
|
.query_server(
|
||||||
|
|
@ -175,7 +176,7 @@ async fn handle_status<T: MinecraftServerHandle>(
|
||||||
status_struct.players.max = 0;
|
status_struct.players.max = 0;
|
||||||
status_struct.players.online = 0;
|
status_struct.players.online = 0;
|
||||||
status_struct.description.text = format!(
|
status_struct.description.text = format!(
|
||||||
"Could not find §kserver§r: §f§o{server_addr}§r\nMinecraft Ingress {bye_message}"
|
"Could not find §kserver§r: §f§o{server_addr}§r\nMinecraft Ingress - {BYE_MESSAGE}"
|
||||||
);
|
);
|
||||||
|
|
||||||
mc_server::complete_status_request(client_stream, status_struct)
|
mc_server::complete_status_request(client_stream, status_struct)
|
||||||
|
|
@ -219,12 +220,12 @@ async fn handle_status<T: MinecraftServerHandle>(
|
||||||
status_struct.players.max = 1;
|
status_struct.players.max = 1;
|
||||||
status_struct.players.online = 1;
|
status_struct.players.online = 1;
|
||||||
status_struct.description.text =
|
status_struct.description.text =
|
||||||
format!("{motd}\n§2Starting!§r §b§oWait a bit§r§b ^^§r{bye_message}");
|
format!("{motd}\n§2Starting!§r §b§oWait a bit§r§b ^^§r - {BYE_MESSAGE}");
|
||||||
}
|
}
|
||||||
ServerDeploymentStatus::Offline => {
|
ServerDeploymentStatus::Offline => {
|
||||||
status_struct.players.max = 1;
|
status_struct.players.max = 1;
|
||||||
status_struct.description.text =
|
status_struct.description.text =
|
||||||
format!("{motd}\n§4Offline§r §oJoin to start!§r{bye_message}");
|
format!("{motd}\n§4Offline§r §oJoin to start!§r - {BYE_MESSAGE}");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -289,13 +290,13 @@ async fn handle_login<T: MinecraftServerHandle>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ServerDeploymentStatus::PodOk | ServerDeploymentStatus::Starting => {
|
ServerDeploymentStatus::PodOk | ServerDeploymentStatus::Starting => {
|
||||||
mc_server::send_disconnect(client_stream, "Starting...§d<3§r").await?;
|
mc_server::send_disconnect(client_stream, format!("[\"\",{{\"text\":\"The server is still starting up...\n wait a bit more please ^^\n\n\"}},{{\"text\":\"{BYE_MESSAGE}\"}}]").as_str()).await?;
|
||||||
}
|
}
|
||||||
ServerDeploymentStatus::Offline => {
|
ServerDeploymentStatus::Offline => {
|
||||||
server.start().await?;
|
server.start().await?;
|
||||||
api.start_watch(server.clone(), Duration::from_secs(600))
|
api.start_watch(server.clone(), Duration::from_secs(600))
|
||||||
.await?;
|
.await?;
|
||||||
mc_server::send_disconnect(client_stream, "Okayy_starting_it...§d<3§r").await?;
|
mc_server::send_disconnect(client_stream, format!("[\"\",{{\"text\":\"Okayy, §2starting§r the server!\n\n\"}},{{\"text\":\"{BYE_MESSAGE}\"}}]").as_str()).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue