refactor(state): clean up client information tables
This commit is contained in:
parent
0ea2c81d2a
commit
8ae882a56a
@ -31,26 +31,26 @@ pub fn score(_lua: &Lua, client: &Client) -> Result<i32> {
|
|||||||
pub async fn set_client_information(
|
pub async fn set_client_information(
|
||||||
_lua: Lua,
|
_lua: Lua,
|
||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
ci: Table,
|
info: Table,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let model_customization = if let Some(mc) = ci.get::<Option<Table>>("model_customization")? {
|
let get_bool = |table: &Table, name| table.get(name).unwrap_or(true);
|
||||||
ModelCustomization {
|
|
||||||
cape: mc.get("cape")?,
|
|
||||||
jacket: mc.get("jacket")?,
|
|
||||||
left_sleeve: mc.get("left_sleeve")?,
|
|
||||||
right_sleeve: mc.get("right_sleeve")?,
|
|
||||||
left_pants: mc.get("left_pants")?,
|
|
||||||
right_pants: mc.get("right_pants")?,
|
|
||||||
hat: mc.get("hat")?,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ModelCustomization::default()
|
|
||||||
};
|
|
||||||
if let Err(error) = client
|
if let Err(error) = client
|
||||||
.set_client_information(ClientInformation {
|
.set_client_information(ClientInformation {
|
||||||
allows_listing: ci.get("allows_listing")?,
|
allows_listing: info.get("allows_listing")?,
|
||||||
model_customization,
|
model_customization: info
|
||||||
view_distance: ci.get("view_distance").unwrap_or(8),
|
.get::<Table>("model_customization")
|
||||||
|
.map(|t| ModelCustomization {
|
||||||
|
cape: get_bool(&t, "cape"),
|
||||||
|
jacket: get_bool(&t, "jacket"),
|
||||||
|
left_sleeve: get_bool(&t, "left_sleeve"),
|
||||||
|
right_sleeve: get_bool(&t, "right_sleeve"),
|
||||||
|
left_pants: get_bool(&t, "left_pants"),
|
||||||
|
right_pants: get_bool(&t, "right_pants"),
|
||||||
|
hat: get_bool(&t, "hat"),
|
||||||
|
})
|
||||||
|
.unwrap_or_default(),
|
||||||
|
view_distance: info.get("view_distance").unwrap_or(8),
|
||||||
..ClientInformation::default()
|
..ClientInformation::default()
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
Loading…
x
Reference in New Issue
Block a user