🥋
AttributePlus - Pro
  • AttributePlus
  • 插件相关
    • 高版本物品问题
    • 配置
      • attribute.yml
      • stats.yml
      • script.yml
    • 语言
  • 属性相关
    • 优先级 / 战斗力 / 公式 / 消息
    • MythicMobs 属性相关
  • 读取相关
    • 过滤符相关
    • 装备条件标签
    • NBT属性加载
    • 自定义条件标签
    • 新读取格式相关 (>=3.3.0.7)
    • 旧读取格式相关 (<=3.3.0.6)
    • 属性内嵌条件格式
    • 属性百分比读取格式
  • 机制相关
    • 蓄力机制
    • 盾牌机制
    • 弓箭机制
    • 召唤机制
  • 属性脚本
    • 属性类型
    • 脚本教学
      • RUNTIME 类型
      • UPDATE 类型
      • CUSTOM 类型
      • KILLER 类型
      • 延迟触发任务
    • 脚本方法
    • 常见问题
  • 开发文档
    • API
    • Counter 计数器
    • AttributeComponent
      • AttributeType
      • Example
      • AttributeName
    • CustomTriggerComponent
    • EmbeddedCondition
    • ReadComponent
      • 教学
  • 更新记录
由 GitBook 提供支持
在本页
  • 读取类型
  • 读取优先级

这有帮助吗?

  1. 开发文档

ReadComponent

请继承 DescriptionRead 类注册组件

public DescriptionRead(DescriptionRead.ReadPriority priority, DescriptionRead.AttributeReadType type, Boolean filterColor)

//请继承 DescriptionRead 类注册组件
interface ReadComponent {

    //读取优先级
    val priority: DescriptionRead.ReadPriority
    //读取类型
    val type: DescriptionRead.AttributeReadType
    //是否过滤掉颜色代码
    val filterColor: Boolean

    /**
     * 属性数据读取
     * [key] 读取的标签
     * [lore] 需要读取数据的描述
     *
     * 通过自己的方式将 [key] 的内容读取为属性数据 Array<Number>
     * [lore] 一定包含 [key] 属性标签,所以不需要去 lore.contains(attributeName) 了
     */
    fun read(key: String, lore: String): Array<Number>

    /**
    * 作用与 read(key: String, lore: String) 相同
    */
    fun read(key: String, lore: String, source: AttributeSource): Array<Number>

    /**
     * 条件判断
     * [entity] 实体
     * [lore] 需要读取数据的描述
     *
     * 如果条件不满足,那么将不会执行 read 方法
     */
    fun condition(entity: LivingEntity, lore: String): Boolean

    /**
     * 作用与 condition(entity: LivingEntity, lore: String) 相同
     */
    fun condition(entity: LivingEntity, lore: String, source: AttributeSource): Boolean

    /**
     * 注册组件
     *
     * @AutoRegister 请使用自动注册注释注册
     */
    fun register()

    /**
     * 注销组件
     */
    fun unregister()
}

读取类型

/**
 * VALUE -> 该类型会执行 read 与 condition 方法
 * BOOLEAN -> 该类型只执行 condition 方法
 * RUNTIME -> 该类型与 VALUE 相同,但返回的值不会计入属性
 */
enum class AttributeReadType {
    VALUE, BOOLEAN, RUNTIME
}

读取优先级

/**
 * 优先执行 BEFORE 的读取组件
 * AFTER 所有组件是在 BEFORE 所有组件处理完后才执行
 */
enum class ReadPriority {
    BEFORE, AFTER
}
上一页EmbeddedCondition下一页教学

最后更新于4年前

这有帮助吗?