[Help] How to convert skill-MythicConfig strings to be placeholdered?
Here is a custom skill code using MythicMobs API 3.5.0, but i dont know how to make MythicPlaceholders in the skill-config effective.
For example, the skill is - customdamage{a="<caster.level> * 2 + 1"} @target
, then the placeholder will not be converted to a number.
public class customDamage implements ITargetedEntitySkill {
protected String amount;
protected String defenseName;
protected String critChanceName;
protected String critRateName;
protected boolean ignoreCooldown;
public customDamage(MythicLineConfig config){
this.amount = config.getPlaceholderString(new String[]{"amount", "amt", "a"}, "0").get().replace("\"", "");
this.defenseName = config.getPlaceholderString(new String[]{"defenseName", "defensename", "dn"}, "NULL").get().replace("\"", "");
this.critChanceName = config.getPlaceholderString(new String[]{"critChanceName", "critchancename", "ccn"}, "NULL").get().replace("\"", "");
this.critRateName = config.getPlaceholderString(new String[]{"critRateName", "critratename", "crn"}, "NULL").get().replace("\"", "");
this.ignoreCooldown = config.getBoolean(new String[]{"ignoreCooldown", "ignorecooldown", "ic"}, false);
}
@Override
public SkillResult castAtEntity(SkillMetadata data, AbstractEntity target) {
Entity caster = BukkitAdapter.adapt(data.getCaster().getEntity());
Entity entity = BukkitAdapter.adapt(target);
if(caster instanceof LivingEntity && entity instanceof LivingEntity) {
LivingEntity livingCaster = (LivingEntity) caster;
LivingEntity livingEntity = (LivingEntity) entity;
if(livingCaster instanceof Player) {
// PlaceholderAPI
amount = PlaceholderAPI.setPlaceholders((Player) livingCaster, amount);
}
double attackValue = Utils.evaluateFormula(AttributeAPI.getAttrData(livingCaster), amount, critChanceName, critRateName);
double defenseValue = Utils.getValue(AttributeAPI.getAttrData(livingEntity), defenseName);
if(attackValue > defenseValue) {
attackValue -= defenseValue;
}
DecimalFormat decimalFormat = new DecimalFormat("#.00");
attackValue = Double.parseDouble(decimalFormat.format(attackValue));
if(ignoreCooldown) {
livingEntity.setNoDamageTicks(0);
}
livingEntity.damage(attackValue);
return SkillResult.SUCCESS;
}
return null;
}
}