Search in sources :

Example 1 with MagicAttribute

use of com.elmakers.mine.bukkit.magic.MagicAttribute in project MagicPlugin by elBukkit.

the class Wand method addPropertyLore.

protected void addPropertyLore(List<String> lore, boolean isSingleSpell) {
    if (usesMana() && effectiveManaMax > 0) {
        int manaMax = getManaMax();
        if (effectiveManaMax != manaMax) {
            String fullMessage = getLevelString("mana_amount_boosted", manaMax, controller.getMaxMana());
            ConfigurationUtils.addIfNotEmpty(fullMessage.replace("$mana", Integer.toString(effectiveManaMax)), lore);
        } else {
            ConfigurationUtils.addIfNotEmpty(getLevelString("mana_amount", manaMax, controller.getMaxMana()), lore);
        }
        int manaRegeneration = getManaRegeneration();
        if (manaRegeneration > 0 && effectiveManaRegeneration > 0) {
            if (effectiveManaRegeneration != manaRegeneration) {
                String fullMessage = getLevelString("mana_regeneration_boosted", manaRegeneration, controller.getMaxManaRegeneration());
                ConfigurationUtils.addIfNotEmpty(fullMessage.replace("$mana", Integer.toString(effectiveManaRegeneration)), lore);
            } else {
                ConfigurationUtils.addIfNotEmpty(getLevelString("mana_regeneration", manaRegeneration, controller.getMaxManaRegeneration()), lore);
            }
        }
        if (manaPerDamage > 0) {
            ConfigurationUtils.addIfNotEmpty(getLevelString("mana_per_damage", manaPerDamage, controller.getMaxManaRegeneration()), lore);
        }
    }
    if (superPowered) {
        ConfigurationUtils.addIfNotEmpty(getMessage("super_powered"), lore);
    }
    if (blockReflectChance > 0) {
        ConfigurationUtils.addIfNotEmpty(getLevelString("reflect_chance", blockReflectChance), lore);
    } else if (blockChance != 0) {
        ConfigurationUtils.addIfNotEmpty(getLevelString("block_chance", blockChance), lore);
    }
    float manaMaxBoost = getManaMaxBoost();
    if (manaMaxBoost != 0) {
        ConfigurationUtils.addIfNotEmpty(getPropertyString("mana_boost", manaMaxBoost), lore);
    }
    float manaRegenerationBoost = getManaRegenerationBoost();
    if (manaRegenerationBoost != 0) {
        ConfigurationUtils.addIfNotEmpty(getPropertyString("mana_regeneration_boost", manaRegenerationBoost), lore);
    }
    if (castSpell != null) {
        SpellTemplate spell = controller.getSpellTemplate(castSpell);
        if (spell != null) {
            ConfigurationUtils.addIfNotEmpty(getMessage("spell_aura").replace("$spell", spell.getName()), lore);
        }
    }
    for (Map.Entry<PotionEffectType, Integer> effect : potionEffects.entrySet()) {
        ConfigurationUtils.addIfNotEmpty(describePotionEffect(effect.getKey(), effect.getValue()), lore);
    }
    // In this case we should show it as such in the lore.
    if (passive)
        isSingleSpell = false;
    if (consumeReduction != 0 && !isSingleSpell)
        ConfigurationUtils.addIfNotEmpty(getPropertyString("consume_reduction", consumeReduction), lore);
    if (costReduction != 0 && !isSingleSpell)
        ConfigurationUtils.addIfNotEmpty(getPropertyString("cost_reduction", costReduction), lore);
    if (cooldownReduction != 0 && !isSingleSpell)
        ConfigurationUtils.addIfNotEmpty(getPropertyString("cooldown_reduction", cooldownReduction), lore);
    if (power > 0)
        ConfigurationUtils.addIfNotEmpty(getLevelString("power", power), lore);
    if (superProtected) {
        ConfigurationUtils.addIfNotEmpty(getMessage("super_protected"), lore);
    } else if (protection != null) {
        for (Map.Entry<String, Double> entry : protection.entrySet()) {
            String protectionType = entry.getKey();
            double amount = entry.getValue();
            addDamageTypeLore("protection", protectionType, amount, lore);
        }
    }
    ConfigurationSection weaknessConfig = getConfigurationSection("weakness");
    if (weaknessConfig != null) {
        Set<String> keys = weaknessConfig.getKeys(false);
        for (String key : keys) {
            addDamageTypeLore("weakness", key, weaknessConfig.getDouble(key), lore);
        }
    }
    ConfigurationSection strengthConfig = getConfigurationSection("strength");
    if (strengthConfig != null) {
        Set<String> keys = strengthConfig.getKeys(false);
        for (String key : keys) {
            addDamageTypeLore("strength", key, strengthConfig.getDouble(key), lore);
        }
    }
    if (spMultiplier > 1) {
        ConfigurationUtils.addIfNotEmpty(getPropertyString("sp_multiplier", spMultiplier - 1), lore);
    }
    ConfigurationSection attributes = getConfigurationSection("attributes");
    if (attributes != null) {
        // Don't bother with the lore at all if the template has been blanked out
        String template = getMessage("attributes");
        if (!template.isEmpty()) {
            Set<String> keys = attributes.getKeys(false);
            for (String key : keys) {
                String label = controller.getMessages().get("attributes." + key + ".name", key);
                // We are only display attributes as integers for now
                int value = attributes.getInt(key);
                if (value == 0)
                    continue;
                float max = 1;
                MagicAttribute attribute = controller.getAttribute(key);
                if (attribute != null) {
                    Double maxValue = attribute.getMax();
                    if (maxValue != null) {
                        max = (float) (double) maxValue;
                    }
                }
                label = getPropertyString("attributes", value, max).replace("$attribute", label);
                lore.add(label);
            }
        }
    }
}
Also used : PotionEffectType(org.bukkit.potion.PotionEffectType) MagicAttribute(com.elmakers.mine.bukkit.magic.MagicAttribute) Map(java.util.Map) HashMap(java.util.HashMap) SpellTemplate(com.elmakers.mine.bukkit.api.spell.SpellTemplate) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

SpellTemplate (com.elmakers.mine.bukkit.api.spell.SpellTemplate)1 MagicAttribute (com.elmakers.mine.bukkit.magic.MagicAttribute)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 PotionEffectType (org.bukkit.potion.PotionEffectType)1