Search in sources :

Example 1 with ExperienceCalculatorManager

use of de.Keyle.MyPet.api.skill.experience.ExperienceCalculatorManager in project MyPet by xXKeyleXx.

the class CommandOptionReload method reloadConfig.

protected void reloadConfig(CommandSender sender) {
    int oldMaxPetCount = Configuration.Misc.MAX_STORED_PET_COUNT;
    ConfigurationLoader.loadConfiguration();
    ConfigurationLoader.loadCompatConfiguration();
    if (MyPetApi.getLogger() instanceof MyPetLogger) {
        ((MyPetLogger) MyPetApi.getLogger()).updateDebugLoggerLogLevel();
    }
    Translation.init();
    if (Configuration.Misc.MAX_STORED_PET_COUNT > oldMaxPetCount) {
        for (int i = oldMaxPetCount + 1; i <= Configuration.Misc.MAX_STORED_PET_COUNT; i++) {
            try {
                Bukkit.getPluginManager().addPermission(new Permission("MyPet.petstorage.limit." + i));
            } catch (Exception ignored) {
            }
        }
    } else if (oldMaxPetCount > Configuration.Misc.MAX_STORED_PET_COUNT) {
        for (int i = oldMaxPetCount; i > Configuration.Misc.MAX_STORED_PET_COUNT; i--) {
            try {
                Bukkit.getPluginManager().removePermission("MyPet.petstorage.limit." + i);
            } catch (Exception ignored) {
            }
        }
    }
    ExperienceCalculatorManager calculatorManager = MyPetApi.getServiceManager().getService(ExperienceCalculatorManager.class).get();
    calculatorManager.switchCalculator(Configuration.LevelSystem.CALCULATION_MODE);
    MyPetApi.getPluginHookManager().getConfig().loadConfig();
    for (PluginHook hook : MyPetApi.getPluginHookManager().getHooks()) {
        ConfigurationSection pluginSection = MyPetApi.getPluginHookManager().getConfig().getConfig().getConfigurationSection(hook.getPluginName());
        if (pluginSection != null) {
            hook.loadConfig(pluginSection);
        }
    }
    if (!(sender instanceof ConsoleCommandSender)) {
        sender.sendMessage("[" + ChatColor.DARK_GREEN + "MyPet" + ChatColor.RESET + "] config reloaded!");
    }
    MyPetApi.getLogger().info("Config reloaded!");
}
Also used : ExperienceCalculatorManager(de.Keyle.MyPet.api.skill.experience.ExperienceCalculatorManager) Permission(org.bukkit.permissions.Permission) MyPetLogger(de.Keyle.MyPet.api.util.logger.MyPetLogger) PluginHook(de.Keyle.MyPet.api.util.hooks.PluginHook) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

ExperienceCalculatorManager (de.Keyle.MyPet.api.skill.experience.ExperienceCalculatorManager)1 PluginHook (de.Keyle.MyPet.api.util.hooks.PluginHook)1 MyPetLogger (de.Keyle.MyPet.api.util.logger.MyPetLogger)1 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 Permission (org.bukkit.permissions.Permission)1