FileAPI
通过 FileAPI.API 访问。允许外部插件以编程方式导入方块交互配置,无需手动编辑 KetherModulesLite 的配置文件。
导入方法
破坏方块交互
| 方法签名 | 说明 |
|---|---|
importBreakBlock(source: String, block: String, action: String) | 导入破坏方块交互配置 |
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
source | String | 来源标识(用于后续清除) |
block | String | 方块类型(如 STONE) |
action | String | 触发时执行的 Kether 脚本 |
FileAPI.API.importBreakBlock("my_plugin", "DIAMOND_ORE", "tell &a你挖到了钻石矿!")
点击方块交互
| 方法签名 | 说明 |
|---|---|
importClickBlock(source: String, type: ClickBlockType, block: String, config: Configuration) | 导入点击方块交互配置 |
ClickBlockType 枚举:
| 值 | 说明 |
|---|---|
LEFT | 左键点击 |
RIGHT | 右键点击 |
ALL | 任意点击 |
import kim.hhhhhy.kethermodule.api.FileAPI
import kim.hhhhhy.kethermodule.api.FileAPI.ClickBlockType
FileAPI.API.importClickBlock(
"my_plugin",
ClickBlockType.RIGHT,
"CHEST",
config // Configuration 对象,包含交互逻辑
)
站立方块交互
| 方法签名 | 说明 |
|---|---|
importOnBlock(source: String, type: OnBlockType, block: String, config: Configuration) | 导入站立方块交互配置 |
OnBlockType 枚举:
| 值 | 说明 |
|---|---|
ON | 站在方块上 |
IN | 站在方块内 |
import kim.hhhhhy.kethermodule.api.FileAPI
import kim.hhhhhy.kethermodule.api.FileAPI.OnBlockType
FileAPI.API.importOnBlock(
"my_plugin",
OnBlockType.ON,
"GOLD_BLOCK",
config
)
清除方法
按来源标识批量清除已导入的配置。
| 方法签名 | 说明 |
|---|---|
clearBreakBlock(source: String) | 清除指定来源的所有破坏方块交互 |
clearClickBlock(source: String, type: ClickBlockType) | 清除指定来源和类型的点击方块交互 |
clearOnBlock(source: String, type: OnBlockType) | 清除指定来源和类型的站立方块交互 |
// 插件卸载时清除所有已注册的交互
FileAPI.API.clearBreakBlock("my_plugin")
FileAPI.API.clearClickBlock("my_plugin", ClickBlockType.RIGHT)
FileAPI.API.clearOnBlock("my_plugin", OnBlockType.ON)
提示
建议在插件 onDisable() 中调用对应的 clear 方法,避免残留配置。