Skip to content

Commit 19452bc

Browse files
authored
Merge branch 'master' into feat/commands
2 parents f63e5a2 + 7a6d183 commit 19452bc

File tree

8 files changed

+185
-180
lines changed

8 files changed

+185
-180
lines changed

.etc/example-config.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,3 @@ cache_ttl = 60
4040
# How big the cache can be in kb.
4141
cache_capacity = 20_000
4242

43-
whitelist = false
44-

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ ahash = "0.8.12"
144144
serde = { version = "1.0.219", features = ["derive"] }
145145
serde_json = "1.0.142"
146146
serde_derive = "1.0.219"
147+
serde_yaml_ng = "0.9.36"
147148
base64 = "0.22.1"
148149
bitcode = "0.6.6"
149150
bitcode_derive = "0.6.5"

src/bin/src/game_loop.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pub fn start_game_loop(global_state: GlobalState) -> Result<(), BinaryError> {
112112
Ok(())
113113
}
114114

115-
// This is the bit where we bridge to async
116115
fn tcp_conn_acceptor(
117116
state: GlobalState,
118117
packet_sender: Arc<PacketSender>,

src/lib/utils/config/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ uuid = { workspace = true }
1919
regex = { workspace = true }
2020
reqwest = { workspace = true }
2121
ureq = { workspace = true, features = ["json"] }
22+
serde_json = { workspace = true }
23+
serde_yaml_ng = { workspace = true }
2224
rayon = { workspace = true }

src/lib/utils/config/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ pub enum ConfigError {
2727
/// Error when the root path cannot be found.
2828
#[error("Failed to get the root path.")]
2929
RootPathError(#[from] ferrumc_general_purpose::paths::RootPathError),
30+
31+
/// YAML serialization/deserialization error.
32+
#[error("YAML error: {0}")]
33+
YamlError(#[from] serde_yaml_ng::Error),
34+
35+
/// Custom error message.
36+
#[error("{0}")]
37+
Custom(String),
3038
}

src/lib/utils/config/src/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl From<std::io::Error> for SetupError {
2727
}
2828

2929
pub fn setup() -> Result<(), SetupError> {
30-
if !std::fs::exists(get_root_path().join("whitelist.txt"))? {
30+
if !std::fs::exists(get_root_path().join("whitelist.yml"))? {
3131
create_blank_whitelist_file();
3232
}
3333
if std::fs::exists(get_root_path().join("config.toml"))? {

src/lib/utils/config/src/statics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::server_config::ServerConfig;
2-
use dashmap::DashSet;
2+
use dashmap::DashMap;
33
use ferrumc_general_purpose::paths::get_root_path;
44
use lazy_static::lazy_static;
55
use std::fs::File;
@@ -13,8 +13,8 @@ pub(crate) const DEFAULT_CONFIG: &str = include_str!("../../../../../.etc/exampl
1313
lazy_static! {
1414
/// The server configuration that is stored in memory.
1515
static ref CONFIG: ServerConfig = create_config();
16-
/// The whitelist of player uuids.
17-
pub static ref WHITELIST: DashSet<u128> = DashSet::new();
16+
/// The whitelist of player uuids to names.
17+
pub static ref WHITELIST: DashMap<u128, String> = DashMap::new();
1818
}
1919
fn create_config() -> ServerConfig {
2020
let config_location = get_root_path().join("config.toml");
@@ -77,6 +77,6 @@ pub fn get_global_config() -> &'static ServerConfig {
7777
&CONFIG
7878
}
7979

80-
pub fn get_whitelist() -> &'static DashSet<u128> {
80+
pub fn get_whitelist() -> &'static DashMap<u128, String> {
8181
&WHITELIST
8282
}

0 commit comments

Comments
 (0)