Search in sources :

Example 1 with Requirements

use of com.archyx.aureliumskills.requirement.Requirements in project AureliumSkills by Archy-X.

the class SkillsCommand method onArmorRequirementAdd.

@Subcommand("armor requirement add")
@CommandPermission("aureliumskills.armor.requirement.add")
@CommandCompletion("@skills @nothing false|true")
@Description("Adds an armor requirement to the item held, along with lore by default")
public void onArmorRequirementAdd(@Flags("itemheld") Player player, Skill skill, int level, @Default("true") boolean lore) {
    Locale locale = plugin.getLang().getLocale(player);
    ItemStack item = player.getInventory().getItemInMainHand();
    Requirements requirements = new Requirements(plugin);
    if (requirements.hasRequirement(ModifierType.ARMOR, item, skill)) {
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_REQUIREMENT_ADD_ALREADY_EXISTS, locale), "{skill}", skill.getDisplayName(locale)));
        return;
    }
    item = requirements.addRequirement(ModifierType.ARMOR, item, skill, level);
    if (lore) {
        requirements.addLore(ModifierType.ARMOR, item, skill, level, locale);
    }
    player.getInventory().setItemInMainHand(item);
    player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_REQUIREMENT_ADD_ADDED, locale), "{skill}", skill.getDisplayName(locale), "{level}", String.valueOf(level)));
}
Also used : Locale(java.util.Locale) ItemStack(org.bukkit.inventory.ItemStack) Requirements(com.archyx.aureliumskills.requirement.Requirements)

Example 2 with Requirements

use of com.archyx.aureliumskills.requirement.Requirements in project AureliumSkills by Archy-X.

the class SkillsCommand method onItemRequirementAdd.

@Subcommand("item requirement add")
@CommandPermission("aureliumskills.item.requirement.add")
@CommandCompletion("@skills @nothing false|true")
@Description("Adds an item requirement to the item held, along with lore by default.")
public void onItemRequirementAdd(@Flags("itemheld") Player player, Skill skill, int level, @Default("true") boolean lore) {
    Locale locale = plugin.getLang().getLocale(player);
    ItemStack item = player.getInventory().getItemInMainHand();
    Requirements requirements = new Requirements(plugin);
    if (requirements.hasRequirement(ModifierType.ITEM, item, skill)) {
        player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_REQUIREMENT_ADD_ALREADY_EXISTS, locale), "{skill}", skill.getDisplayName(locale)));
        return;
    }
    item = requirements.addRequirement(ModifierType.ITEM, item, skill, level);
    if (lore) {
        requirements.addLore(ModifierType.ITEM, item, skill, level, locale);
    }
    player.getInventory().setItemInMainHand(item);
    player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_REQUIREMENT_ADD_ADDED, locale), "{skill}", skill.getDisplayName(locale), "{level}", String.valueOf(level)));
}
Also used : Locale(java.util.Locale) ItemStack(org.bukkit.inventory.ItemStack) Requirements(com.archyx.aureliumskills.requirement.Requirements)

Example 3 with Requirements

use of com.archyx.aureliumskills.requirement.Requirements in project AureliumSkills by Archy-X.

the class SkillsCommand method onItemRequirementRemoveAll.

@Subcommand("item requirement removeall")
@CommandPermission("aureliumskills.item.requirement.removeall")
@Description("Removes all item requirements from the item held.")
public void onItemRequirementRemoveAll(@Flags("itemheld") Player player) {
    Locale locale = plugin.getLang().getLocale(player);
    Requirements requirements = new Requirements(plugin);
    ItemStack item = requirements.removeAllRequirements(ModifierType.ITEM, player.getInventory().getItemInMainHand());
    player.getInventory().setItemInMainHand(item);
    player.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.ITEM_REQUIREMENT_REMOVEALL_REMOVED, locale));
}
Also used : Locale(java.util.Locale) ItemStack(org.bukkit.inventory.ItemStack) Requirements(com.archyx.aureliumskills.requirement.Requirements)

Example 4 with Requirements

use of com.archyx.aureliumskills.requirement.Requirements in project AureliumSkills by Archy-X.

the class ModifierManager method reloadPlayer.

public void reloadPlayer(Player player) {
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    Requirements requirements = new Requirements(plugin);
    Modifiers modifiers = new Modifiers(plugin);
    Multipliers multipliers = new Multipliers(plugin);
    if (playerData != null) {
        Set<Stat> statsToReload = new HashSet<>();
        ItemStack item = player.getInventory().getItemInMainHand();
        if (!(item.getType() == Material.AIR)) {
            for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, item)) {
                playerData.removeStatModifier(modifier.getName());
                statsToReload.add(modifier.getStat());
            }
            for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
                playerData.removeMultiplier(multiplier.getName());
            }
            if (requirements.meetsRequirements(ModifierType.ITEM, item, player)) {
                for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, item)) {
                    playerData.addStatModifier(modifier, false);
                    statsToReload.add(modifier.getStat());
                }
                for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
                    playerData.addMultiplier(multiplier);
                }
            }
        }
        ItemStack itemOffHand = player.getInventory().getItemInOffHand();
        if (!(itemOffHand.getType() == Material.AIR)) {
            for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, itemOffHand)) {
                playerData.removeStatModifier(modifier.getName() + ".Offhand");
                statsToReload.add(modifier.getStat());
            }
            for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, itemOffHand)) {
                playerData.removeMultiplier(multiplier.getName() + ".Offhand");
            }
            if (requirements.meetsRequirements(ModifierType.ITEM, itemOffHand, player)) {
                for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, itemOffHand)) {
                    StatModifier offHandModifier = new StatModifier(modifier.getName() + ".Offhand", modifier.getStat(), modifier.getValue());
                    playerData.addStatModifier(offHandModifier, false);
                    statsToReload.add(modifier.getStat());
                }
                for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, itemOffHand)) {
                    Multiplier offHandMultiplier = new Multiplier(multiplier.getName() + ".Offhand", multiplier.getSkill(), multiplier.getValue());
                    playerData.addMultiplier(offHandMultiplier);
                }
            }
        }
        EntityEquipment equipment = player.getEquipment();
        if (equipment != null) {
            for (ItemStack armor : equipment.getArmorContents()) {
                if (armor != null) {
                    if (!(armor.getType() == Material.AIR)) {
                        for (StatModifier modifier : modifiers.getModifiers(ModifierType.ARMOR, armor)) {
                            playerData.removeStatModifier(modifier.getName());
                            statsToReload.add(modifier.getStat());
                        }
                        for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, armor)) {
                            playerData.removeMultiplier(multiplier.getName());
                        }
                        if (requirements.meetsRequirements(ModifierType.ARMOR, armor, player)) {
                            for (StatModifier modifier : modifiers.getModifiers(ModifierType.ARMOR, armor)) {
                                playerData.addStatModifier(modifier, false);
                                statsToReload.add(modifier.getStat());
                            }
                            for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, armor)) {
                                playerData.addMultiplier(multiplier);
                            }
                        }
                    }
                }
            }
        }
        for (Stat stat : statsToReload) {
            statLeveler.reloadStat(player, stat);
        }
    }
}
Also used : Stat(com.archyx.aureliumskills.stats.Stat) EntityEquipment(org.bukkit.inventory.EntityEquipment) ItemStack(org.bukkit.inventory.ItemStack) PlayerData(com.archyx.aureliumskills.data.PlayerData) Requirements(com.archyx.aureliumskills.requirement.Requirements) HashSet(java.util.HashSet)

Example 5 with Requirements

use of com.archyx.aureliumskills.requirement.Requirements in project AureliumSkills by Archy-X.

the class SkillsCommand method onItemRequirementList.

@Subcommand("item requirement list")
@CommandPermission("aureliumskills.item.requirement.list")
@Description("Lists the item requirements on the item held.")
public void onItemRequirementList(@Flags("itemheld") Player player) {
    Locale locale = plugin.getLang().getLocale(player);
    player.sendMessage(Lang.getMessage(CommandMessage.ITEM_REQUIREMENT_LIST_HEADER, locale));
    Requirements requirements = new Requirements(plugin);
    for (Map.Entry<Skill, Integer> entry : requirements.getRequirements(ModifierType.ITEM, player.getInventory().getItemInMainHand()).entrySet()) {
        player.sendMessage(TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_REQUIREMENT_LIST_ENTRY, locale), "{skill}", entry.getKey().getDisplayName(locale), "{level}", String.valueOf(entry.getValue())));
    }
}
Also used : Locale(java.util.Locale) Skill(com.archyx.aureliumskills.skills.Skill) Map(java.util.Map) Requirements(com.archyx.aureliumskills.requirement.Requirements)

Aggregations

Requirements (com.archyx.aureliumskills.requirement.Requirements)9 Locale (java.util.Locale)8 ItemStack (org.bukkit.inventory.ItemStack)7 Skill (com.archyx.aureliumskills.skills.Skill)2 Map (java.util.Map)2 PlayerData (com.archyx.aureliumskills.data.PlayerData)1 Stat (com.archyx.aureliumskills.stats.Stat)1 HashSet (java.util.HashSet)1 EntityEquipment (org.bukkit.inventory.EntityEquipment)1