PlaceholderAPI 占位符
安装 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_rate% | 闪避率 |
%emakiattribute_lifesteal% | 吸血比例 |
战力占位符
text
%emakiattribute_power%返回玩家当前属性战力总和(基于各属性的 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
conditions:
- '%emakiattribute_physical_attack% >= 100'
- '%emakiattribute_resource_mana_percent% >= 50'技能门槛
在 EmakiSkills 条件中检查属性:
yaml
conditions:
- '%emakiattribute_physical_attack% >= 200'展示建议
- 百分比属性统一显示格式,例如保留 1 位小数。
- 资源显示建议使用
当前 / 最大格式。 - 高频刷新场景(如 ActionBar、BossBar)不要放太多复杂占位符。
- 面向玩家的占位符和面向管理员的 debug 占位符分开使用。
- 占位符返回的是数字字符串,不包含颜色代码,可以直接用于数值比较。
伤害消息模板变量
在伤害类型配置的 attacker_message / target_message 中,可使用 %variable% 格式的模板变量。
实体信息
| 变量 | 说明 | 示例 |
|---|---|---|
%attacker% / %attacker_name% | 攻击者显示名。 | Steve |
%attacker_type% | 攻击者实体类型。 | PLAYER |
%attacker_uuid% | 攻击者 UUID。 | 550e8400-... |
%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% | 伤害类型 ID。 | physical |
%source_damage% / %input_damage% | 原始伤害值。 | 25 |
%base_damage% | 基础伤害值。 | 20 |
%final_damage% / %damage% | 最终伤害值。 | 15.5 |
%cause% / %damage_cause% | 伤害原因名。 | ENTITY_ATTACK |
%cause_name% / %damage_cause_name% | 伤害原因本地化名。 | 攻击 |
%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%)"