KubeJS Figura
This mod serves as a lightweight bridge between KubeJS and Figura, providing access to core Figura avatar functions directly from KubeJS scripts. The solution is designed for minimal impact on the game environment while offering a secure method for working with avatars through server scripts.
For security reasons, the module can only load avatar models that already exist in the player's avatar folder. This functionality is primarily aimed at automated character systems implemented on the server side, allowing developers to easily integrate Figura's capabilities into their projects.

Usage Example
The code below demonstrates the implementation of server commands for working with Figura avatars:
// Example of KubeJS Figura usage in a server script
const StringArgumentType = Java.loadClass("com.mojang.brigadier.arguments.StringArgumentType");
const ServerPlayer = Java.loadClass("net.minecraft.server.level.ServerPlayer");
const KJSFigura = Java.loadClass("com.confect1on.kubejs_figura.KubeJSFiguraMod");
ServerEvents.commandRegistry(event => {
const { commands: Commands } = event;
// Command for loading an avatar
event.register(
Commands.literal("figuraLoad")
.then(
Commands.argument("model", StringArgumentType.greedyString())
.executes(ctx => {
const player = ctx.source.entity;
const model = StringArgumentType.getString(ctx, "model");
if (player instanceof ServerPlayer) {
KJSFigura.load(player, model);
}
return 1;
})
)
);
// Command for uploading an avatar to the system
event.register(
Commands.literal("figuraUpload")
.executes(ctx => {
const player = ctx.source.entity;
if (player instanceof ServerPlayer) {
KJSFigura.upload(player);
}
return 1;
})
);
// Command for managing an avatar
event.register(
Commands.literal("figuraHandle")
.then(
Commands.argument("charName", StringArgumentType.greedyString())
.executes(ctx => {
const player = ctx.source.entity;
const charName = StringArgumentType.getString(ctx, "charName");
if (player instanceof ServerPlayer) {
KJSFigura.handle(player, charName, false);
}
return 1;
})
)
);
});