Mosaic FrameworkMosaic Framework
指南
API参考
插件开发
示例
GitHub
指南
API参考
插件开发
示例
GitHub
  • 指南

    • 指南
    • 快速开始
    • 核心概念
    • 配置
    • 事件系统

配置

读取配置

插件可通过 CubeApi.getCubeConfig() 获取配置:

import io.github.tml.mosaic.cube.CubeConfig;
import io.github.tml.mosaic.cube.external.MosaicCube;

public class MyCube extends MosaicCube {
    @Override
    public boolean init() {
        CubeConfig cfg = getCubeConfig();
        String model = cfg.getConfig("model", String.class, "gpt-3.5-turbo");
        Integer timeout = cfg.getConfig("timeout", Integer.class, 30);
        return true;
    }
}

CubeConfig 支持:

  • getConfig(name, type)
  • getConfig(name, type, defaultValue)
  • getAllConfigs()

scope 与实例化

  • scope=singleton:已存在实例时复用;
  • scope=property:存在实例时先 destroy 再重建,适合多实例/按配置隔离。

configId

  • Slot.SetupCubeInfo.configId 用于按配置隔离检索 Cube 实例(同一 cubeId 可有多份实例,每份绑定不同配置)。
最近更新: 2025/8/14 16:51
Contributors: SeasonsChange
Prev
核心概念
Next
事件系统