Search in sources :

Example 1 with LifeInfo

use of de.Keyle.MyPet.api.skill.skills.LifeInfo in project MyPet by xXKeyleXx.

the class Life method upgrade.

public void upgrade(SkillInfo upgrade, boolean quiet) {
    if (upgrade instanceof LifeInfo) {
        if (upgrade.getProperties().getCompoundData().containsKey("hp")) {
            int hp = upgrade.getProperties().getAs("hp", TagInt.class).getIntData();
            upgrade.getProperties().getCompoundData().remove("hp");
            TagDouble TagDouble = new TagDouble(hp);
            upgrade.getProperties().getCompoundData().put("hp_double", TagDouble);
        }
        if (upgrade.getProperties().getCompoundData().containsKey("hp_double")) {
            if (!upgrade.getProperties().getCompoundData().containsKey("addset_hp") || upgrade.getProperties().getAs("addset_hp", TagString.class).getStringData().equals("add")) {
                hpIncrease += upgrade.getProperties().getAs("hp_double", TagDouble.class).getDoubleData();
            } else {
                hpIncrease = upgrade.getProperties().getAs("hp_double", TagDouble.class).getDoubleData();
            }
            if (getMyPet().getStatus() == PetState.Here) {
                getMyPet().getEntity().get().setMaxHealth(getMyPet().getMaxHealth());
            }
            if (!quiet) {
                myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skill.Hp.Upgrade", myPet.getOwner().getLanguage()), myPet.getPetName(), myPet.getMaxHealth()));
            }
        }
    }
}
Also used : LifeInfo(de.Keyle.MyPet.api.skill.skills.LifeInfo) TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Aggregations

LifeInfo (de.Keyle.MyPet.api.skill.skills.LifeInfo)1 TagDouble (de.keyle.knbt.TagDouble)1 TagInt (de.keyle.knbt.TagInt)1 TagString (de.keyle.knbt.TagString)1