### Counter Usage Example in JavaScript Source: https://ersha.gitbook.io/attributeplus-pro/kai-fa-wen-dang/api-1 Demonstrates how to use the counter functionality within a JavaScript environment, specifically for a 'KILLER' script type. It shows how to get the counter object, update its value, and check conditions based on the counter's state. ```javascript var priority = 1 var combatPower = 1.0 var attributeName = "KILLER_ATTRIBUTE" var attributeType = "KILLER" var placeholder = "KILLER_ATTRIBUTE" function onLoad(attr){ return attr } function runKiller(attr, killer, entity, handle) { //获取击杀者的 AttributeData 对象 var data = attr.getData(killer, handle) //获取创建一个名为 reaper_count 的计算,重置类型为 DEATH 死亡时重置 var counter = data.counter.getCounter("reaper_count", "DEATH") //更新计数器值 +1 默认值为 0 var value = counter.updateValue(1, 0) //判断计数器计数值是否大于等于 3 次 if (value >= 3) { //重置计数器值 counter.resetValue() killer.sendMessage("§a§lKILLER_ATTRIBUTE 触发") } else { killer.sendMessage("§a§lKILLER_ATTRIBUTE §f§l" + value + "/3") } } ``` -------------------------------- ### Attribute Script - New Format Example Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu Shows an example of an attribute script written in the new format introduced in version 3.3.1.0. This demonstrates the updated syntax, including the use of method parameters instead of the `Attr` placeholder for the attribute object. ```javascript function onLoad(attr) { // New script content } function run(attr, entity) { // New script content } ``` -------------------------------- ### Attribute Script - Old Format Example Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu Presents an example of an attribute script written in the older format before version 3.3.1.0. This illustrates the previous syntax and structure that needed to be updated to the new format. ```javascript function onLoad() { // Old script content } function run(entity) { // Old script content } ``` -------------------------------- ### MythicMobs Skill Trigger Example Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu Demonstrates how to use the `~onSignal:AttributePlus` trigger in MythicMobs skills to activate when a player damages an entity. This allows skills to react to attribute-related events and access trigger values via placeholders in the `attributes.yml` configuration. ```yml ~onSignal:AttributePlus ``` -------------------------------- ### Configure Custom Condition Tag (YAML) Source: https://ersha.gitbook.io/attributeplus-pro/du-qu-xiang-guan/zi-ding-yi-tiao-jian-biao-qian Example configuration for a custom condition tag named '战力要求' (Combat Power Requirement). This demonstrates how to define the key, parsing formats, value extraction placeholders, condition logic using Kether syntax, and a custom message for when the condition is not met. It also shows how to register custom variables. ```yaml #自定义规则标签 custom-condition-component: example: #添加至物品的标签 key: "战力要求" #读取格式 formats: - "{key}.*?@value" #{value_0-N} 代表获取到的值(未处理过的数据) #{value_min_0-N} 表示获取到的最小值 #{value_max_0-N} 表示获取到的最大值,如果非范围值格式则返回 none #{..._0-N} 0-N 每个对应上方 formats 配置的 @value 或 (.*?) conditions: - check '%ap_combatPower%' >= {value_min_0} - any [ check '{value_max_0}' == 'none' check '%ap_combatPower%' <= {value_max_0} ] #不满足时的提示 message: "&f你不满足 &6{item_name} &f物品的使用战力要求" #如果 custom-condition-component 配置项内,使用 AttributePlus 自带的变量时,需将变量配置进来 cache-placeholder: #- "attack" - "combatPower" ``` -------------------------------- ### Kotlin Implementation of DescriptionLineCondition for Level Requirements Source: https://ersha.gitbook.io/attributeplus-pro/kai-fa-wen-dang/descriptionlinecondition-1 Provides a concrete implementation of the `DescriptionLineCondition` interface in Kotlin. This example demonstrates how to register a custom condition using `@AutoRegister`. The `condition` method checks if the description text contains a level requirement and if the player's level meets that requirement, allowing for dynamic attribute display based on player level. ```kotlin @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 } } } ``` -------------------------------- ### Attribute Script Method Signature Changes Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu Details the updated method signatures for attribute registration and custom script properties in version 3.3.1.0. The `handle(AttributeHandle)` object parameter is now required, affecting older scripts. Examples show the transition from old to new signatures for `run`, `runAttack`, and `runDefense` methods. ```java // Old signature run(attr, entity) // New signature run(attr, entity, handle) // Old signature runAttack(attr, attacker, entity) // New signature runAttack(attr, attacker, entity, handle) // Old signature runDefense(attr, entity, killer) // New signature runDefense(attr, entity, killer, handle) ``` -------------------------------- ### Custom Trigger Registration Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu Allows developers to register custom triggers by implementing the `CustomTriggerComponent` interface in Kotlin. Provides a code example for registering a 'SKILL CAST' trigger. ```APIDOC ## Custom Trigger Registration (Kotlin) ### Description Enables developers to extend the trigger system by creating their own trigger components using the `CustomTriggerComponent` interface. ### Method Kotlin Class Implementation ### Endpoint N/A (Code implementation) ### Parameters #### `CustomTriggerComponent` Interface - **name** (String) - The unique name of the trigger. - **event** (Class) - The specific event class this trigger listens to. - **priority** (EventPriority) - The priority of the event listener. - **ignoreCancelled** (Boolean) - Whether to ignore cancelled events. - **condition(event: E)** (Boolean) - Optional condition to check before triggering. - **caster(event: E)** (LivingEntity) - Determines the caster entity from the event. - **target(event: E)** (LivingEntity?) - Determines the target entity from the event (optional). - **params(event: E)** (Array) - Provides additional parameters from the event. - **register()**: Calls `attributeManager.registerTrigger(this)` to register the component. ### Request Example (Kotlin) ```kotlin class SkillCastAttributeTrigger : CustomTriggerComponent { override val name: String = "SKILL CAST" override val event: Class = PlayerCastSkillEvent::class.java override val priority: EventPriority = EventPriority.NORMAL override val ignoreCancelled: Boolean = false override fun caster(event: PlayerCastSkillEvent): LivingEntity { return event.player } override fun params(event: PlayerCastSkillEvent): Array { val skillName = event.skill.data.name return arrayOf(skillName) } } // To register: SkillCastAttributeTrigger().register() ``` ### Response N/A (Code implementation) ``` -------------------------------- ### Get Counter Object in Java Source: https://ersha.gitbook.io/attributeplus-pro/kai-fa-wen-dang/api-1 Retrieves the main counter control object from an AttributeData instance. This object is required to interact with counter functionalities. ```java AttributeData data = ... data.getCounter() //主控对象 ``` -------------------------------- ### Configure Attribute Hint Messages in YAML Source: https://ersha.gitbook.io/attributeplus-pro/shu-xing-xiang-guan/you-xian-ji This YAML block configures the hint messages displayed for attribute events. You can define custom messages using variables like {entity}, {attackerDamage}, and attribute-specific placeholders (e.g., {attack}). Messages can be tailored for different attribute types, excluding 'other' types. Changes take effect after '/ap reload'. ```yaml # 消息 message: # 变量说明 #{attacker} 攻击者名称 #{entity} 被攻击者名称 #{attackerDamage} 此次事件 被攻击者 所受最终伤害 #{entityDamage} 此次事件 攻击者 所受最终伤害(例如反弹伤害) #{属性变量} 此次事件该属性所造成的属性值 (例 {attack}) attack: - "对 {entityB} 造成 {attackerDamage} 点伤害,穿透伤害 {see_through}" - "{entityA} 对你造成 {attackerDamage} 点伤害" # 特别提醒: # 除 other 类属性外的所有属性点支持在这增加提示消息 # 节点名格式固定为属性变量名,例如 # armor: # - "对方抵消了你百分之 {armor} 点伤害!" # - "你抵消了对方百分之 {armor} 点伤害!" ``` -------------------------------- ### Configure Combat Power Calculation in YAML Source: https://ersha.gitbook.io/attributeplus-pro/shu-xing-xiang-guan/you-xian-ji This YAML configuration defines how combat power is calculated for various attribute types. Modifying these values allows you to customize the combat power score associated with attributes. The player's current attribute combat power can be displayed using the %ap_combatPower% variable after configuration. ```yaml # 战斗力 combatPower: attackOrDefense: attack: 1.0 update: [] runtime: [] other: [] ``` -------------------------------- ### Customize Attribute Formulas in YAML Source: https://ersha.gitbook.io/attributeplus-pro/shu-xing-xiang-guan/you-xian-ji This YAML section allows you to define custom formulas for attributes that support them. Formulas use placeholders like {attackerAttack}, {entityA:AttributeName}, and {value} to reference dynamic data, enabling complex attribute calculations. Not all attributes support custom formulas; this is determined during attribute development. Apply changes with '/ap reload'. ```yaml # 属性公式 #{attackerAttack} 当前 被攻击者 所受伤害(受优先级影响) #{entityAttack} 当前 攻击者 所受伤害(受优先级影响)(例如反弹伤害) #{value} 取得对应属性值 #{entityA:属性名} 取得攻击者的对应属性值 #{entityB:属性名} 取得被攻击者的对应属性值 formula: crit: "{attackerAttack}*{entityA:暴击倍率}/100" ``` -------------------------------- ### Entity Attribute Data Timestamps Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu Illustrates how to retrieve timestamp data from an entity's `AttributeData` object. This includes methods to get the last attack time, last defense time, and the current timestamp, enabling calculation of time intervals between events. ```java data.getLastAttack() data.getLastDefense() data.getCurrentTime() ``` -------------------------------- ### Configure Attribute Priority in YAML Source: https://ersha.gitbook.io/attributeplus-pro/shu-xing-xiang-guan/you-xian-ji This YAML snippet shows how to set the execution priority for different attribute types like attack, defense, and updates. Priority values determine the order of attribute processing, with lower numbers indicating higher priority. Ensure priorities are unique to avoid automatic adjustments. This configuration is crucial for controlling the flow of attribute effects. ```yaml # 优先级 priority: attackOrDefense: # 如果闪避触发,则不会继续执行 dodge: 0 attack: 1 # 如果优先级是 defense: 1, attack: 2 那样子防御属性就没意义了 defense: 2 update: health: 100 moving: 101 runtime: [] ``` -------------------------------- ### YAML: attribute.yml 核心配置示例 Source: https://context7.com/context7/ersha_gitbook_io_attributeplus-pro/llms.txt 这是一个基础的 'attribute.yml' 配置文件示例,用于配置 AttributePlus Pro 插件的核心选项,包括语言设置。此文件定义了插件的全局行为和参数。 ```yaml # 插件选项 options: lang: "zh_CN" ``` -------------------------------- ### 配置弓箭机制 - YAML Source: https://ersha.gitbook.io/attributeplus-pro/ji-zhi-xiang-guan/gong-jian-ji-zhi 该YAML配置用于定义弓箭机制的各项属性,包括是否启用、蓄力影响、箭矢速度、偏离度和穿透能力。支持1.8及以上版本,穿透功能仅限1.14+。属性值计算公式为'属性值/100'。 ```yaml #支持版本 1.8? 1.9+ #弓箭机制 shoot: #弓箭属性计算公式均为 "属性值/100" enable: false #蓄力影响 #拉满则可以打出满射速的箭,如果没拉满则按力道削弱速度 #拉满精准度会提高,没拉满精准度则会降低,精准度不会超过 默认值+属性加成 force: true #默认箭飞行速度 (数值越大速度越快) speed: 2.0 #默认箭飞行偏离 (数值越大偏离越大) spread: 3.0 #穿透 1.14+ 版本支持,其他版本爬 through: #是否启用 enable: false #穿透次数 (箭术穿透触发时穿透实体次数) amount: 3 ``` -------------------------------- ### JavaScript: UPDATE 类型生命恢复属性 Source: https://context7.com/context7/ersha_gitbook_io_attributeplus-pro/llms.txt 此代码定义了一个 'UPDATE' 类型的属性,用于在每次属性更新时自动恢复生命值。它包含 onLoad 和 run 函数,用于设置消息和执行生命恢复逻辑。依赖于实体和属性管理系统。 ```javascript var priority = 5; var combatPower = 2.0; var attributeName = "生命恢复"; var attributeType = "UPDATE"; var placeholder = "health_regen"; function onLoad(attr) { attr.setMessages(Arrays.asList( "§a恢复了 §e{health_regen} §a点生命值" )); return attr; } function run(attr, entity, handle) { var regenValue = attr.getRandomValue(entity, handle); if (regenValue > 0 && entity.getHealth() < entity.getMaxHealth()) { Utils.safeHeal(entity, regenValue); attr.storageValue("health_regen", regenValue); return true; } return false; } ``` -------------------------------- ### JavaScript: DEFENSE 类型反伤护盾属性 Source: https://context7.com/context7/ersha_gitbook_io_attributeplus-pro/llms.txt 此代码定义了一个 'DEFENSE' 类型的属性,用于在受到攻击时反弹部分伤害给攻击者。它在 onLoad 中设置消息和反伤公式,并在 runDefense 函数中计算并执行反伤逻辑。依赖于伤害计算和实体交互系统。 ```javascript var priority = 8; var combatPower = 3.0; var attributeName = "荆棘反伤"; var attributeType = "DEFENSE"; var placeholder = "thorns_damage"; function onLoad(attr) { attr.setMessages(Arrays.asList( "§6荆棘反伤!§f你对 {entity} 造成 §e{thorns_damage} §f点反伤", "§6荆棘反伤!§f{attacker} 的荆棘对你造成 §e{thorns_damage} §f点伤害" )); // 公式:受到伤害的百分比 + 固定反伤值 attr.setFormula("({attackerDamage}*0.3)+{value}"); return attr; } function runDefense(attr, entity, killer, handle) { var thornsValue = attr.getRandomValue(entity, handle); if (thornsValue > 0) { // 使用公式计算反伤 var reflectDamage = attr.getFormulaValue(function() { // 后备计算:受到伤害的30% + 荆棘属性值 var incomingDamage = attr.getDamage(entity, handle); return (incomingDamage * 0.3) + thornsValue; }); // 对攻击者造成反伤 attr.addDamage(entity, reflectDamage, handle); attr.storageValue("thorns_damage", reflectDamage); return true; } return false; } ``` -------------------------------- ### 自定义 JavaScript 触发器脚本 (JavaScript) Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu 用于 AttributePlus Pro 插件中自定义触发器属性类型。脚本需要实现 `runCustom` 方法,并接收触发器事件、触发者、目标、参数和事件源等信息。需要配合 `SKILLAPI` 插件使用,并在 `onLoad()` 方法中调用 `setCustomTrigger()` 来注册触发器名称。 ```JavaScript /** * 自定义触发器属性脚本 * @param attr 属性对象 * @param caster 触发者 * @param target 触发目标(可为空) * @param params 触发器事件传入的参数 * @param source 触发器此次事件对象 * @param handle 处理对象 */ function runCustom(attr, caster, target, params, source, handle) { // 脚本逻辑 } ``` -------------------------------- ### JavaScript: RUNTIME 类型治疗光环属性 Source: https://context7.com/context7/ersha_gitbook_io_attributeplus-pro/llms.txt 此代码定义了一个 'RUNTIME' 类型的属性,实现周期性为周围队友施加增益效果(治疗光环)。它在 onLoad 中注册半径属性,并在 run 函数中检测实体范围内的玩家进行治疗。依赖于实体、世界和粒子管理系统。 ```javascript var priority = 10; var combatPower = 4.0; var attributeName = "治疗光环"; var attributeType = "RUNTIME"; var placeholder = "healing_aura"; function onLoad(attr) { // 注册光环半径属性 Utils.registerOtherAttribute("光环半径", 0.5, "aura_radius"); return attr; } function run(attr, entity, handle) { var healAmount = attr.getRandomValue(entity, handle); var radius = attr.getRandomValue(entity, "光环半径", handle); if (healAmount <= 0 || radius <= 0) { return false; } // 获取范围内的玩家 var nearbyPlayers = Utils.getNearbyEntities( entity, radius, radius, radius, true, // 包含自己 Arrays.asList(EntityType.PLAYER) ); var healedCount = 0; for (var i = 0; i < nearbyPlayers.size(); i++) { var target = nearbyPlayers.get(i); if (target.getHealth() < target.getMaxHealth()) { Utils.safeHeal(target, healAmount); // 显示治疗粒子 target.getWorld().spawnParticle( Particle.HEART, target.getLocation().add(0, 2, 0), 5 ); healedCount++; } } return healedCount > 0; } ``` -------------------------------- ### YAML Configuration for Attribute Display (stats.yml) Source: https://ersha.gitbook.io/attributeplus-pro/cha-jian-pei-zhi/stats This YAML configuration file defines how player attributes are displayed within the AttributePlus - Pro plugin. It supports two main display modes: 'BOOK' for a book interface and 'GUI' for a chest-based interface. The configuration includes options for the GUI title, size, item placement, and the content of the lore for each attribute category (attack, defense, other). It also specifies the book formatting for these attributes. ```yaml #BOOK 则通过书本方式展示属性内容 (1.9+) #GUI 则通过箱子界面展示属性内容 (1.7+) options: "BOOK" gui: title: "&1&l&n玩家属性" #选择界面大小 (必须为 9 的倍数,最高 54) size: 27 #可以自由创建新的位置,但节点名不可以相同 list: border: id: 160 ids: 7 slots: [0,1,2,3,4,5,6,7,8,9,17,18,19,20,21,22,23,24,25,26] name: "&8边框" info: id: 397 ids: 3 slot: 4 name: "&6&l个人战力" lore: - "&6属性战力: &c%ap_combatpower%" attack: id: 267 ids: 0 slot: 11 name: "&6攻击属性" lore: - " " - "&a物理伤害: &f%ap_attack%" - "&aPVP伤害: &f%ap_pvp_attack%" - "&aPVE伤害: &f%ap_pve_attack%" - "&6真实伤害: &f%ap_real_attack%" - "&6燃烧几率: &f%ap_fire:max%&8&l%" - "&6燃烧伤害: &f%ap_fire_damage%" - " " - "&c暴击几率: &f%ap_crit:max%&8&l%" - "&c暴击倍率: &f%ap_crit_rate:max%&8&l%" - "&c吸血几率: &f%ap_vampire:max%&8&l%" - "&c吸血倍率: &f%ap_vampire_rate:max%&8&l%" - " " - "&3命中几率: &f%ap_hit:max%&8&l%" - "&3冰冻几率: &f%ap_frozen:max%&8&l%" - "&3冰冻强度: &f%ap_frozen_intensity:max%&8&l%" - "&3雷击几率: &f%ap_lightning:max%&8&l%" - "&3雷击伤害: &f%ap_lightning_damage%" - "&3破甲几率: &f%ap_sunder_armor:max%&8&l%" - "&6护甲穿透: &f%ap_see_through:max%&8&l%" - "&3破盾几率: &f%ap_break_shield:max%&8&l%" defense: id: 307 ids: 0 slot: 13 name: "&3防御属性" lore: - " " - "&a护甲值: &f%ap_armor:max%&8&l%" - "&a物理防御: &f%ap_defense%" - "&aPVE防御: &f%ap_pvp_defense%" - "&aPVE防御: &f%ap_pve_defense%" - " " - "&c暴击抗性: &f%ap_crit_resist:max%&8&l%" - "&c吸血抗性: &f%ap_vampire_resist:max%&8&l%" - " " - "&6反弹几率: &f%ap_reflection:max%&8&l%" - "&6反弹伤害: &f%ap_reflection_rate:max%&8&l%" - "&6闪避几率: &f%ap_dodge:max%&8&l%" - "&6盾牌格挡率: &f%ap_shield_block:max%&8&l%" - "&6箭伤免疫率: &f%ap_remote_immune:max%&8&l%" other: id: 403 ids: 0 slot: 15 name: "&7其他属性" lore: - " " - "&a生命力: &f%ap_health:max%&8&l%" - "&a生命恢复: &f%ap_restore%" - "&a百分比恢复: &f%ap_restore_ratio:max%&8&l%" - " " - "&6蓄力加成: &f%ap_accumulate_addition:max%&8&l%" - "&6蓄力干扰: &f%ap_accumulate_disturb:max%&8&l%" - "&6移速加成: &f%ap_moving:max%&8&l%" - "&6经验加成: &f%ap_exp_addition:max%&8&l%" - "&6召唤强度: &f%ap_summon_intensity:max%&8&l%" - " " - "&3弓箭射速: &f%ap_shoot_speed:max%&8&l%" - "&3箭术精准: &f%ap_shoot_spread:max%&8&l%" - "&3箭术穿透率: &f%ap_shoot_through:max%&8&l%" book: attack: - " &6&l&n攻击属性" - "&a物理伤害: &8%ap_attack%" - "&aPVP伤害: &8%ap_pvp_attack%" - "&aPVE伤害: &8%ap_pve_attack%" - "&6真实伤害: &8%ap_real_attack%" - "&6燃烧几率: &8%ap_fire:max%&8&l%" - "&6燃烧伤害: &8%ap_fire_damage%" - " " - "&c暴击几率: &8%ap_crit:max%&8&l%" - "&c暴击倍率: &8%ap_crit_rate:max%&8&l%" - "&c吸血几率: &8%ap_vampire:max%&8&l%" - "&c吸血倍率: &8%ap_vampire_rate:max%&8&l%" - " " - "&8命中几率: &8%ap_hit:max%&8&l%" - "&8冰冻几率: &8%ap_frozen:max%&8&l%" - "&8冰冻强度: &8%ap_frozen_intensity:max%&8&l%" - "&8雷击几率: &8%ap_lightning:max%&8&l%" - "&8雷击伤害: &8%ap_lightning_damage%" - "&8破甲几率: &8%ap_sunder_armor:max%&8&l%" - "&8护甲穿透: &8%ap_see_through:max%&8&l%" - "&8破盾几率: &8%ap_break_shield:max%&8&l%" - "&8伤害加成: &8%ap_attack_addition:max%&8&l%" defense: - " &3&l&n防御属性" - "&a护甲值: &8%ap_armor:max%&8&l%" - "&a物理防御: &8%ap_defense%" - "&aPVE防御: &8%ap_pvp_defense%" - "&aPVE防御: &8%ap_pve_defense%" - " " - "&c暴击抗性: &8%ap_crit_resist:max%&8&l%" - "&c吸血抗性: &8%ap_vampire_resist:max%&8&l%" - " " - "&6反弹几率: &8%ap_reflection:max%&8&l%" - "&6反弹伤害: &8%ap_reflection_rate:max%&8&l%" - "&6闪避几率: &8%ap_dodge:max%&8&l%" - "&6盾牌格挡率: &8%ap_shield_block:max%&8&l%" - "&6箭伤免疫率: &8%ap_remote_immune:max%&8&l%" other: - " &8&l&n其他属性" - "&a生命力: &8%ap_health:max%&8&l%" - "&a生命加成: &8%ap_health_addition:max%&8&l%" - "&a生命恢复: &8%ap_restore%" - "&a百分比恢复: &8%ap_restore_ratio:max%&8&l%" - " " - "&6蓄力加成: &8%ap_accumulate_addition:max%&8&l%" - "&6蓄力干扰: &8%ap_accumulate_disturb:max%&8&l%" - "&6移速加成: &8%ap_moving:max%&8&l%" - "&6经验加成: &8%ap_exp_addition:max%&8&l%" - "&6召唤强度: &8%ap_summon_intensity:max%&8&l%" - " " - "&3弓箭射速: &8%ap_shoot_speed:max%&8&l%" - "&3箭术精准: &8%ap_shoot_spread:max%&8&l%" - "&3箭术穿透率: &8%ap_shoot_through:max%&8&l%" ``` -------------------------------- ### 自定义触发器组件接口 (Kotlin) Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu AttributePlus Pro 插件中用于附属开发者自定义注册触发器的接口。定义了触发器名称、事件类型、优先级、是否忽略取消、条件判断、触发者、目标、参数以及注册方法。 ```Kotlin interface CustomTriggerComponent { // 触发器名称 val name: String // 触发器事件 val event: Class // 触发器事件优先级 val priority: EventPriority // 触发器事件是否忽略取消 val ignoreCancelled: Boolean /** * 触发器触发条件,条件不满足时将不触发处理 * [event] 触发器此次事件 */ fun condition(event: E): Boolean { return true } /** * 触发者对象传入 * [event] 触发器此次事件 */ fun caster(event: E): LivingEntity /** * 目标对象传入 * [event] 触发器此次事件 */ fun target(event: E): LivingEntity? { return null } /** * 触发事件相关参数传入,可在 runCustom 属性处理方法获取 * [event] 触发器此次事件 */ fun params(event: E): Array { return emptyArray() } /* 注册触发器 */ fun register() { attributeManager.registerTrigger(this) } } ``` -------------------------------- ### 实体单体冷却中控器工具类 (Kotlin) Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu 在 `AttrScriptUtils.kt` 类中提供的一组工具方法,用于管理非玩家实体的冷却状态。当实体死亡时,相关的冷却数据会自动清除。可用于检查目标是否处于冷却状态、进入冷却状态或重置冷却。 ```Kotlin object AttrScriptUtils { // ... 其他方法 ... /** * 目标是否冷却中 * @param name 冷却名称 * @param entity 目标实体 * @return boolean 是否冷却中 */ fun hasEntityCooling(name: String, entity: LivingEntity): Boolean { /* ... */ } /** * 目标是否冷却中,未冷却则进入冷却 * @param name 冷却名称 * @param entity 目标实体 * @param time 冷却时间 (毫秒) * @return boolean 是否冷却中 */ fun hasEntityCooling(name: String, entity: LivingEntity, time: Long): Boolean { /* ... */ } /** * 重置目标冷却 * @param name 冷却名称 * @param entity 目标实体 */ fun resetEntityCooling(name: String, entity: LivingEntity) { /* ... */ } // ... 其他方法 ... } ``` -------------------------------- ### YAML Configuration for Equipment Condition Tags Source: https://ersha.gitbook.io/attributeplus-pro/du-qu-xiang-guan/zhuang-bei-tiao-jian-biao-qian This YAML configuration defines settings for various equipment condition tags used in the AttributePlus Pro plugin. It includes options for permission-based restrictions (job), level requirements, and equipment type matching. The configuration specifies delimiters for multiple permissions and lists valid equipment types. ```yaml #权限限制 #支持多个权限,例如 "职业: 剑士/法师/牧师" 只需要满足其一即可 permission: split: "/" key: "职业" #装备等级限制 #支持 10-100 的范围格式,即10至100级内玩家可使用(3.3.0.7+) level: "装备等级" #装备等级限制标签,等级来源变量 level-placeholder: "%player_level%" #装备类型 #例如 [装备类型: 双持] equipmentType: lore: "装备类型" list: - "双持" - "主手" - "副手" - "头盔" - "衣服" - "裤子" - "鞋子" ``` -------------------------------- ### 自定义 JavaScript KILLER 属性脚本 (JavaScript) Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu AttributePlus Pro 插件中用于 `KILLER` 属性处理类型的 JavaScript 脚本。当击杀目标时触发,脚本需要实现 `runKiller` 方法,并接收属性对象、击杀者、被击杀者以及处理对象。 ```JavaScript /** * KILLER 属性处理脚本 * @param attr 属性对象 * @param killer 击杀者 * @param entity 被击杀者 * @param handle 处理对象 */ function runKiller(attr, killer, entity, handle) { // 脚本逻辑 } ``` -------------------------------- ### Counter Methods in Kotlin Source: https://ersha.gitbook.io/attributeplus-pro/kai-fa-wen-dang/api-1 Provides methods for managing counter values and text. These include updating, setting, retrieving, and resetting numerical values and string content. Default values can be specified for retrieval methods. ```kotlin /** * 更新计数器记录数值 * [update] 数值 [default] 默认值(即该计数器未操作过时的默认值) */ fun updateValue(update: Double, default: Double): Double /** * 设置计数器记录数值 * [value] 数值 */ fun setValue(value: Double): Double /** * 设置计数器文本记录 * [update] 文本 */ fun updateContent(update: String): String /** * 获取计数器记录数值 * [default] 默认值(即该计数器未操作过时的默认值) */ fun getValue(default: Double): Double /** * 获取计数器记录文本 * [default] 默认值(即该计数器未操作过时的默认值) */ fun getContent(default: String): String /** * 重置计数器记录数值 */ fun resetValue() /** * 重置计数器记录文本 */ fun resetContent() ``` -------------------------------- ### Shield Mechanism Configuration (YAML) Source: https://ersha.gitbook.io/attributeplus-pro/ji-zhi-xiang-guan/dun-pai-ji-zhi This YAML snippet configures the shield mechanism for AttributePlus Pro. It allows enabling the shield, choosing between cooldown and no-cooldown modes, and setting the cooldown duration. This configuration is compatible with version 1.9+. ```yaml #支持版本: 1.9+ #盾牌格挡机制 shield: enable: true #right 则为无冷却模式 right: false #right 为 false 时启用盾牌格挡冷却机制 cd: 10 ``` -------------------------------- ### SkillCast 属性触发器示例 (Kotlin) Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu 一个实现 `CustomTriggerComponent` 接口的示例,用于注册 `SKILL CAST` 类型的属性触发器。该触发器监听 `PlayerCastSkillEvent` 事件,并提取技能名称作为参数。 ```Kotlin class SkillCastAttributeTrigger : CustomTriggerComponent { override val name: String = "SKILL CAST" override val event: Class = PlayerCastSkillEvent::class.java override val priority: EventPriority = EventPriority.NORMAL override val ignoreCancelled: Boolean = false override fun caster(event: PlayerCastSkillEvent): LivingEntity { return event.player } override fun params(event: PlayerCastSkillEvent): Array { val skillName = event.skill.data.name return arrayOf(skillName) } } ``` -------------------------------- ### AttributeAPI 实体攻击方法 (Java) Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu AttributeAPI 提供的 `attackTo` 方法用于造成固定伤害。与 `entity.damage()` 不同,此方法在击杀目标时会将击杀者指定为 [attacker],并建议用于处理真实伤害,避免触发二次属性处理。依赖于 AttributePlus Pro 插件。 ```Java /** * 造成固定伤害方法: * 该方法 entity.damage(damage) 相比,该方法直接击杀目标击杀者会为 [attacker] * 建议各类真伤处理调用该方法,该方法造成的时候不会触发二次属性处理 * @param entity 目标实体 * @param attacker 攻击者实体 * @param damage 伤害值 */ public void attackTo(LivingEntity entity, LivingEntity attacker, double damage) { ``` -------------------------------- ### Attribute Calculator Source Usage Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu Provides the package path for `AttributeCalculatorSource`, a utility class designed to automatically calculate attribute formulas based on provided placeholder data. It generates an `AttributeSource` object after computation. ```java packet: org.serverct.ersha.attribute.data.AttributeCalculatorSource ``` -------------------------------- ### 属性自定义计数器工具方法 (Java) Source: https://ersha.gitbook.io/attributeplus-pro/geng-xin-ji-lu AttributePlus Pro 插件提供的属性自定义计数器工具。通过 `AttributeData.getCounter()` 获取计数器主控对象,并提供 `getCounter`, `resetValue`, `getValue`, `setValue`, `updateValue`, `getContent`, `updateContent` 等方法来管理和操作计数器数据。 ```Java /** * 获取计数器主控对象 * @return Counter 对象 */ public Counter getCounter() { /* ... */ } // Counter 对象方法示例: // counter.getCounter(name, type).resetValue(); // counter.getCounter(name, type).getValue(def); // counter.getCounter(name, type).setValue(value); // counter.getCounter(name, type).updateValue(value, def); // counter.getCounter(name, type).getContent(def); // counter.getCounter(name, type).updateContent(text); ```