Fix entity ID change bug

This commit is contained in:
ErrorNoInternet 2023-01-26 16:30:00 +08:00
parent 65209b3b64
commit db65c11395
Signed by untrusted user who does not match committer: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3

View File

@ -424,11 +424,17 @@ async fn handle(mut client: Client, event: Event, mut state: State) -> anyhow::R
if uuid.as_hyphenated().to_string() == entity.uuid { if uuid.as_hyphenated().to_string() == entity.uuid {
let mut player_locations = let mut player_locations =
state.player_locations.lock().unwrap().to_owned(); state.player_locations.lock().unwrap().to_owned();
let username = player.profile.name.to_owned();
for (player, _) in player_locations.to_owned() {
if player.username == username {
player_locations.remove(&player);
}
}
player_locations.insert( player_locations.insert(
Player { Player {
uuid: uuid.as_hyphenated().to_string(), uuid: uuid.as_hyphenated().to_string(),
entity_id: entity.id, entity_id: entity.id,
username: player.profile.name.to_owned(), username,
}, },
PositionTimeData { PositionTimeData {
position: vec![ position: vec![