Skip to content

PlaceholderAPI 占位符 ​

EmakiAttribute 提供的占位符与伤害消息模板可用的变量如下

前置条件: 服务器已安装 PlaceholderAPI. 满足后 EmakiAttribute 会自动注册占位符扩展, 向计分板, 聊天, 菜单, Hologram 或其他插件暴露玩家属性和资源数据

扩展标识符 ​

text
emakiattribute

所有占位符格式为 %emakiattribute_<key>%

属性值占位符 ​

基础格式 ​

text
%emakiattribute_<attribute_id>%

返回玩家当前战斗快照中该属性的数值, 最多保留 2 位小数 (如 15.5, 100). 属性不存在时返回 0

示例 ​

占位符说明
%emakiattribute_physical_attack%物理攻击值
%emakiattribute_physical_defense%物理防御值
%emakiattribute_physical_crit_rate%物理暴击率
%emakiattribute_physical_crit_damage%物理暴击伤害
%emakiattribute_spell_attack%法术攻击值
%emakiattribute_dodge_chance%闪避率
%emakiattribute_lifesteal%吸血比例

战力占位符 ​

text
%emakiattribute_power%
%emakiattribute_attribute_power%

返回玩家当前的属性战力总和 (按各属性的 attribute_power 权重与 attribute_balance.yml 中的分数计算). power 会被规范化为属性 ID attribute_power, 两种写法等价

资源占位符 ​

基础格式 ​

text
%emakiattribute_resource_<resource_id>%
%emakiattribute_resource_<resource_id>_<field>%

不指定 field 时默认返回 current (当前值)

field 可选值 ​

field说明示例返回
current当前值 (默认)85
max当前最大值 (含加成)120
default默认最大值 (不含加成)100
bonus加成最大值20
percent当前值占最大值的百分比 (0–100)70
regen每秒回复速率2.5

示例 ​

占位符说明
%emakiattribute_resource_health%当前生命值
%emakiattribute_resource_health_max%最大生命值
%emakiattribute_resource_health_percent%生命百分比
%emakiattribute_resource_mana%当前法力值
%emakiattribute_resource_mana_max%最大法力值
%emakiattribute_resource_mana_percent%法力百分比

常见用途 ​

计分板 ​

yaml
# Scoreboard 配置示例
lines:
  - '&c❤ %emakiattribute_resource_health%/%emakiattribute_resource_health_max%'
  - '&b✦ %emakiattribute_resource_mana%/%emakiattribute_resource_mana_max%'
  - '&e⚔ 攻击:%emakiattribute_physical_attack%'
  - '&a🛡 防御:%emakiattribute_physical_defense%'

条件系统 ​

在 CoreLib 条件表达式里直接使用 PAPI 占位符:

yaml
condition:
  entries:
    - '%emakiattribute_physical_attack% >= 100'
    - '%emakiattribute_resource_mana_percent% >= 50'

技能门槛 ​

在 EmakiSkills 条件中检查属性:

yaml
condition:
  entries:
    - '%emakiattribute_physical_attack% >= 200'

展示建议 ​

  • 百分比属性统一显示格式, 例如保留 1 位小数
  • 资源显示建议用 当前 / 最大 格式
  • 高频刷新场景 (如 ActionBar, BossBar) 不要放太多复杂占位符
  • 面向玩家的占位符和面向管理员的 debug 占位符分开使用
  • 占位符返回的是数字字符串, 不带颜色代码, 可以直接用于数值比较

伤害消息模板变量 ​

伤害类型配置的 attacker_message / target_message 中可使用 %variable% 格式的模板变量

实体信息 ​

变量说明示例
%attacker% / %attacker_name% / %source% / %source_name%攻击者显示名Steve
%attacker_type% / %source_type%攻击者实体类型PLAYER
%attacker_uuid% / %source_uuid%攻击者 UUID550e8400-...
%attacker_health%攻击者当前血量18.5
%attacker_max_health%攻击者最大血量20
%target% / %target_name%目标显示名Zombie
%target_type%目标实体类型ZOMBIE
%target_uuid%目标 UUID...
%target_health%目标当前血量12.3
%target_max_health%目标最大血量40
%distance%攻击者与目标之间的距离5.2

伤害信息 ​

变量说明示例
%damage_type% / %damage_type_name%伤害类型显示名物理伤害
%damage_type_id%伤害类型 IDphysical
%source_damage% / %input_damage%原始伤害值25
%base_damage%基础伤害值20
%final_damage% / %damage%最终伤害值15.5
%cause% / %damage_cause%伤害原因名ENTITY_ATTACK
%cause_name% / %damage_cause_name%伤害原因本地化名攻击
%cause_id% / %damage_cause_id%伤害原因规范化 IDentity_attack
%critical%是否暴击true
%critical_text%暴击文本 (非暴击为空)暴击
%critical_suffix%暴击后缀 (非暴击为空) <red>暴击</red>
%roll%暴击判定骰值0.85

模板示例 ​

yaml
damage_types:
  physical:
    attacker_message: "<gray>[战斗] 你对 %target_name% 造成了 <red>%final_damage%</red> 点伤害%critical_suffix% <gray>(距离: %distance%m)"
    target_message: "<gray>[战斗] %attacker_name% 对你造成了 <red>%final_damage%</red> 点伤害%critical_suffix% <gray>(剩余: %target_health%/%target_max_health%)"