Search in sources :

Example 1 with Luck

use of com.archyx.aureliumskills.stats.Luck in project AureliumSkills by Archy-X.

the class ReloadManager method reload.

public void reload(CommandSender sender) {
    Locale locale = plugin.getLang().getLocale(sender);
    // Load config
    plugin.reloadConfig();
    plugin.saveDefaultConfig();
    plugin.getOptionLoader().loadOptions();
    plugin.getRequirementManager().load();
    // Load sources_config
    plugin.getSourceManager().loadSources();
    plugin.getCheckBlockReplace().reloadCustomBlocks();
    // Load rewards
    plugin.getRewardManager().loadRewards();
    // Load language files
    lang.loadLanguageFiles();
    lang.loadEmbeddedMessages(plugin.getCommandManager());
    lang.loadLanguages(plugin.getCommandManager());
    // Load menus
    try {
        plugin.getMenuLoader().load();
    } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
        e.printStackTrace();
        if (sender instanceof Player) {
            sender.sendMessage(ChatColor.YELLOW + "[AureliumSkills] Error while loading menus, see console for details");
        } else {
            Bukkit.getLogger().warning("[AureliumSkills] Error while loading menus!");
        }
    }
    // Load ability_config
    plugin.getAbilityManager().loadOptions();
    plugin.getLeveler().loadLevelRequirements();
    // Load loot tables
    plugin.getLootTableManager().loadLootTables();
    // Load worlds and regions
    plugin.getWorldManager().loadWorlds();
    if (plugin.isWorldGuardEnabled()) {
        plugin.getWorldGuardSupport().loadRegions();
    }
    // Recalculate health and luck stats
    Luck luck = new Luck(plugin);
    for (Player player : Bukkit.getOnlinePlayers()) {
        plugin.getHealth().reload(player);
        luck.reload(player);
    }
    // Resets all action bars
    plugin.getActionBar().resetActionBars();
    // Load boss bars
    plugin.getBossBar().loadOptions();
    sender.sendMessage(AureliumSkills.getPrefix(locale) + ChatColor.GREEN + Lang.getMessage(CommandMessage.RELOAD, locale));
}
Also used : Locale(java.util.Locale) Player(org.bukkit.entity.Player) Luck(com.archyx.aureliumskills.stats.Luck) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with Luck

use of com.archyx.aureliumskills.stats.Luck in project AureliumSkills by Archy-X.

the class PlayerData method addStatModifier.

public void addStatModifier(StatModifier modifier, boolean reload) {
    // Removes if already existing
    if (statModifiers.containsKey(modifier.getName())) {
        StatModifier oldModifier = statModifiers.get(modifier.getName());
        if (oldModifier.getStat() == modifier.getStat() && oldModifier.getValue() == modifier.getValue()) {
            return;
        }
        removeStatModifier(modifier.getName());
    }
    statModifiers.put(modifier.getName(), modifier);
    setStatLevel(modifier.getStat(), getStatLevel(modifier.getStat()) + modifier.getValue());
    // Reloads stats
    if (reload) {
        if (modifier.getStat() == Stats.HEALTH) {
            plugin.getHealth().reload(player);
        } else if (modifier.getStat() == Stats.LUCK) {
            new Luck(plugin).reload(player);
        }
    }
}
Also used : StatModifier(com.archyx.aureliumskills.modifier.StatModifier) Luck(com.archyx.aureliumskills.stats.Luck)

Example 3 with Luck

use of com.archyx.aureliumskills.stats.Luck in project AureliumSkills by Archy-X.

the class PlayerData method removeStatModifier.

public boolean removeStatModifier(String name, boolean reload) {
    StatModifier modifier = statModifiers.get(name);
    if (modifier == null)
        return false;
    setStatLevel(modifier.getStat(), statLevels.get(modifier.getStat()) - modifier.getValue());
    statModifiers.remove(name);
    // Reloads stats
    if (reload) {
        if (modifier.getStat() == Stats.HEALTH) {
            plugin.getHealth().reload(player);
        } else if (modifier.getStat() == Stats.LUCK) {
            new Luck(plugin).reload(player);
        }
    }
    return true;
}
Also used : StatModifier(com.archyx.aureliumskills.modifier.StatModifier) Luck(com.archyx.aureliumskills.stats.Luck)

Aggregations

Luck (com.archyx.aureliumskills.stats.Luck)3 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Locale (java.util.Locale)1 Player (org.bukkit.entity.Player)1