1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add slot renaming op code support to fix #24

This commit is contained in:
NG (Graham)
2025-05-31 15:36:33 -04:00
parent 299c15c6da
commit f117fd3d2a
4 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
use polariton_server::operations::{SimpleOpError, SimpleOperation, SimpleOpImpl};
use polariton::operation::{ParameterTable, Typed};
const CODE: u8 = 46;
const SLOT_PARAM_KEY: u8 = 45; // int; in
const NAME_PARAM_KEY: u8 = 42; // str; in
pub(super) struct GarageSlotRenamer;
#[async_trait::async_trait]
impl <C: Send + 'static> SimpleOperation<C> for GarageSlotRenamer {
type User = crate::UserTy;
const CODE: u8 = CODE;
async fn handle(&self, params: ParameterTable<C>, user: &Self::User) -> Result<ParameterTable<C>, SimpleOpError> {
let mut params = params.to_dict();
if let Some(Typed::Int(slot)) = params.remove(&SLOT_PARAM_KEY) {
if let Some(Typed::Str(name)) = params.remove(&NAME_PARAM_KEY) {
let user_info = user.user()?;
user_info.set_slot_name(slot, name.string).await?;
}
}
Ok(params.into())
}
}
pub(super) fn garage_slot_rename_provider<C: Send + 'static>() -> SimpleOpImpl<C, crate::UserTy, GarageSlotRenamer> {
SimpleOpImpl::new(GarageSlotRenamer)
}

View File

@@ -95,6 +95,7 @@ mod avatar_set_custom;
mod avatar_set;
mod garage_slot_controls;
mod garage_slot_set_customisations;
mod garage_slot_name;
use polariton_server::operations::OperationsHandler;
@@ -213,4 +214,5 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
.add(avatar_set::avatar_set_provider())
.add(garage_slot_controls::garage_slot_controls_provider())
.add(garage_slot_set_customisations::garage_slot_customisation_provider())
.add(garage_slot_name::garage_slot_rename_provider())
}