Search in sources :

Example 1 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class SkillsCommand method onItemMultiplierAdd.

@Subcommand("item multiplier add")
@CommandCompletion("@skills_global @nothing true|false")
@CommandPermission("aureliumskills.item.multiplier.add")
@Description("Adds an item multiplier to the held item to global or a specific skill where value is the percent more XP gained.")
public void onItemMultiplierAdd(@Flags("itemheld") Player player, String target, double value, @Default("true") boolean lore) {
    ItemStack item = player.getInventory().getItemInMainHand();
    Skill skill = plugin.getSkillRegistry().getSkill(target);
    Locale locale = plugin.getLang().getLocale(player);
    Multipliers multipliers = new Multipliers(plugin);
    if (skill != null) {
        // Add multiplier for specific skill
        for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
            if (multiplier.getSkill() == skill) {
                player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", skill.getDisplayName(locale)));
                return;
            }
        }
        if (lore) {
            multipliers.addLore(ModifierType.ITEM, item, skill, value, locale);
        }
        ItemStack newItem = multipliers.addMultiplier(ModifierType.ITEM, item, skill, value);
        player.getInventory().setItemInMainHand(newItem);
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ADDED, locale), "{target}", skill.getDisplayName(locale), "{value}", String.valueOf(value)));
    } else if (target.equalsIgnoreCase("global")) {
        // Add multiplier for all skills
        String global = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
        for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
            if (multiplier.getSkill() == null) {
                player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", global));
                return;
            }
        }
        if (lore) {
            multipliers.addLore(ModifierType.ITEM, item, null, value, locale);
        }
        ItemStack newItem = multipliers.addMultiplier(ModifierType.ITEM, item, null, value);
        player.getInventory().setItemInMainHand(newItem);
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ADDED, locale), "{target}", global, "{value}", String.valueOf(value)));
    } else {
        throw new InvalidCommandArgument("Target must be valid skill name or global");
    }
}
Also used : Locale(java.util.Locale) Skill(com.archyx.aureliumskills.skills.Skill) InvalidCommandArgument(co.aikar.commands.InvalidCommandArgument) ItemStack(org.bukkit.inventory.ItemStack)

Example 2 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class SkillsCommand method onItemMultiplierRemove.

@Subcommand("item multiplier remove")
@CommandCompletion("@skills_global")
@CommandPermission("aureliumskills.item.multiplier.remove")
@Description("Removes an item multiplier of a the specified skill or global from the held item.")
public void onItemMultiplierRemove(@Flags("itemheld") Player player, String target) {
    Locale locale = plugin.getLang().getLocale(player);
    ItemStack item = player.getInventory().getItemInMainHand();
    Skill skill = plugin.getSkillRegistry().getSkill(target);
    boolean removed = false;
    Multipliers multipliers = new Multipliers(plugin);
    for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
        if (multiplier.getSkill() == skill) {
            item = multipliers.removeMultiplier(ModifierType.ITEM, item, skill);
            removed = true;
            break;
        }
    }
    player.getInventory().setItemInMainHand(item);
    // Use skill display name if skill is not null, otherwise use global name
    String targetName;
    if (skill != null) {
        targetName = skill.getDisplayName(locale);
    } else if (target.equalsIgnoreCase("global")) {
        targetName = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
    } else {
        throw new InvalidCommandArgument("Target must be valid skill name or global");
    }
    if (removed) {
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_REMOVE_REMOVED, locale), "{target}", targetName));
    } else {
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_REMOVE_DOES_NOT_EXIST, locale), "{target}", targetName));
    }
}
Also used : Locale(java.util.Locale) Skill(com.archyx.aureliumskills.skills.Skill) InvalidCommandArgument(co.aikar.commands.InvalidCommandArgument) ItemStack(org.bukkit.inventory.ItemStack)

Example 3 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class SkillsCommand method onArmorMultiplierAdd.

@Subcommand("armor multiplier add")
@CommandCompletion("@skills_global @nothing true|false")
@CommandPermission("aureliumskills.armor.multiplier.add")
@Description("Adds an armor multiplier to the held item to global or a specific skill where value is the percent more XP gained.")
public void onArmorMultiplierAdd(@Flags("itemheld") Player player, String target, double value, @Default("true") boolean lore) {
    ItemStack item = player.getInventory().getItemInMainHand();
    Skill skill = plugin.getSkillRegistry().getSkill(target);
    Locale locale = plugin.getLang().getLocale(player);
    Multipliers multipliers = new Multipliers(plugin);
    if (skill != null) {
        // Add multiplier for specific skill
        for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, item)) {
            if (multiplier.getSkill() == skill) {
                player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", skill.getDisplayName(locale)));
                return;
            }
        }
        if (lore) {
            multipliers.addLore(ModifierType.ARMOR, item, skill, value, locale);
        }
        ItemStack newItem = multipliers.addMultiplier(ModifierType.ARMOR, item, skill, value);
        player.getInventory().setItemInMainHand(newItem);
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ADDED, locale), "{target}", skill.getDisplayName(locale), "{value}", String.valueOf(value)));
    } else if (target.equalsIgnoreCase("global")) {
        // Add multiplier for all skills
        String global = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
        for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, item)) {
            if (multiplier.getSkill() == null) {
                player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", global));
                return;
            }
        }
        if (lore) {
            multipliers.addLore(ModifierType.ARMOR, item, null, value, locale);
        }
        ItemStack newItem = multipliers.addMultiplier(ModifierType.ARMOR, item, null, value);
        player.getInventory().setItemInMainHand(newItem);
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ADDED, locale), "{target}", global, "{value}", String.valueOf(value)));
    } else {
        throw new InvalidCommandArgument("Target must be valid skill name or global");
    }
}
Also used : Locale(java.util.Locale) Skill(com.archyx.aureliumskills.skills.Skill) InvalidCommandArgument(co.aikar.commands.InvalidCommandArgument) ItemStack(org.bukkit.inventory.ItemStack)

Example 4 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class SkillsCommand method onArmorMultiplierRemove.

@Subcommand("armor multiplier remove")
@CommandCompletion("@skills_global")
@CommandPermission("aureliumskills.armor.multiplier.remove")
@Description("Removes an armor multiplier of a the specified skill or global from the held item.")
public void onArmorMultiplierRemove(@Flags("itemheld") Player player, String target) {
    Locale locale = plugin.getLang().getLocale(player);
    ItemStack item = player.getInventory().getItemInMainHand();
    Skill skill = plugin.getSkillRegistry().getSkill(target);
    boolean removed = false;
    Multipliers multipliers = new Multipliers(plugin);
    for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, item)) {
        if (multiplier.getSkill() == skill) {
            item = multipliers.removeMultiplier(ModifierType.ARMOR, item, skill);
            removed = true;
            break;
        }
    }
    player.getInventory().setItemInMainHand(item);
    // Use skill display name if skill is not null, otherwise use global name
    String targetName;
    if (skill != null) {
        targetName = skill.getDisplayName(locale);
    } else if (target.equalsIgnoreCase("global")) {
        targetName = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
    } else {
        throw new InvalidCommandArgument("Target must be valid skill name or global");
    }
    if (removed) {
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_REMOVE_REMOVED, locale), "{target}", targetName));
    } else {
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_REMOVE_DOES_NOT_EXIST, locale), "{target}", targetName));
    }
}
Also used : Locale(java.util.Locale) Skill(com.archyx.aureliumskills.skills.Skill) InvalidCommandArgument(co.aikar.commands.InvalidCommandArgument) ItemStack(org.bukkit.inventory.ItemStack)

Example 5 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class SkillsCommand method onSkillReset.

@Subcommand("skill reset")
@CommandCompletion("@players @skills")
@CommandPermission("aureliumskills.skill.reset")
@Description("Resets all skills or a specific skill to level 1 for a player.")
public void onSkillReset(CommandSender sender, @Flags("other") Player player, @Optional Skill skill) {
    Locale locale = plugin.getLang().getLocale(sender);
    if (skill != null) {
        if (OptionL.isEnabled(skill)) {
            PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
            if (playerData == null)
                return;
            resetPlayerSkills(player, playerData, skill);
            // Reload items and armor to check for newly met requirements
            this.plugin.getModifierManager().reloadPlayer(player);
            sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_RESET_RESET_SKILL, locale).replace("{skill}", skill.getDisplayName(locale)).replace("{player}", player.getName()));
        } else {
            sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.UNKNOWN_SKILL, locale));
        }
    } else {
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        for (Skill s : plugin.getSkillRegistry().getSkills()) {
            resetPlayerSkills(player, playerData, s);
        }
        sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_RESET_RESET_ALL, locale).replace("{player}", player.getName()));
    }
}
Also used : Locale(java.util.Locale) Skill(com.archyx.aureliumskills.skills.Skill) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Aggregations

Skill (com.archyx.aureliumskills.skills.Skill)54 PlayerData (com.archyx.aureliumskills.data.PlayerData)15 Locale (java.util.Locale)15 Player (org.bukkit.entity.Player)13 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)12 File (java.io.File)11 IOException (java.io.IOException)9 ItemStack (org.bukkit.inventory.ItemStack)8 EventHandler (org.bukkit.event.EventHandler)7 Stat (com.archyx.aureliumskills.stats.Stat)6 InvalidCommandArgument (co.aikar.commands.InvalidCommandArgument)5 SkillValue (com.archyx.aureliumskills.leaderboard.SkillValue)5 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)5 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)5 AbilityData (com.archyx.aureliumskills.data.AbilityData)4 KeyIntPair (com.archyx.aureliumskills.util.misc.KeyIntPair)4 Map (java.util.Map)4 AureliumSkills (com.archyx.aureliumskills.AureliumSkills)3 OptionL (com.archyx.aureliumskills.configuration.OptionL)3 Lang (com.archyx.aureliumskills.lang.Lang)3