mirror of
https://github.com/italicsjenga/valence.git
synced 2025-01-11 15:21:31 +11:00
Don't send untranslated error messages to clients
This commit is contained in:
parent
0c6ecc9c12
commit
985ecf3922
|
@ -163,7 +163,7 @@ impl Config for Game {
|
||||||
}
|
}
|
||||||
Event::Movement { position, .. } => {
|
Event::Movement { position, .. } => {
|
||||||
if position.y <= 0.0 {
|
if position.y <= 0.0 {
|
||||||
client.teleport(spawn_pos, client.pitch(), client.yaw());
|
client.teleport(spawn_pos, client.yaw(), client.pitch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -328,7 +328,7 @@ impl Client {
|
||||||
|
|
||||||
pub fn disconnect_no_reason(&mut self) {
|
pub fn disconnect_no_reason(&mut self) {
|
||||||
if self.send.is_some() {
|
if self.send.is_some() {
|
||||||
log::info!("disconnecting client '{}' (no reason)", self.username);
|
log::info!("disconnecting client '{}'", self.username);
|
||||||
self.send = None;
|
self.send = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,12 +456,16 @@ impl Client {
|
||||||
C2sPlayPacket::KeepAlive(p) => {
|
C2sPlayPacket::KeepAlive(p) => {
|
||||||
let last_keepalive_id = self.last_keepalive_id;
|
let last_keepalive_id = self.last_keepalive_id;
|
||||||
if self.got_keepalive {
|
if self.got_keepalive {
|
||||||
self.disconnect("Unexpected keepalive");
|
log::warn!("unexpected keepalive from player {}", self.username());
|
||||||
|
self.disconnect_no_reason();
|
||||||
} else if p.id != last_keepalive_id {
|
} else if p.id != last_keepalive_id {
|
||||||
self.disconnect(format!(
|
log::warn!(
|
||||||
"Keepalive ids don't match (expected {}, got {})",
|
"keepalive ids for player {} don't match (expected {}, got {})",
|
||||||
last_keepalive_id, p.id
|
self.username(),
|
||||||
));
|
last_keepalive_id,
|
||||||
|
p.id
|
||||||
|
);
|
||||||
|
self.disconnect_no_reason();
|
||||||
} else {
|
} else {
|
||||||
self.got_keepalive = true;
|
self.got_keepalive = true;
|
||||||
}
|
}
|
||||||
|
@ -610,7 +614,7 @@ impl Client {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.player_list().packets(|pkt| self.send_packet(pkt));
|
meta.player_list().diff_packets(|pkt| self.send_packet(pkt));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the players spawn position (compass position)
|
// Update the players spawn position (compass position)
|
||||||
|
@ -641,7 +645,11 @@ impl Client {
|
||||||
self.last_keepalive_id = id;
|
self.last_keepalive_id = id;
|
||||||
self.got_keepalive = false;
|
self.got_keepalive = false;
|
||||||
} else {
|
} else {
|
||||||
self.disconnect("Timed out (no keepalive response)");
|
log::warn!(
|
||||||
|
"player {} timed out (no keepalive response)",
|
||||||
|
self.username()
|
||||||
|
);
|
||||||
|
self.disconnect_no_reason();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl PlayerList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn packets(&self, mut packet: impl FnMut(S2cPlayPacket)) {
|
pub(crate) fn diff_packets(&self, mut packet: impl FnMut(S2cPlayPacket)) {
|
||||||
if !self.removed.is_empty() {
|
if !self.removed.is_empty() {
|
||||||
packet(PlayerInfo::RemovePlayer(self.removed.iter().cloned().collect()).into());
|
packet(PlayerInfo::RemovePlayer(self.removed.iter().cloned().collect()).into());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue