Search in sources :

Example 1 with MagicProperties

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

the class MageCommandExecutor method onMageDescribe.

public boolean onMageDescribe(CommandSender sender, Player player, String[] parameters) {
    Mage mage = controller.getMage(player);
    MageClass activeClass = mage.getActiveClass();
    MagicProperties mageProperties = mage.getProperties();
    if (parameters.length == 0) {
        sender.sendMessage(ChatColor.BLUE + "Use " + ChatColor.AQUA + "/mage describe <property>" + ChatColor.BLUE + " for specific properties");
        sender.sendMessage(ChatColor.BLUE + "Use " + ChatColor.AQUA + "/mage activate" + ChatColor.BLUE + " to change or clear the active class");
        Collection<String> classKeys = mage.getClassKeys();
        if (classKeys.size() > 0) {
            Collection<String> coloredClasses = new ArrayList<>();
            for (String classKey : classKeys) {
                ChatColor color = mage.hasClassUnlocked(classKey) ? ChatColor.GREEN : ChatColor.GRAY;
                coloredClasses.add(color + classKey);
            }
            sender.sendMessage(ChatColor.AQUA + "Classes: " + ChatColor.GREEN + StringUtils.join(coloredClasses, ","));
        }
        if (!mageProperties.isEmpty()) {
            sender.sendMessage(ChatColor.AQUA + "Mage properties:");
            mageProperties.describe(sender, BaseMagicProperties.HIDDEN_PROPERTY_KEYS);
        }
        if (activeClass != null) {
            sender.sendMessage(ChatColor.AQUA + "Active class: " + ChatColor.GREEN + activeClass.getKey());
        } else {
            sender.sendMessage(ChatColor.DARK_GREEN + "No active class");
        }
        Set<Spell> activeSpells = mage.getActiveSpells();
        if (activeSpells != null && !activeSpells.isEmpty()) {
            Collection<String> spellNames = new ArrayList<>();
            for (Spell spell : activeSpells) {
                spellNames.add(spell.getName());
            }
            sender.sendMessage(ChatColor.AQUA + "Active spells: " + ChatColor.DARK_AQUA + StringUtils.join(spellNames, ","));
        }
        if (activeClass != null) {
            activeClass.describe(sender, BaseMagicProperties.HIDDEN_PROPERTY_KEYS);
        }
    } else {
        Object property = activeClass.getProperty(parameters[0]);
        if (property == null) {
            sender.sendMessage(ChatColor.DARK_AQUA + parameters[0] + ChatColor.GRAY + ": " + ChatColor.RED + "(Not Set)");
        } else {
            sender.sendMessage(ChatColor.DARK_AQUA + parameters[0] + ChatColor.GRAY + ": " + ChatColor.WHITE + InventoryUtils.describeProperty(property));
        }
    }
    return true;
}
Also used : MageClass(com.elmakers.mine.bukkit.api.magic.MageClass) Mage(com.elmakers.mine.bukkit.api.magic.Mage) ArrayList(java.util.ArrayList) BaseMagicProperties(com.elmakers.mine.bukkit.magic.BaseMagicProperties) MagicProperties(com.elmakers.mine.bukkit.api.magic.MagicProperties) ChatColor(org.bukkit.ChatColor) Spell(com.elmakers.mine.bukkit.api.spell.Spell)

Aggregations

Mage (com.elmakers.mine.bukkit.api.magic.Mage)1 MageClass (com.elmakers.mine.bukkit.api.magic.MageClass)1 MagicProperties (com.elmakers.mine.bukkit.api.magic.MagicProperties)1 Spell (com.elmakers.mine.bukkit.api.spell.Spell)1 BaseMagicProperties (com.elmakers.mine.bukkit.magic.BaseMagicProperties)1 ArrayList (java.util.ArrayList)1 ChatColor (org.bukkit.ChatColor)1