Search in sources :

Example 1 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class AbilityManager method sendMessage.

public void sendMessage(Player player, String message) {
    if (OptionL.getBoolean(Option.ACTION_BAR_ABILITY) && OptionL.getBoolean(Option.ACTION_BAR_ENABLED)) {
        plugin.getActionBar().sendAbilityActionBar(player, message);
    } else {
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        player.sendMessage(AureliumSkills.getPrefix(playerData.getLocale()) + message);
    }
}
Also used : PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 2 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class SkillsCommand method onSkillSetlevel.

@Subcommand("skill setlevel")
@CommandCompletion("@players @skills")
@CommandPermission("aureliumskills.skill.setlevel")
@Description("Sets a specific skill to a level for a player.")
public void onSkillSetlevel(CommandSender sender, @Flags("other") Player player, Skill skill, int level) {
    Locale locale = plugin.getLang().getLocale(sender);
    if (OptionL.isEnabled(skill)) {
        if (level > 0) {
            PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
            if (playerData == null)
                return;
            int oldLevel = playerData.getSkillLevel(skill);
            playerData.setSkillLevel(skill, level);
            playerData.setSkillXp(skill, 0);
            plugin.getLeveler().updateStats(player);
            plugin.getLeveler().updatePermissions(player);
            plugin.getLeveler().applyRevertCommands(player, skill, oldLevel, level);
            plugin.getLeveler().applyLevelUpCommands(player, skill, oldLevel, level);
            // Reload items and armor to check for newly met requirements
            this.plugin.getModifierManager().reloadPlayer(player);
            sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_SETLEVEL_SET, locale).replace("{skill}", skill.getDisplayName(locale)).replace("{level}", String.valueOf(level)).replace("{player}", player.getName()));
        } else {
            sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_SETLEVEL_AT_LEAST_ONE, locale));
        }
    } else {
        sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.UNKNOWN_SKILL, locale));
    }
}
Also used : Locale(java.util.Locale) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 3 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class SkillsCommand method onRemove.

@Subcommand("modifier remove")
@CommandPermission("aureliumskills.modifier.remove")
@CommandCompletion("@players @modifiers true")
@Description("Removes a specific stat modifier from a player.")
public void onRemove(CommandSender sender, @Flags("other") Player player, String name, @Default("false") boolean silent) {
    Locale locale = plugin.getLang().getLocale(sender);
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData != null) {
        if (playerData.removeStatModifier(name)) {
            if (!silent) {
                sender.sendMessage(AureliumSkills.getPrefix(locale) + StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_REMOVE_REMOVED, locale), name, player));
            }
        } else {
            if (!silent) {
                sender.sendMessage(AureliumSkills.getPrefix(locale) + StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_REMOVE_NOT_FOUND, locale), name, player));
            }
        }
    } else {
        if (!silent) {
            sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.NO_PROFILE, locale));
        }
    }
}
Also used : Locale(java.util.Locale) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 4 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class SkillsCommand method onAdd.

@Subcommand("modifier add")
@CommandPermission("aureliumskills.modifier.add")
@CommandCompletion("@players @stats @nothing @nothing true")
@Description("Adds a stat modifier to a player.")
public void onAdd(CommandSender sender, @Flags("other") Player player, Stat stat, String name, double value, @Default("false") boolean silent) {
    Locale locale = plugin.getLang().getLocale(sender);
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData != null) {
        StatModifier modifier = new StatModifier(name, stat, value);
        if (!playerData.getStatModifiers().containsKey(name)) {
            playerData.addStatModifier(modifier);
            if (!silent) {
                sender.sendMessage(AureliumSkills.getPrefix(locale) + StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_ADD_ADDED, locale), modifier, player, locale));
            }
        } else {
            if (!silent) {
                sender.sendMessage(AureliumSkills.getPrefix(locale) + StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_ADD_ALREADY_EXISTS, locale), modifier, player, locale));
            }
        }
    } else {
        if (!silent) {
            sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.NO_PROFILE, locale));
        }
    }
}
Also used : Locale(java.util.Locale) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 5 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData 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

PlayerData (com.archyx.aureliumskills.data.PlayerData)111 Player (org.bukkit.entity.Player)54 EventHandler (org.bukkit.event.EventHandler)43 Locale (java.util.Locale)27 ItemStack (org.bukkit.inventory.ItemStack)25 Skill (com.archyx.aureliumskills.skills.Skill)15 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 Stat (com.archyx.aureliumskills.stats.Stat)9 AttributeInstance (org.bukkit.attribute.AttributeInstance)8 PlayerLootDropEvent (com.archyx.aureliumskills.api.event.PlayerLootDropEvent)7 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)7 Material (org.bukkit.Material)7 LivingEntity (org.bukkit.entity.LivingEntity)7 KeyIntPair (com.archyx.aureliumskills.util.misc.KeyIntPair)6 AureliumSkills (com.archyx.aureliumskills.AureliumSkills)5 OptionL (com.archyx.aureliumskills.configuration.OptionL)5 AbilityData (com.archyx.aureliumskills.data.AbilityData)5 File (java.io.File)5 IOException (java.io.IOException)5 PlayerDataLoadEvent (com.archyx.aureliumskills.data.PlayerDataLoadEvent)4