预设基类
scripts/libs/ 目录下提供了一系列抽象基类,用于简化 Groovy 脚本的开发。它们封装了与 Kotlin 核心类的交互细节,让开发者只需关注业务逻辑。
基类列表
| 基类 | 用途 | 文档 |
|---|---|---|
GroovyAttribute | 属性系统基类 | 文档 |
GroovyConditionReader | 条件读取器基类 | 文档 |
GroovyValueReader | 数值读取器基类 | 文档 |
GroovyMappingReader | 映射读取器基类 | 文档 |
GroovyEffect | 视觉效果基类 | 文档 |
使用方式
所有基类都在 scripts/libs 包下,使用时直接继承:
Groovy
// 继承 GroovyAttribute 创建属性
package scripts.attributes
import scripts.libs.GroovyAttribute
class MyAttribute extends GroovyAttribute {
MyAttribute() {
super(AttributeTypes.ATTACK_AND_DEFENSE, "my_attr", "我的属性", 1, 1.0, -1)
}
// ...
}其他库
libs 目录下还包含:
AttributeName.groovy— 属性名枚举类,统一管理属性的 id、name、priority、power、maxUtils.groovy— 工具类,提供了chance()、registerDefaultAttribute()等便捷方法Utils.js— JavaScript 版工具函数
