Skip to content

预设基类

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、max
  • Utils.groovy — 工具类,提供了 chance()registerDefaultAttribute() 等便捷方法
  • Utils.js — JavaScript 版工具函数