@@ -23,6 +23,7 @@ use tokio::sync::{mpsc, Mutex, Semaphore};
2323use tokio_util:: sync:: CancellationToken ;
2424
2525use crate :: {
26+ args:: Args ,
2627 net:: { cache:: RegistryCache , player:: SharedPlayer } ,
2728 protocol:: packets:: login:: registry:: ALL_REGISTRIES ,
2829} ;
@@ -45,22 +46,18 @@ pub struct State {
4546 pub shutdown_token : CancellationToken ,
4647
4748 pub net_sema : Arc < Semaphore > ,
49+
50+ pub spawnpoint : ( f64 , f64 , f64 ) ,
51+ pub border_radius : i32 ,
4852}
4953
5054impl State {
5155 #[ must_use]
52- pub fn new (
53- version_name : & str ,
54- version_number : i32 ,
55- description : & str ,
56- max_players : usize ,
57- addr : String ,
58- port : u16 ,
59- ) -> Self {
60- let max = max_players. min ( Semaphore :: MAX_PERMITS ) ;
61-
62- if max < max_players {
63- warn ! ( "Requested max player count {max_players} is less than max semaphore permits {max} - limited to {max}." ) ;
56+ pub fn new ( version_name : & str , version_number : i32 , args : Args ) -> Self {
57+ let max = args. max_players . min ( Semaphore :: MAX_PERMITS ) ;
58+
59+ if max < args. max_players {
60+ warn ! ( "Requested max player count {} is less than max semaphore permits {max} - limited to {max}." , args. max_players) ;
6461 }
6562
6663 let ( player_send, player_recv) = mpsc:: channel ( 16 ) ;
@@ -69,11 +66,11 @@ impl State {
6966 Self {
7067 max_players : max,
7168 current_players : AtomicUsize :: new ( 0 ) ,
72- description : description . to_owned ( ) ,
69+ description : args . motd ,
7370 version_name : version_name. to_owned ( ) ,
7471 version_number : version_number. to_owned ( ) ,
75- addr,
76- port,
72+ addr : args . addr ,
73+ port : args . port ,
7774
7875 registry_cache : RegistryCache :: from ( & * ALL_REGISTRIES ) ,
7976
@@ -83,6 +80,9 @@ impl State {
8380 shutdown_token,
8481
8582 net_sema : Arc :: new ( Semaphore :: new ( max) ) ,
83+
84+ spawnpoint : ( args. spawn_x , args. spawn_y , args. spawn_z ) ,
85+ border_radius : args. border_radius ,
8686 }
8787 }
8888}
0 commit comments