Added main menu kick message with kick reason after player is kicked

This commit is contained in:
tylerlowrey 2020-08-02 16:36:01 -04:00 committed by Joshua Yanovski
parent fee79720ee
commit 30c3146682
7 changed files with 26 additions and 1 deletions

View File

@ -142,6 +142,7 @@ https://account.veloren.net."#,
"main.login.client_crashed": "Client crashed",
"main.login.not_on_whitelist": "You need a Whitelist entry by an Admin to join",
"main.login.banned": "You have been banned with the following reason",
"main.login.kicked": "You have been kicked with the following reason",
/// End Main screen section

View File

@ -17,6 +17,7 @@ pub enum Error {
AuthClientError(AuthClientError),
AuthServerNotTrusted,
Banned(String),
Kicked(String),
/// Persisted character data is invalid or missing
InvalidCharacter,
//TODO: InvalidAlias,

View File

@ -59,6 +59,7 @@ pub enum Event {
Disconnect,
DisconnectionNotification(u64),
InventoryUpdated(InventoryUpdateEvent),
Kicked(String),
Notification(Notification),
SetViewDistance(u32),
Outcome(Outcome),
@ -1395,6 +1396,10 @@ impl Client {
self.singleton_stream.send(ClientMsg::Terminate)?;
break Ok(());
},
ServerMsg::Kicked(reason) => {
frontend_events.push(Event::Kicked(reason.clone()));
self.singleton_stream.send(ClientMsg::Terminate)?;
}
ServerMsg::CharacterListUpdate(character_list) => {
self.character_list.characters = character_list;
self.character_list.loading = false;

View File

@ -239,6 +239,7 @@ pub enum ServerMsg {
},
TerrainBlockUpdates(HashMap<Vec3<i32>, Block>),
Disconnect,
Kicked(String),
Shutdown,
TooManyPlayers,
/// Send a popup notification such as "Waypoint Saved"

View File

@ -1832,7 +1832,7 @@ fn handle_kick(
if let Some(target_player) = target_player_opt {
server.notify_client(
target_player,
ServerMsg::Disconnect
ServerMsg::Kicked(reason.clone())
);
server.notify_client(
client,

View File

@ -132,6 +132,13 @@ impl PlayState for MainMenuState {
reason
)
},
client::Error::Kicked(reason) => {
format!(
"{}: {}",
localized_strings.get("main.login.kicked"),
reason
)
}
client::Error::InvalidCharacter => {
localized_strings.get("main.login.invalid_character").into()
},

View File

@ -163,6 +163,16 @@ impl SessionState {
message,
});
},
client::Event::Kicked(reason) => {
global_state.info_message = Some(
format!(
"{}: {}",
self.voxygen_i18n.get("main.login.kicked").to_string(),
reason
)
);
return Ok(TickAction::Disconnect)
},
client::Event::Notification(n) => {
self.hud.new_notification(n);
},