Added info_messages.rs and moved string literals to it
This commit is contained in:
parent
2e067be5af
commit
ec81b13385
|
@ -12,6 +12,7 @@ use purple_cello_mc_protocol::{
|
|||
use crate::status_handle;
|
||||
use crate::login_handle;
|
||||
use crate::listener;
|
||||
use crate::info_messages;
|
||||
|
||||
pub async fn handle_client(
|
||||
client_socket: TcpStream,
|
||||
|
@ -80,9 +81,7 @@ pub async fn handle_client(
|
|||
}
|
||||
None => {
|
||||
login::clientbound::Disconnect {
|
||||
reason: "\"Server Error (Server is down or \
|
||||
restarting)\nPlease contact the admins if the issue persists:\n\
|
||||
purplecelloserver@gmail.com\""
|
||||
reason: info_messages::BACKEND_DOWN_DISCONNECT
|
||||
.to_string()
|
||||
}
|
||||
.write(&mut client_conn)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// Yeahbut June 2024
|
||||
|
||||
pub const BACKEND_DOWN_PING: &str = "\
|
||||
Server Error (Server may be starting)\n\
|
||||
Purple Cello Server";
|
||||
|
||||
pub const BACKEND_DOWN_DISCONNECT: &str = "\
|
||||
\"Server Error (Server is down or restarting)\n\
|
||||
Please contact the admins if the issue persists:\n\
|
||||
purplecelloserver@gmail.com\"";
|
||||
|
||||
pub const UUID_MISSING_DISCONNECT: &str = "Invalid UUID! (UUID Missing)";
|
||||
|
||||
pub const WHITELIST_STATUS_INACTIVE_DISCONNECT: &str = "\
|
||||
Whitelist Status Inactive!\n\
|
||||
Please contact the admins to reactivate:\n\
|
||||
purplecelloserver@gmail.com";
|
||||
|
||||
pub const USERNAME_INVALID_DISCONNECT: &str = "\
|
||||
Invalid Username!\n\
|
||||
Please contact the admins to update your username:\n\
|
||||
purplecelloserver@gmail.com";
|
||||
|
||||
pub const UUID_INVALID_DISCONNECT: &str = "Invalid UUID!";
|
||||
|
||||
pub const NOT_WHITELISTED_DISCONNECT: &str = "\
|
||||
Not whitelisted on this server.\n\
|
||||
Please direct whitelist requests to the admins:\n\
|
||||
purplecelloserver@gmail.com";
|
|
@ -9,6 +9,7 @@ mod login_handle;
|
|||
mod client;
|
||||
mod listener;
|
||||
mod whitelist;
|
||||
mod info_messages;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
|
|
@ -18,6 +18,7 @@ use purple_cello_mc_protocol::{
|
|||
};
|
||||
|
||||
use crate::listener;
|
||||
use crate::info_messages;
|
||||
|
||||
const EXPIRATION_DURATION: Duration = Duration::from_secs(3600);
|
||||
|
||||
|
@ -187,8 +188,8 @@ pub async fn respond_status(
|
|||
protocol: 0,
|
||||
},
|
||||
description: mc_types::Chat {
|
||||
text: "Server Error (Server may be starting)"
|
||||
.to_string() + "\nPurple Cello Server",
|
||||
text: info_messages::BACKEND_DOWN_PING
|
||||
.to_string(),
|
||||
},
|
||||
players: status::clientbound::StatusPlayers {
|
||||
max: 0,
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
use std::fs;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
const EXPIRATION_DURATION: Duration = Duration::from_secs(10);
|
||||
// const EXPIRATION_DURATION: Duration = Duration::from_secs(60);
|
||||
use crate::info_messages;
|
||||
|
||||
const EXPIRATION_DURATION: Duration = Duration::from_secs(60);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct Player {
|
||||
|
@ -146,7 +146,7 @@ impl WhitelistFile {
|
|||
|
||||
if player.player_uuid.is_none() {
|
||||
return PlayerAllowed::False(
|
||||
"Invalid UUID (UUID Missing)".to_string());
|
||||
info_messages::UUID_MISSING_DISCONNECT.to_string());
|
||||
}
|
||||
|
||||
let whitelist = self.get_whitelist();
|
||||
|
@ -173,21 +173,17 @@ impl WhitelistFile {
|
|||
}
|
||||
|
||||
if is_inactive {
|
||||
PlayerAllowed::False("Whitelist Status Inactive!\n\
|
||||
Please contact the admins to reactivate:\n\
|
||||
purplecelloserver@gmail.com".to_string()
|
||||
)
|
||||
PlayerAllowed::False(
|
||||
info_messages::WHITELIST_STATUS_INACTIVE_DISCONNECT.to_string())
|
||||
} else if invalid_username {
|
||||
PlayerAllowed::False("Invalid Username!\n\
|
||||
Please contact the admins to update your username:\n\
|
||||
purplecelloserver@gmail.com".to_string()
|
||||
)
|
||||
PlayerAllowed::False(
|
||||
info_messages::USERNAME_INVALID_DISCONNECT.to_string())
|
||||
} else if invalid_uuid {
|
||||
PlayerAllowed::False("Invalid UUID".to_string())
|
||||
PlayerAllowed::False(
|
||||
info_messages::UUID_INVALID_DISCONNECT.to_string())
|
||||
} else {
|
||||
PlayerAllowed::False("Not whitelisted on this server.\n\
|
||||
Please direct whitelist requests to the admins:\n\
|
||||
purplecelloserver@gmail.com".to_string())
|
||||
PlayerAllowed::False(
|
||||
info_messages::NOT_WHITELISTED_DISCONNECT.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue