Skip to content

🥳type和args的应用

使用扩展功能必须到导包,这个功能只对于DamageAp生效,具体能实现什么样的功能还需看使用者的脑洞

同样的,若在开发插件中使用,也需要导这个包

yaml
"ApmmAPI": "me.monsterxz.attributemm.api.ApmmAPI"

ApmmAPI

ApmmAPI下的方法

java
public static boolean isSkill(EntityDamageByEntityEvent event)
//实体应该是被攻击的实体,获取此实体受到的伤害是否是APMM的DamageAP造成的
public static boolean isSkill(Entity entity)
public static String getDamageType(EntityDamageByEntityEvent event)
public static String getDamageType(Entity entity) 
public static List<String> getArgs(EntityDamageByEntityEvent event) 
public static List<String> getArgs(Entity entity)

示例

可以在脚本属性等任何使用API下方法的地方进行与AttributeMM的互动,比如在脚本属性中判断一个type火属性的技能

javascript
function runAttack(attr, attacker, entity, handle) {
  if (ApmmAPI.isSkill(entity) && ApmmAPI.getDamageType(entity) == "火属性") {
    var damage = Attr.getRandomValue(attacker, "火元素攻击", handle)
    attr.addDamage(attacker, damage, handle)
  }
  return false
}

使用一个type参数为火属性DamageAp

yaml
- DamageAp{type=火属性;AttributeList={火元素攻击=100}}
#若使用错误的type则无法触发火元素攻击 如下
- DamageAp{AttributeList={火元素攻击=100}}
- DamageAp{type=水属性;AttributeList={火元素攻击=100}}