Search in sources :

Example 1 with MageDataStore

use of com.elmakers.mine.bukkit.api.data.MageDataStore in project MagicPlugin by elBukkit.

the class MagicController method loadProperties.

protected void loadProperties(ConfigurationSection properties) {
    if (properties == null)
        return;
    // Cancel any pending save tasks
    if (autoSaveTaskId > 0) {
        Bukkit.getScheduler().cancelTask(autoSaveTaskId);
        autoSaveTaskId = 0;
    }
    EffectPlayer.debugEffects(properties.getBoolean("debug_effects", false));
    CompatibilityUtils.USE_MAGIC_DAMAGE = properties.getBoolean("use_magic_damage", CompatibilityUtils.USE_MAGIC_DAMAGE);
    EffectPlayer.setParticleRange(properties.getInt("particle_range", EffectPlayer.PARTICLE_RANGE));
    resourcePackPrompt = properties.getBoolean("resource_pack_prompt", false);
    enableResourcePackCheck = properties.getBoolean("enable_resource_pack_check", true);
    resourcePackCheckInterval = properties.getInt("resource_pack_check_interval", 0);
    defaultResourcePack = properties.getString("resource_pack", null);
    // For legacy configs
    defaultResourcePack = properties.getString("default_resource_pack", defaultResourcePack);
    // For combined configs
    if (addExamples != null && addExamples.size() > 0 && !defaultResourcePack.isEmpty()) {
        defaultResourcePack = properties.getString("add_resource_pack", defaultResourcePack);
    }
    if (!properties.getBoolean("enable_resource_pack")) {
        defaultResourcePack = null;
    }
    // For reloading after disabling the RP
    if (defaultResourcePack == null || defaultResourcePack.isEmpty()) {
        resourcePack = null;
        resourcePackHash = null;
    }
    resourcePackDelay = properties.getLong("resource_pack_delay", 0);
    showCastHoloText = properties.getBoolean("show_cast_holotext", showCastHoloText);
    showActivateHoloText = properties.getBoolean("show_activate_holotext", showCastHoloText);
    castHoloTextRange = properties.getInt("cast_holotext_range", castHoloTextRange);
    activateHoloTextRange = properties.getInt("activate_holotext_range", activateHoloTextRange);
    urlIconsEnabled = properties.getBoolean("url_icons_enabled", urlIconsEnabled);
    spellUpgradesEnabled = properties.getBoolean("enable_spell_upgrades", spellUpgradesEnabled);
    spellProgressionEnabled = properties.getBoolean("enable_spell_progression", spellProgressionEnabled);
    autoSpellUpgradesEnabled = properties.getBoolean("enable_automatic_spell_upgrades", autoSpellUpgradesEnabled);
    autoPathUpgradesEnabled = properties.getBoolean("enable_automatic_spell_upgrades", autoPathUpgradesEnabled);
    undoQueueDepth = properties.getInt("undo_depth", undoQueueDepth);
    workPerUpdate = properties.getInt("work_per_update", workPerUpdate);
    workFrequency = properties.getInt("work_frequency", workFrequency);
    mageUpdateFrequency = properties.getInt("mage_update_frequency", mageUpdateFrequency);
    undoFrequency = properties.getInt("undo_frequency", undoFrequency);
    pendingQueueDepth = properties.getInt("pending_depth", pendingQueueDepth);
    undoMaxPersistSize = properties.getInt("undo_max_persist_size", undoMaxPersistSize);
    commitOnQuit = properties.getBoolean("commit_on_quit", commitOnQuit);
    saveNonPlayerMages = properties.getBoolean("save_non_player_mages", saveNonPlayerMages);
    defaultWandPath = properties.getString("default_wand_path", "");
    Wand.DEFAULT_WAND_TEMPLATE = properties.getString("default_wand", "");
    defaultWandMode = Wand.parseWandMode(properties.getString("default_wand_mode", ""), defaultWandMode);
    defaultBrushMode = Wand.parseWandMode(properties.getString("default_brush_mode", ""), defaultBrushMode);
    backupInventories = properties.getBoolean("backup_player_inventory", true);
    Wand.brushSelectSpell = properties.getString("brush_select_spell", Wand.brushSelectSpell);
    showMessages = properties.getBoolean("show_messages", showMessages);
    showCastMessages = properties.getBoolean("show_cast_messages", showCastMessages);
    messageThrottle = properties.getInt("message_throttle", 0);
    soundsEnabled = properties.getBoolean("sounds", soundsEnabled);
    fillingEnabled = properties.getBoolean("fill_wands", fillingEnabled);
    maxFillLevel = properties.getInt("fill_wand_level", maxFillLevel);
    welcomeWand = properties.getString("welcome_wand", "");
    maxDamagePowerMultiplier = (float) properties.getDouble("max_power_damage_multiplier", maxDamagePowerMultiplier);
    maxConstructionPowerMultiplier = (float) properties.getDouble("max_power_construction_multiplier", maxConstructionPowerMultiplier);
    maxRangePowerMultiplier = (float) properties.getDouble("max_power_range_multiplier", maxRangePowerMultiplier);
    maxRangePowerMultiplierMax = (float) properties.getDouble("max_power_range_multiplier_max", maxRangePowerMultiplierMax);
    maxRadiusPowerMultiplier = (float) properties.getDouble("max_power_radius_multiplier", maxRadiusPowerMultiplier);
    maxRadiusPowerMultiplierMax = (float) properties.getDouble("max_power_radius_multiplier_max", maxRadiusPowerMultiplierMax);
    maxPower = (float) properties.getDouble("max_power", maxPower);
    ConfigurationSection damageTypes = properties.getConfigurationSection("damage_types");
    if (damageTypes != null) {
        Set<String> typeKeys = damageTypes.getKeys(false);
        for (String typeKey : typeKeys) {
            ConfigurationSection damageType = damageTypes.getConfigurationSection(typeKey);
            this.damageTypes.put(typeKey, new DamageType(damageType));
        }
    }
    maxCostReduction = (float) properties.getDouble("max_cost_reduction", maxCostReduction);
    maxCooldownReduction = (float) properties.getDouble("max_cooldown_reduction", maxCooldownReduction);
    maxMana = properties.getInt("max_mana", maxMana);
    maxManaRegeneration = properties.getInt("max_mana_regeneration", maxManaRegeneration);
    worthSkillPoints = properties.getDouble("worth_sp", 1);
    skillPointIcon = properties.getString("sp_item_icon_url");
    skillPointItemsEnabled = properties.getBoolean("sp_items_enabled", true);
    worthBase = properties.getDouble("worth_base", 1);
    worthXP = properties.getDouble("worth_xp", 1);
    ConfigurationSection currencies = properties.getConfigurationSection("currency");
    if (currencies != null) {
        Collection<String> worthItemKeys = currencies.getKeys(true);
        for (String worthItemKey : worthItemKeys) {
            MaterialAndData material = new MaterialAndData(worthItemKey);
            ConfigurationSection currencyConfig = currencies.getConfigurationSection(worthItemKey);
            ItemStack worthItemType = material.getItemStack(1);
            double worthItemAmount = currencyConfig.getDouble("worth");
            String worthItemName = currencyConfig.getString("name");
            String worthItemNamePlural = currencyConfig.getString("name_plural");
            currencyItem = new CurrencyItem(worthItemType, worthItemAmount, worthItemName, worthItemNamePlural);
            break;
        }
    } else {
        currencyItem = null;
    }
    SafetyUtils.MAX_VELOCITY = properties.getDouble("max_velocity", 10);
    HitboxUtils.setHitboxScale(properties.getDouble("hitbox_scale", 1.0));
    HitboxUtils.setHitboxScaleY(properties.getDouble("hitbox_scale_y", 1.0));
    HitboxUtils.setHitboxSneakScaleY(properties.getDouble("hitbox_sneaking_scale_y", 0.75));
    if (properties.contains("hitboxes")) {
        HitboxUtils.configureHitboxes(properties.getConfigurationSection("hitboxes"));
    }
    if (properties.contains("head_sizes")) {
        HitboxUtils.configureHeadSizes(properties.getConfigurationSection("head_sizes"));
    }
    if (properties.contains("max_height")) {
        HitboxUtils.configureMaxHeights(properties.getConfigurationSection("max_height"));
    }
    if (properties.contains("cast_command_cost_reduction")) {
        castCommandCostFree = (properties.getDouble("cast_command_cost_reduction") > 0);
    } else {
        castCommandCostFree = properties.getBoolean("cast_command_cost_free", castCommandCostFree);
    }
    if (properties.contains("cast_command_cooldown_reduction")) {
        castCommandCooldownFree = (properties.getDouble("cast_command_cooldown_reduction") > 0);
    } else {
        castCommandCooldownFree = properties.getBoolean("cast_command_cooldown_free", castCommandCooldownFree);
    }
    if (properties.contains("cast_console_cost_reduction")) {
        castConsoleCostFree = (properties.getDouble("cast_console_cost_reduction") > 0);
    } else {
        castConsoleCostFree = properties.getBoolean("cast_console_cost_free", castConsoleCostFree);
    }
    if (properties.contains("cast_console_cooldown_reduction")) {
        castConsoleCooldownFree = (properties.getDouble("cast_console_cooldown_reduction") > 0);
    } else {
        castConsoleCooldownFree = properties.getBoolean("cast_console_cooldown_free", castConsoleCooldownFree);
    }
    castCommandPowerMultiplier = (float) properties.getDouble("cast_command_power_multiplier", castCommandPowerMultiplier);
    castConsolePowerMultiplier = (float) properties.getDouble("cast_console_power_multiplier", castConsolePowerMultiplier);
    maps.setAnimationAllowed(properties.getBoolean("enable_map_animations", true));
    costReduction = (float) properties.getDouble("cost_reduction", costReduction);
    cooldownReduction = (float) properties.getDouble("cooldown_reduction", cooldownReduction);
    autoUndo = properties.getInt("auto_undo", autoUndo);
    spellDroppingEnabled = properties.getBoolean("allow_spell_dropping", spellDroppingEnabled);
    essentialsSignsEnabled = properties.getBoolean("enable_essentials_signs", essentialsSignsEnabled);
    citizensEnabled = properties.getBoolean("enable_citizens", citizensEnabled);
    dynmapShowWands = properties.getBoolean("dynmap_show_wands", dynmapShowWands);
    dynmapShowSpells = properties.getBoolean("dynmap_show_spells", dynmapShowSpells);
    dynmapOnlyPlayerSpells = properties.getBoolean("dynmap_only_player_spells", dynmapOnlyPlayerSpells);
    dynmapUpdate = properties.getBoolean("dynmap_update", dynmapUpdate);
    protectLocked = properties.getBoolean("protected_locked", protectLocked);
    bindOnGive = properties.getBoolean("bind_on_give", bindOnGive);
    bypassBuildPermissions = properties.getBoolean("bypass_build", bypassBuildPermissions);
    bypassBreakPermissions = properties.getBoolean("bypass_break", bypassBreakPermissions);
    bypassPvpPermissions = properties.getBoolean("bypass_pvp", bypassPvpPermissions);
    bypassFriendlyFire = properties.getBoolean("bypass_friendly_fire", bypassFriendlyFire);
    useScoreboardTeams = properties.getBoolean("use_scoreboard_teams", useScoreboardTeams);
    defaultFriendly = properties.getBoolean("default_friendly", defaultFriendly);
    extraSchematicFilePath = properties.getString("schematic_files", extraSchematicFilePath);
    createWorldsEnabled = properties.getBoolean("enable_world_creation", createWorldsEnabled);
    defaultSkillIcon = properties.getString("default_skill_icon", defaultSkillIcon);
    skillInventoryRows = properties.getInt("skill_inventory_max_rows", skillInventoryRows);
    InventoryUtils.MAX_LORE_LENGTH = properties.getInt("lore_wrap_limit", InventoryUtils.MAX_LORE_LENGTH);
    libsDisguiseEnabled = properties.getBoolean("enable_libsdisguises", libsDisguiseEnabled);
    skillAPIEnabled = properties.getBoolean("skillapi_enabled", skillAPIEnabled);
    useSkillAPIMana = properties.getBoolean("use_skillapi_mana", useSkillAPIMana);
    placeholdersEnabled = properties.getBoolean("placeholder_api_enabled", placeholdersEnabled);
    lightAPIEnabled = properties.getBoolean("light_api_enabled", lightAPIEnabled);
    skriptEnabled = properties.getBoolean("skript_enabled", skriptEnabled);
    citadelConfiguration = properties.getConfigurationSection("citadel");
    mobArenaConfiguration = properties.getConfigurationSection("mobarena");
    if (mobArenaManager != null) {
        mobArenaManager.configure(mobArenaConfiguration);
    }
    skillsUseHeroes = properties.getBoolean("skills_use_heroes", skillsUseHeroes);
    useHeroesParties = properties.getBoolean("use_heroes_parties", useHeroesParties);
    useHeroesMana = properties.getBoolean("use_heroes_mana", useHeroesMana);
    heroesSkillPrefix = properties.getString("heroes_skill_prefix", heroesSkillPrefix);
    skillsUsePermissions = properties.getBoolean("skills_use_permissions", skillsUsePermissions);
    messagePrefix = properties.getString("message_prefix", messagePrefix);
    castMessagePrefix = properties.getString("cast_message_prefix", castMessagePrefix);
    redstoneReplacement = ConfigurationUtils.getMaterialAndData(properties, "redstone_replacement", redstoneReplacement);
    messagePrefix = ChatColor.translateAlternateColorCodes('&', messagePrefix);
    castMessagePrefix = ChatColor.translateAlternateColorCodes('&', castMessagePrefix);
    worldGuardManager.setEnabled(properties.getBoolean("region_manager_enabled", worldGuardManager.isEnabled()));
    factionsManager.setEnabled(properties.getBoolean("factions_enabled", factionsManager.isEnabled()));
    pvpManager.setEnabled(properties.getBoolean("pvp_manager_enabled", pvpManager.isEnabled()));
    multiverseManager.setEnabled(properties.getBoolean("multiverse_enabled", multiverseManager.isEnabled()));
    preciousStonesManager.setEnabled(properties.getBoolean("precious_stones_enabled", preciousStonesManager.isEnabled()));
    preciousStonesManager.setOverride(properties.getBoolean("precious_stones_override", true));
    townyManager.setEnabled(properties.getBoolean("towny_enabled", townyManager.isEnabled()));
    townyManager.setWildernessBypass(properties.getBoolean("towny_wilderness_bypass", true));
    locketteManager.setEnabled(properties.getBoolean("lockette_enabled", locketteManager.isEnabled()));
    griefPreventionManager.setEnabled(properties.getBoolean("grief_prevention_enabled", griefPreventionManager.isEnabled()));
    ncpManager.setEnabled(properties.getBoolean("ncp_enabled", false));
    metricsLevel = properties.getInt("metrics_level", metricsLevel);
    Wand.regenWhileInactive = properties.getBoolean("regenerate_while_inactive", Wand.regenWhileInactive);
    if (properties.contains("mana_display")) {
        String manaDisplay = properties.getString("mana_display");
        if (manaDisplay.equalsIgnoreCase("bar") || manaDisplay.equalsIgnoreCase("hybrid")) {
            Wand.manaMode = WandManaMode.BAR;
        } else if (manaDisplay.equalsIgnoreCase("number")) {
            Wand.manaMode = WandManaMode.NUMBER;
        } else if (manaDisplay.equalsIgnoreCase("durability")) {
            Wand.manaMode = WandManaMode.DURABILITY;
        } else if (manaDisplay.equalsIgnoreCase("glow")) {
            Wand.manaMode = WandManaMode.GLOW;
        } else if (manaDisplay.equalsIgnoreCase("none")) {
            Wand.manaMode = WandManaMode.NONE;
        }
    }
    if (properties.contains("sp_display")) {
        String spDisplay = properties.getString("sp_display");
        if (spDisplay.equalsIgnoreCase("number")) {
            Wand.spMode = WandManaMode.NUMBER;
        } else {
            Wand.spMode = WandManaMode.NONE;
        }
    }
    spEnabled = properties.getBoolean("sp_enabled", true);
    spEarnEnabled = properties.getBoolean("sp_earn_enabled", true);
    spMaximum = properties.getInt("sp_max", 9999);
    populateEntityTypes(undoEntityTypes, properties, "entity_undo_types");
    populateEntityTypes(friendlyEntityTypes, properties, "friendly_entity_types");
    String defaultLocationString = properties.getString("default_cast_location");
    try {
        com.elmakers.mine.bukkit.magic.Mage.DEFAULT_CAST_LOCATION = CastSourceLocation.valueOf(defaultLocationString.toUpperCase());
    } catch (Exception ex) {
        com.elmakers.mine.bukkit.magic.Mage.DEFAULT_CAST_LOCATION = CastSourceLocation.MAINHAND;
        getLogger().warning("Invalid default_cast_location: " + defaultLocationString);
    }
    com.elmakers.mine.bukkit.magic.Mage.DEFAULT_CAST_OFFSET.setZ(properties.getDouble("default_cast_location_offset", com.elmakers.mine.bukkit.magic.Mage.DEFAULT_CAST_OFFSET.getZ()));
    com.elmakers.mine.bukkit.magic.Mage.DEFAULT_CAST_OFFSET.setY(properties.getDouble("default_cast_location_offset_vertical", com.elmakers.mine.bukkit.magic.Mage.DEFAULT_CAST_OFFSET.getY()));
    com.elmakers.mine.bukkit.magic.Mage.OFFHAND_CAST_COOLDOWN = properties.getInt("offhand_cast_cooldown", com.elmakers.mine.bukkit.magic.Mage.OFFHAND_CAST_COOLDOWN);
    com.elmakers.mine.bukkit.magic.Mage.SNEAKING_CAST_OFFSET = properties.getDouble("sneaking_cast_location_offset_vertical", com.elmakers.mine.bukkit.magic.Mage.SNEAKING_CAST_OFFSET);
    // Parse wand settings
    Wand.DefaultUpgradeMaterial = ConfigurationUtils.getMaterial(properties, "wand_upgrade_item", Wand.DefaultUpgradeMaterial);
    Wand.SpellGlow = properties.getBoolean("spell_glow", Wand.SpellGlow);
    Wand.LiveHotbarSkills = properties.getBoolean("live_hotbar_skills", Wand.LiveHotbarSkills);
    Wand.LiveHotbar = properties.getBoolean("live_hotbar", Wand.LiveHotbar);
    Wand.LiveHotbarCooldown = properties.getBoolean("live_hotbar_cooldown", Wand.LiveHotbar);
    Wand.BrushGlow = properties.getBoolean("brush_glow", Wand.BrushGlow);
    Wand.BrushItemGlow = properties.getBoolean("brush_item_glow", Wand.BrushItemGlow);
    Wand.WAND_KEY = properties.getString("wand_key", "wand");
    Wand.UPGRADE_KEY = properties.getString("wand_upgrade_key", "wand");
    Wand.WAND_SELF_DESTRUCT_KEY = properties.getString("wand_self_destruct_key", "");
    if (Wand.WAND_SELF_DESTRUCT_KEY.isEmpty()) {
        Wand.WAND_SELF_DESTRUCT_KEY = null;
    }
    Wand.HIDE_FLAGS = (byte) properties.getInt("wand_hide_flags", Wand.HIDE_FLAGS);
    Wand.Unbreakable = properties.getBoolean("wand_unbreakable", Wand.Unbreakable);
    Wand.Unstashable = properties.getBoolean("wand_undroppable", properties.getBoolean("wand_unstashable", Wand.Unstashable));
    MaterialBrush.CopyMaterial = ConfigurationUtils.getMaterialAndData(properties, "copy_item", MaterialBrush.CopyMaterial);
    MaterialBrush.EraseMaterial = ConfigurationUtils.getMaterialAndData(properties, "erase_item", MaterialBrush.EraseMaterial);
    MaterialBrush.CloneMaterial = ConfigurationUtils.getMaterialAndData(properties, "clone_item", MaterialBrush.CloneMaterial);
    MaterialBrush.ReplicateMaterial = ConfigurationUtils.getMaterialAndData(properties, "replicate_item", MaterialBrush.ReplicateMaterial);
    MaterialBrush.SchematicMaterial = ConfigurationUtils.getMaterialAndData(properties, "schematic_item", MaterialBrush.SchematicMaterial);
    MaterialBrush.MapMaterial = ConfigurationUtils.getMaterialAndData(properties, "map_item", MaterialBrush.MapMaterial);
    MaterialBrush.DefaultBrushMaterial = ConfigurationUtils.getMaterialAndData(properties, "default_brush_item", MaterialBrush.DefaultBrushMaterial);
    MaterialBrush.configureReplacements(properties.getConfigurationSection("brush_replacements"));
    MaterialBrush.CopyCustomIcon = properties.getString("copy_icon_url", MaterialBrush.CopyCustomIcon);
    MaterialBrush.EraseCustomIcon = properties.getString("erase_icon_url", MaterialBrush.EraseCustomIcon);
    MaterialBrush.CloneCustomIcon = properties.getString("clone_icon_url", MaterialBrush.CloneCustomIcon);
    MaterialBrush.ReplicateCustomIcon = properties.getString("replicate_icon_url", MaterialBrush.ReplicateCustomIcon);
    MaterialBrush.SchematicCustomIcon = properties.getString("schematic_icon_url", MaterialBrush.SchematicCustomIcon);
    MaterialBrush.MapCustomIcon = properties.getString("map_icon_url", MaterialBrush.MapCustomIcon);
    MaterialBrush.DefaultBrushCustomIcon = properties.getString("default_brush_icon_url", MaterialBrush.DefaultBrushCustomIcon);
    BaseSpell.DEFAULT_DISABLED_ICON_URL = properties.getString("disabled_icon_url", BaseSpell.DEFAULT_DISABLED_ICON_URL);
    Wand.DEFAULT_CAST_OFFSET.setZ(properties.getDouble("wand_location_offset", Wand.DEFAULT_CAST_OFFSET.getZ()));
    Wand.DEFAULT_CAST_OFFSET.setY(properties.getDouble("wand_location_offset_vertical", Wand.DEFAULT_CAST_OFFSET.getY()));
    com.elmakers.mine.bukkit.magic.Mage.JUMP_EFFECT_FLIGHT_EXEMPTION_DURATION = properties.getInt("jump_exemption", 0);
    com.elmakers.mine.bukkit.magic.Mage.CHANGE_WORLD_EQUIP_COOLDOWN = properties.getInt("change_world_equip_cooldown", 0);
    com.elmakers.mine.bukkit.magic.Mage.DEACTIVATE_WAND_ON_WORLD_CHANGE = properties.getBoolean("close_wand_on_world_change", false);
    com.elmakers.mine.bukkit.magic.Mage.DEFAULT_SP = properties.getInt("sp_default", 0);
    Wand.inventoryOpenSound = ConfigurationUtils.toSoundEffect(properties.getString("wand_inventory_open_sound"));
    Wand.inventoryCloseSound = ConfigurationUtils.toSoundEffect(properties.getString("wand_inventory_close_sound"));
    Wand.inventoryCycleSound = ConfigurationUtils.toSoundEffect(properties.getString("wand_inventory_cycle_sound"));
    Wand.noActionSound = ConfigurationUtils.toSoundEffect(properties.getString("wand_no_action_sound"));
    if (blockPhysicsManager != null) {
        blockPhysicsManager.setVelocityScale(properties.getDouble("block_physics_velocity_scale", 1));
    }
    // Configure sub-controllers
    explosionController.loadProperties(properties);
    inventoryController.loadProperties(properties);
    blockController.setUndoOnWorldSave(properties.getBoolean("undo_on_world_save", false));
    blockController.setCreativeBreakFrequency(properties.getInt("prevent_creative_breaking", 0));
    entityController.loadProperties(properties);
    playerController.loadProperties(properties);
    // Set up other systems
    EffectPlayer.SOUNDS_ENABLED = soundsEnabled;
    // Set up auto-save timer
    final AutoSaveTask autoSave = new AutoSaveTask(this);
    int autoSaveIntervalTicks = properties.getInt("auto_save", 0) * 20 / 1000;
    ;
    if (autoSaveIntervalTicks > 1) {
        autoSaveTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoSave, autoSaveIntervalTicks, autoSaveIntervalTicks);
    }
    savePlayerData = properties.getBoolean("save_player_data", true);
    externalPlayerData = properties.getBoolean("external_player_data", false);
    if (externalPlayerData) {
        getLogger().info("Magic is expecting player data to be loaded from an external source");
    } else if (!savePlayerData) {
        getLogger().info("Magic player data saving is disabled");
    }
    asynchronousSaving = properties.getBoolean("save_player_data_asynchronously", true);
    ConfigurationSection mageDataStore = properties.getConfigurationSection("player_data_store");
    if (mageDataStore != null) {
        String dataStoreClassName = mageDataStore.getString("class");
        try {
            Class<?> dataStoreClass = Class.forName(dataStoreClassName);
            Object dataStore = dataStoreClass.getDeclaredConstructor().newInstance();
            if (dataStore == null || !(dataStore instanceof MageDataStore)) {
                getLogger().log(Level.WARNING, "Invalid player_data_store class " + dataStoreClassName + ", does it implement MageDataStore? Player data saving is disabled!");
                this.mageDataStore = null;
            } else {
                this.mageDataStore = (MageDataStore) dataStore;
                this.mageDataStore.initialize(this, mageDataStore);
            }
        } catch (Exception ex) {
            getLogger().log(Level.WARNING, "Failed to create player_data_store class from " + dataStoreClassName + " player data saving is disabled!", ex);
            this.mageDataStore = null;
        }
    } else {
        getLogger().log(Level.WARNING, "Missing player_data_store configuration, player data saving disabled!");
        this.mageDataStore = null;
    }
    useBlockPhysics = properties.getBoolean("enable_block_physics", true);
    // Semi-deprecated Wand defaults
    Wand.DefaultWandMaterial = ConfigurationUtils.getMaterial(properties, "wand_item", Wand.DefaultWandMaterial);
    Wand.EnchantableWandMaterial = ConfigurationUtils.getMaterial(properties, "wand_item_enchantable", Wand.EnchantableWandMaterial);
    // Load sub-controllers
    enchanting.setEnabled(properties.getBoolean("enable_enchanting", enchanting.isEnabled()));
    if (enchanting.isEnabled()) {
        getLogger().info("Wand enchanting is enabled");
    }
    crafting.setEnabled(properties.getBoolean("enable_crafting", crafting.isEnabled()));
    if (crafting.isEnabled()) {
        getLogger().info("Wand crafting is enabled");
    }
    anvil.load(properties);
    if (anvil.isCombiningEnabled()) {
        getLogger().info("Wand anvil combining is enabled");
    }
    if (anvil.isOrganizingEnabled()) {
        getLogger().info("Wand anvil organizing is enabled");
    }
    if (isUrlIconsEnabled()) {
        getLogger().info("Skin-based spell icons enabled");
    } else {
        getLogger().info("Skin-based spell icons disabled");
    }
}
Also used : InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException) IOException(java.io.IOException) ParseException(java.text.ParseException) MageDataStore(com.elmakers.mine.bukkit.api.data.MageDataStore) CurrencyItem(com.elmakers.mine.bukkit.api.block.CurrencyItem) MaterialAndData(com.elmakers.mine.bukkit.block.MaterialAndData) ItemStack(org.bukkit.inventory.ItemStack) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

CurrencyItem (com.elmakers.mine.bukkit.api.block.CurrencyItem)1 MageDataStore (com.elmakers.mine.bukkit.api.data.MageDataStore)1 MaterialAndData (com.elmakers.mine.bukkit.block.MaterialAndData)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)1 ItemStack (org.bukkit.inventory.ItemStack)1