🥋
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 提供支持
在本页
  • 跟 DescriptionRead 有什么区别呢?
  • 示例

这有帮助吗?

  1. 开发文档

EmbeddedCondition

内嵌式条件

上一页CustomTriggerComponent下一页ReadComponent

最后更新于6个月前

这有帮助吗?

跟 DescriptionRead 有什么区别呢?

DescriptionRead 无法做到单独新增一个 内嵌式条件 必须同时覆写 read 与 condition 才能做到,这相当于需要完全重写一个读取组件 具体读取格式请查看

/**
 * 单行描述条件
 * 格式 "属性名: 值 / <条件>" 如果满足该行条件才会读取该行描述属性
 * 
 * 如何注册? : 使用 @AutoRegister 进行注册
 */
interface DescriptionLineCondition : DescriptionComponent {

    /**
     * [entity] 可为空需要自行判断
     * [text] 为 "<属性内容> / <条件>" 中的 <条件> 内容
     * 返回值为 true 时则读取属性,为 false 时则不读取
     */
    fun condition(entity: LivingEntity?, text: String): Boolean
    
    fun condition(entity: LivingEntity?, text: String, slot: EquipmentSlot?): Boolean{
        return this.condition(entity, lore)
    }
    
    fun condition(entity: LivingEntity?, text: String, slot: EquipmentSlot?, item: ItemStack?): Boolean {
        return this.condition(entity, lore, slot)
    }
}

示例

@AutoRegister
class LineCondition : DescriptionLineCondition {

    override fun condition(entity: LivingEntity?, lore: String): Boolean {
        if (entity == null){
            return true
        } else {
            if (entity is Player){
                if (lore.contains("等级要求-")) {
                    val value = lore.split("等级要求-")[1]
                    return entity.level >= value.toInt()
                }
            }
            return true
        }
    }
}

以上示例在实际使用中格式是 "物理伤害: 1000 / 等级要求-100" 等级大于等于 100 时就会激活该行属性,增加 1000 点物理伤害 条件只能写在 " / " 右边

属性内嵌条件格式