☄️
Code
  • 🌍新授权系统
    • ☁️云端插件使用说明
    • ⏳授权时效说明
    • ⚙️授权数据迁移
    • 🐟授权摸鱼模式
    • ❌旧授权系统
    • ⁉️常见问题
  • 🌏知识星球
  • JobFrame
    • 👾Job Frame
      • 插件配置
      • 插件命令
      • 插件兼容
        • DungeonPlus
        • HolographicDisplays
        • Chemdah
        • GermPlugin
        • DragonCore
      • 工作组
        • 对象持续交互模块
        • 对象生成模块
        • 对象初始化模块
        • 对象实体&方块类型
      • 工作对象
        • 对象占位符
          • Player
          • Object
          • Content
          • Random
          • Time
        • 对象动作脚本
          • Script
          • Object
          • Player
          • Item
          • Persistent
          • Step
          • Particle
          • Visible
          • Entity
          • Block
          • Hologram
          • Task
          • Data
          • Temp-Data
          • Germ
          • Dragon
      • 刷新点
      • 插件示例&视频
        • 最基础的示例
        • 草药采集示例
        • 普通的宝箱示例
        • 循环的宝箱示例
        • 体力系统的宝箱示例
        • 蓝水晶矿示例 (过时)
        • 训练史莱姆示例 (过时)
      • 更新记录 (记录不及时)
        • 1.2.1
        • 1.1.0
        • 1.1.9
        • 1.0.9
        • 1.0.8
        • 1.0.7
        • 1.0.6
  • CraftFrame
    • 🌠Craft Frame
      • 插件视频
      • 插件命令
        • Craft 命令
      • 工艺动作组
        • Data Action
        • System Action
        • Describe Action
        • Quality Action
        • Amount Action
        • Name Action
        • Type Action
        • Score Action
        • Nbt Action
      • 工艺占位符
        • Data
        • Score
        • Quality
        • Random
        • Content
        • Describe
        • Material-Data
        • Material-Central
      • 工艺界面
        • Class (分类界面配置)
        • Interface (制作界面配置)
      • 工艺图纸 (主配置)
        • 自定义动作组
        • 工艺阶段
      • 工艺交互按钮
      • 工艺示例配置
        • 锻造示例
        • 强化示例
        • 炼药示例
        • 重铸示例
        • 继承示例
      • 更新记录 (记录不及时)
        • 1.0.8
        • 1.0.6
        • 1.0.5
        • 1.0.4
        • 1.0.3
        • 1.0.2
        • 1.0.1
      • 常见问题
  • Item Extension
    • 💎Item Extension
      • 插件命令
      • 插件兼容
      • 扩展语句
      • 扩展技能
      • 扩展道具
      • 扩展界面
      • 扩展示例
        • 装备附魔
        • 装备宝石
        • 装备赋能
      • 开发文档
      • 更新记录
  • StallMatket
    • 📦Stall Market
      • 插件视频
      • 插件配置
        • Layout (界面布局)
        • Currency (交易货币)
      • 插件命令
        • Stall 命令
        • Request 命令
      • 摊位等级
      • 摆摊区域
      • 数据同步
  • AttributeInventory
    • 🥋Attribute Inventory
      • 插件配置
      • 插件命令
      • 背包组
      • 背包套装
      • 开发兼容
        • 属性兼容
        • 获取装备
        • API
  • RefinePlus
    • 🔮Refine Plus
      • 洗练界面
      • 洗练项目
      • 洗练道具
      • 更新记录
        • 1.0.1
        • 1.0.2
        • 1.0.3
  • TalentAttribute
    • 📕Talent Attribute
      • 插件配置
      • 插件命令
      • 插件变量
      • 天赋界面
        • 天赋页物品
        • 天赋页布局
        • 天赋项
由 GitBook 提供支持
在本页
  • AttributeHandler
  • AttributePlus V3 例子
  1. AttributeInventory
  2. Attribute Inventory
  3. 开发兼容

属性兼容

AttributeHandler

interface AttributeHandler {

    //自定义属性处理名
    val name: String

    //是否为主控属性兼容 (如果是兼容主控属性,这里设为TRUE)
    //整个插件只会注册一个主控属性
    val mainAttributeHook: Boolean

    //注册条件 (一般用于兼容不同属性插件版本的条件判断)
    fun registerCondition(): Boolean

    //通过物品列表为玩家增加属性
    fun addSourceAttribute(player: Player, source: String, items: List<ItemStack>)

    //通过属性列表为玩家增加属性
    fun addSourceAttributeFromList(player: Player, source: String, attributes: List<String>)

    //通过 source 删除增加的属性
    fun deleteSourceAttribute(player: Player, source: String)
    
}

实现 AttributeHandler 内的所有方法后,你需要再 onEnable 处使用 register() 方法注册该属性处理,并将你的插件依赖设置新增 AttributeInventory

AttributePlus V3 例子

下面是 AttributePlus V3 的兼容例子,大致如下

package org.serverct.nanmui.inventory.common.api.attribute.impl

import org.bukkit.Bukkit
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import org.serverct.ersha.api.AttributeAPI
import org.serverct.ersha.attribute.data.AttributeSource
import org.serverct.nanmui.inventory.common.api.IInventoryPage
import org.serverct.nanmui.inventory.common.api.InventoryAPI
import org.serverct.nanmui.inventory.common.api.attribute.AttributeHandler

class AttributePlusV3 : AttributeHandler {

    override val name: String = "AttributePlus_v3"

    override val mainAttributeHook: Boolean = true

    override fun registerCondition(): Boolean {
        val plugin = Bukkit.getPluginManager().getPlugin("AttributePlus")
        if (plugin != null) {
            val description = plugin.description
            if (description.version.first() == '3') {
                return true
            }
        }
        return false
    }

    override fun addSourceAttribute(player: Player, source: String, items: List<ItemStack>) {
        val data = AttributeAPI.getAttrData(player)
        val attributeSource = AttributeSource().apply {
            items.forEach { item ->
                val attribute = AttributeSource(player, item)
                this.merge(attribute)
            }
        }

        AttributeAPI.addSourceAttribute(data, source, attributeSource)
    }

    override fun addSourceAttributeFromList(player: Player, source: String, attributes: List<String>) {
        val data = AttributeAPI.getAttrData(player)
        AttributeAPI.addSourceAttribute(data, source, attributes)
    }

    override fun deleteSourceAttribute(player: Player, source: String) {
        val data = AttributeAPI.getAttrData(player)
        AttributeAPI.takeSourceAttribute(data, source)
    }
}
上一页开发兼容下一页获取装备

最后更新于2年前

🥋