11using System ;
22using System . Collections ;
33using System . Diagnostics ;
4+ using System . Text . RegularExpressions ;
45using NitroxClient . Communication . Abstract ;
56using NitroxClient . Communication . Exceptions ;
67using NitroxClient . Communication . MultiplayerSession ;
@@ -380,9 +381,10 @@ private void OnJoinClick()
380381
381382 string playerName = playerNameText . text ;
382383
383- if ( string . IsNullOrEmpty ( playerName ) )
384+ //https://regex101.com/r/eTWiEs/2/
385+ if ( ! Regex . IsMatch ( playerName , @"^[a-zA-Z0-9._-]{3,25}$" ) )
384386 {
385- NotifyUser ( "Please enter a player name and colour before trying to join a server " ) ;
387+ NotifyUser ( "Please enter a valid player name ! \n \n It must not contain any space or doubtful characters \n Allowed characters : A-Z a-z 0-9 _ . - \n Length : [3, 25] " ) ;
386388 return ;
387389 }
388390
@@ -416,8 +418,9 @@ private void SessionConnectionStateChangedHandler(IMultiplayerSessionConnectionS
416418 case MultiplayerSessionConnectionStage . ESTABLISHING_SERVER_POLICY :
417419 Log . InGame ( "Requesting session policy information..." ) ;
418420 break ;
421+
419422 case MultiplayerSessionConnectionStage . AWAITING_RESERVATION_CREDENTIALS :
420- Log . InGame ( "Waiting for User Input ..." ) ;
423+ Log . InGame ( "Waiting for user input ..." ) ;
421424 RightSideMainMenu . OpenGroup ( "Join Server" ) ;
422425 FocusPlayerNameTextbox ( ) ;
423426 break ;
@@ -434,6 +437,7 @@ private void SessionConnectionStateChangedHandler(IMultiplayerSessionConnectionS
434437 LoadingScreenVersionText . Initialize ( ) ;
435438
436439 break ;
440+
437441 case MultiplayerSessionConnectionStage . SESSION_RESERVATION_REJECTED :
438442 Log . InGame ( "Reservation rejected..." ) ;
439443
@@ -450,6 +454,7 @@ private void SessionConnectionStateChangedHandler(IMultiplayerSessionConnectionS
450454 } ) ;
451455
452456 break ;
457+
453458 case MultiplayerSessionConnectionStage . DISCONNECTED :
454459 Log . Info ( "Disconnected from server" ) ;
455460 break ;
@@ -463,14 +468,12 @@ private void NotifyUser(string notificationMessage, Action continuationAction =
463468 return ;
464469 }
465470
466- Action wrappedAction = ( ) =>
471+ MainMenuNotification notificationDialog = gameObject . AddComponent < MainMenuNotification > ( ) ;
472+ notificationDialog . ShowNotification ( notificationMessage , ( ) =>
467473 {
468474 continuationAction ? . Invoke ( ) ;
469475 Destroy ( gameObject . GetComponent < MainMenuNotification > ( ) , 0.0001f ) ;
470- } ;
471-
472- MainMenuNotification notificationDialog = gameObject . AddComponent < MainMenuNotification > ( ) ;
473- notificationDialog . ShowNotification ( notificationMessage , wrappedAction ) ;
476+ } ) ;
474477 }
475478
476479 private void StopMultiplayerClient ( )
0 commit comments