Search in sources :

Example 1 with SkillAPIManager

use of com.elmakers.mine.bukkit.integration.SkillAPIManager in project MagicPlugin by elBukkit.

the class MagicController method finalizeIntegrationPostLoad.

public void finalizeIntegrationPostLoad(ConfigurationSection mainConfiguration) {
    logger.setContext("integration");
    final PluginManager pluginManager = plugin.getServer().getPluginManager();
    blockController.finalizeIntegration();
    // Check for BattleArenas
    Plugin battleArenaPlugin = pluginManager.getPlugin("BattleArena");
    if (battleArenaPlugin != null) {
        if (useBattleArenaTeams) {
            try {
                battleArenaManager = new BattleArenaManager();
            } catch (Throwable ex) {
                getLogger().log(Level.SEVERE, "Error integrating with BattleArena", ex);
            }
            getLogger().info("BattleArena found, teams will be respected in friendly fire checks");
        } else {
            battleArenaManager = null;
            getLogger().info("BattleArena integration disabled");
        }
    }
    // Check for WildStacker
    if (pluginManager.isPluginEnabled("WildStacker")) {
        if (useWildStacker) {
            getLogger().info("Wild Stacker integration enabled");
            pluginManager.registerEvents(new WildStackerListener(), plugin);
        } else {
            getLogger().info("Wild Stacker found, but integration disabled");
        }
    }
    // Check for Minigames
    Plugin minigamesPlugin = pluginManager.getPlugin("Minigames");
    if (minigamesPlugin != null && minigamesPlugin.isEnabled()) {
        pluginManager.registerEvents(new MinigamesListener(this), plugin);
        getLogger().info("Minigames found, wands will deactivate before joining a minigame");
    }
    // Check for LogBlock
    Plugin logBlockPlugin = pluginManager.getPlugin("LogBlock");
    if (logBlockPlugin == null || !logBlockPlugin.isEnabled()) {
        getLogger().info("LogBlock not found");
    } else if (logBlockEnabled) {
        try {
            logBlockManager = new LogBlockManager(plugin, logBlockPlugin);
            getLogger().info("Integrated with LogBlock, engineering magic will be logged");
        } catch (Throwable ex) {
            getLogger().log(Level.WARNING, "LogBlock integration failed", ex);
        }
    } else {
        getLogger().info("LogBlock integration disabled");
    }
    // Try to link to Essentials:
    Plugin essentials = pluginManager.getPlugin("Essentials");
    essentialsController = null;
    hasEssentials = essentials != null && essentials.isEnabled();
    if (hasEssentials) {
        essentialsController = EssentialsController.initialize(essentials);
        if (essentialsController == null) {
            getLogger().warning("Error integrating with Essentials");
        } else {
            getLogger().info("Integrating with Essentials for vanish detection");
        }
        if (warpController.setEssentials(essentials)) {
            getLogger().info("Integrating with Essentials for Recall warps");
        }
        try {
            mailer = new Mailer(essentials);
        } catch (Exception ex) {
            getLogger().warning("Essentials found, but failed to hook up to Mailer");
            mailer = null;
        }
    }
    if (essentialsSignsEnabled) {
        try {
            if (essentials != null) {
                Class<?> essentialsClass = essentials.getClass();
                essentialsClass.getMethod("getItemDb");
                if (MagicItemDb.register(this, essentials)) {
                    getLogger().info("Essentials found, hooked up custom item handler");
                } else {
                    getLogger().warning("Essentials found, but something went wrong hooking up the custom item handler");
                }
            }
        } catch (Throwable ex) {
            getLogger().warning("Essentials found, but is not up to date. Magic item integration will not work with this version of Magic. Please upgrade EssentialsX or downgrade Magic to 7.6.19");
        }
    }
    // Try to link to CommandBook
    hasCommandBook = false;
    try {
        Plugin commandBookPlugin = plugin.getServer().getPluginManager().getPlugin("CommandBook");
        if (commandBookPlugin != null && commandBookPlugin.isEnabled()) {
            if (warpController.setCommandBook(commandBookPlugin)) {
                getLogger().info("CommandBook found, integrating for Recall warps");
                hasCommandBook = true;
            } else {
                getLogger().warning("CommandBook integration failed");
            }
        }
    } catch (Throwable ignored) {
    }
    // Link to factions
    factionsManager.initialize(plugin);
    // Try to (dynamically) link to WorldGuard:
    worldGuardManager.initialize(plugin);
    // Link to PvpManager
    pvpManager.initialize(plugin);
    // Link to Multiverse
    multiverseManager.initialize(plugin);
    // Link to DeadSouls
    Plugin deadSoulsPlugin = plugin.getServer().getPluginManager().getPlugin("DeadSouls");
    if (deadSoulsPlugin != null) {
        try {
            deadSoulsController = new DeadSoulsManager(this);
        } catch (Exception ex) {
            getLogger().log(Level.WARNING, "Error integrating with DeadSouls, is it up to date? Version 1.6 or higher required.", ex);
        }
    }
    // Check for SkillAPI
    Plugin skillAPIPlugin = pluginManager.getPlugin("SkillAPI");
    if (skillAPIPlugin != null && skillAPIEnabled) {
        skillAPIManager = new SkillAPIManager(this, skillAPIPlugin);
        if (skillAPIManager.initialize()) {
            getLogger().info("SkillAPI found, attributes can be used in spell parameters. Classes and skills can be used in requirements.");
        } else {
            skillAPIManager = null;
            getLogger().warning("SkillAPI integration failed");
        }
    } else if (!skillAPIEnabled) {
        skillAPIManager = null;
        getLogger().info("SkillAPI integration disabled");
    }
    // Link to PreciousStones
    preciousStonesManager.initialize(plugin);
    // Link to Towny
    townyManager.initialize(plugin);
    // Link to Lockette
    locketteManager.initialize(plugin);
    // Link to GriefPrevention
    griefPreventionManager.initialize(plugin);
    // Link to NoCheatPlus
    ncpManager.initialize(plugin);
    // Try to link to dynmap:
    try {
        Plugin dynmapPlugin = plugin.getServer().getPluginManager().getPlugin("dynmap");
        if (dynmapPlugin != null && dynmapPlugin.isEnabled()) {
            dynmap = new DynmapController(plugin, dynmapPlugin, messages);
        } else {
            dynmap = null;
        }
    } catch (Throwable ex) {
        getLogger().warning(ex.getMessage());
    }
    if (dynmap == null) {
        getLogger().info("dynmap not found, not integrating.");
    } else {
        getLogger().info("dynmap found, integrating.");
    }
    // Try to link to Elementals:
    try {
        Plugin elementalsPlugin = plugin.getServer().getPluginManager().getPlugin("Splateds_Elementals");
        if (elementalsPlugin != null && elementalsPlugin.isEnabled()) {
            elementals = new ElementalsController(elementalsPlugin);
        } else {
            elementals = null;
        }
    } catch (Throwable ex) {
        getLogger().warning(ex.getMessage());
    }
    if (elementals != null) {
        getLogger().info("Elementals found, integrating.");
    }
    // Check for Shopkeepers, this is an optimization to avoid scanning for metadata if the plugin is not
    // present
    hasShopkeepers = pluginManager.isPluginEnabled("Shopkeepers");
    if (hasShopkeepers) {
        npcSuppliers.register(new GenericMetadataNPCSupplier("shopkeeper"));
    }
    // Try to link to Citizens
    try {
        Plugin citizensPlugin = plugin.getServer().getPluginManager().getPlugin("Citizens");
        if (citizensPlugin != null && citizensPlugin.isEnabled()) {
            citizens = new CitizensController(citizensPlugin, this, citizensEnabled);
            new MagicTraitCommandExecutor(MagicPlugin.getAPI(), citizens).register(getJavaPlugin());
        } else {
            citizens = null;
            getLogger().info("Citizens not found, Magic trait unavailable.");
        }
    } catch (Throwable ex) {
        citizens = null;
        getLogger().warning("Error integrating with Citizens");
        getLogger().warning(ex.getMessage());
    }
    if (citizens != null) {
        npcSuppliers.register(citizens);
    }
    // Placeholder API
    if (placeholdersEnabled) {
        if (pluginManager.isPluginEnabled("PlaceholderAPI")) {
            try {
                // Can only register this once
                if (placeholderAPIManager == null) {
                    placeholderAPIManager = new PlaceholderAPIManager(this);
                }
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with PlaceholderAPI", ex);
            }
        }
    } else {
        getLogger().info("PlaceholderAPI integration disabled.");
    }
    // Light API
    if (lightAPIEnabled) {
        if (pluginManager.isPluginEnabled("LightAPI")) {
            try {
                lightAPIManager = new LightAPIManager(plugin);
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with LightAPI", ex);
            }
        } else {
            getLogger().info("LightAPI not found, Light action will not work");
        }
    } else {
        lightAPIManager = null;
        getLogger().info("LightAPI integration disabled.");
    }
    // Geyser
    if (pluginManager.isPluginEnabled("Geyser-Spigot")) {
        try {
            geyserManager = new GeyserManager(this);
        } catch (Throwable ex) {
            getLogger().log(Level.WARNING, "Error integrating with Geyser", ex);
        }
    }
    // ajParkour
    if (ajParkourConfiguration.getBoolean("enabled")) {
        if (pluginManager.isPluginEnabled("ajParkour")) {
            try {
                new AJParkourManager(this);
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with ajParkour", ex);
            }
        }
    } else {
        getLogger().info("ajParkour integration disabled.");
    }
    // Citadel
    if (citadelConfiguration.getBoolean("enabled")) {
        if (pluginManager.isPluginEnabled("Citadel")) {
            try {
                citadelManager = new CitadelManager(this, citadelConfiguration);
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with Citadel", ex);
            }
        }
    } else {
        getLogger().info("Citadel integration disabled.");
    }
    // Residence
    if (residenceConfiguration.getBoolean("enabled")) {
        if (pluginManager.isPluginEnabled("Residence")) {
            try {
                residenceManager = new ResidenceManager(pluginManager.getPlugin("Residence"), this, residenceConfiguration);
                getLogger().info("Integrated with residence for build/break/pvp/target checks");
                getLogger().info("Disable warping to residences in recall config with allow_residence: false");
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with Residence", ex);
            }
        }
    } else {
        getLogger().info("Residence integration disabled.");
    }
    // RedProtect
    if (redProtectConfiguration.getBoolean("enabled")) {
        if (pluginManager.isPluginEnabled("RedProtect")) {
            try {
                redProtectManager = new RedProtectManager(pluginManager.getPlugin("RedProtect"), this, redProtectConfiguration);
                getLogger().info("Integrated with RedProtect for build/break/pvp/target checks");
                getLogger().info("Disable warping to fields in recall config with allow_redprotect: false");
                if (redProtectManager.isFlagsEnabled()) {
                    getLogger().info("Added custom flags: " + StringUtils.join(RedProtectManager.flags, ','));
                }
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with RedProtect", ex);
            }
        }
    } else {
        getLogger().info("RedProtect integration disabled.");
    }
    // UltimateClans
    if (ultimateClansConfiguration.getBoolean("enabled")) {
        if (pluginManager.isPluginEnabled("UClans")) {
            try {
                ultimateClansManager = new UltimateClansManager(this);
                getLogger().info("Integrated with UltimateClans for friendly fire checks");
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with UltimateClans", ex);
            }
        }
    } else {
        getLogger().info("UltimateClans integration disabled.");
    }
    // UltimateClans, Lands add on
    if (ultimateClansConfiguration.getBoolean("lands.enabled")) {
        if (pluginManager.isPluginEnabled("Lands-Addon")) {
            try {
                landsManager = new UltimateClansLandsManager(this);
                getLogger().info("Integrated with UltimateClans Lands Add-on for break/build checks");
            } catch (Throwable ex) {
                getLogger().log(Level.WARNING, "Error integrating with UltimateClans Lands add-on", ex);
            }
        }
    } else {
        getLogger().info("UltimateClans Lands integration disabled.");
    }
    // Load integrations for plugins that can't be attached until after load time
    loadPostIntegrations(mainConfiguration);
    // Set up the Mage update timer
    final MageUpdateTask mageTask = new MageUpdateTask(this);
    Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, mageTask, 0, mageUpdateFrequency);
    // Set up the Block update timer
    final BatchUpdateTask batchTask = new BatchUpdateTask(this);
    Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, batchTask, 0, workFrequency);
    // Set up the Automata timer
    final MagicBlockUpdateTask blockTask = new MagicBlockUpdateTask(this);
    Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, blockTask, 0, magicBlockUpdateFrequency);
    // Set up the Update check timer
    final UndoUpdateTask undoTask = new UndoUpdateTask(this);
    Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, undoTask, 0, undoFrequency);
}
Also used : ResidenceManager(com.elmakers.mine.bukkit.protection.ResidenceManager) WildStackerListener(com.elmakers.mine.bukkit.magic.listener.WildStackerListener) SkillAPIManager(com.elmakers.mine.bukkit.integration.SkillAPIManager) PlaceholderAPIManager(com.elmakers.mine.bukkit.integration.PlaceholderAPIManager) GenericMetadataNPCSupplier(com.elmakers.mine.bukkit.integration.GenericMetadataNPCSupplier) PluginManager(org.bukkit.plugin.PluginManager) UltimateClansManager(com.elmakers.mine.bukkit.protection.UltimateClansManager) ElementalsController(com.elmakers.mine.bukkit.elementals.ElementalsController) CitizensController(com.elmakers.mine.bukkit.citizens.CitizensController) MagicTraitCommandExecutor(com.elmakers.mine.bukkit.magic.command.MagicTraitCommandExecutor) LightAPIManager(com.elmakers.mine.bukkit.integration.LightAPIManager) LogBlockManager(com.elmakers.mine.bukkit.integration.LogBlockManager) RedProtectManager(com.elmakers.mine.bukkit.protection.RedProtectManager) MageUpdateTask(com.elmakers.mine.bukkit.tasks.MageUpdateTask) MinigamesListener(com.elmakers.mine.bukkit.magic.listener.MinigamesListener) GeyserManager(com.elmakers.mine.bukkit.integration.GeyserManager) MagicBlockUpdateTask(com.elmakers.mine.bukkit.tasks.MagicBlockUpdateTask) DynmapController(com.elmakers.mine.bukkit.dynmap.DynmapController) Mailer(com.elmakers.mine.bukkit.essentials.Mailer) BatchUpdateTask(com.elmakers.mine.bukkit.tasks.BatchUpdateTask) UltimateClansLandsManager(com.elmakers.mine.bukkit.protection.UltimateClansLandsManager) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) DeadSoulsManager(com.elmakers.mine.bukkit.protection.DeadSoulsManager) CitadelManager(com.elmakers.mine.bukkit.protection.CitadelManager) BattleArenaManager(com.elmakers.mine.bukkit.integration.BattleArenaManager) AJParkourManager(com.elmakers.mine.bukkit.protection.AJParkourManager) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) UndoUpdateTask(com.elmakers.mine.bukkit.tasks.UndoUpdateTask)

Example 2 with SkillAPIManager

use of com.elmakers.mine.bukkit.integration.SkillAPIManager in project MagicPlugin by elBukkit.

the class MagicController method finalizeIntegrationPreSpells.

protected void finalizeIntegrationPreSpells() {
    final PluginManager pluginManager = plugin.getServer().getPluginManager();
    // Check for SkillAPI
    Plugin skillAPIPlugin = pluginManager.getPlugin("SkillAPI");
    if (skillAPIPlugin != null && skillAPIEnabled) {
        skillAPIManager = new SkillAPIManager(this, skillAPIPlugin);
        if (skillAPIManager.initialize()) {
            getLogger().info("SkillAPI found, attributes can be used in spell parameters. Classes and skills can be used in requirements.");
            if (useSkillAPIMana) {
                getLogger().info("SkillAPI mana will be used by spells and wands");
            }
        } else {
            skillAPIManager = null;
            getLogger().warning("SkillAPI integration failed");
        }
    } else if (!skillAPIEnabled) {
        skillAPIManager = null;
        getLogger().info("SkillAPI integration disabled");
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) SkillAPIManager(com.elmakers.mine.bukkit.integration.SkillAPIManager) Plugin(org.bukkit.plugin.Plugin)

Aggregations

SkillAPIManager (com.elmakers.mine.bukkit.integration.SkillAPIManager)2 Plugin (org.bukkit.plugin.Plugin)2 PluginManager (org.bukkit.plugin.PluginManager)2 CitizensController (com.elmakers.mine.bukkit.citizens.CitizensController)1 DynmapController (com.elmakers.mine.bukkit.dynmap.DynmapController)1 ElementalsController (com.elmakers.mine.bukkit.elementals.ElementalsController)1 Mailer (com.elmakers.mine.bukkit.essentials.Mailer)1 BattleArenaManager (com.elmakers.mine.bukkit.integration.BattleArenaManager)1 GenericMetadataNPCSupplier (com.elmakers.mine.bukkit.integration.GenericMetadataNPCSupplier)1 GeyserManager (com.elmakers.mine.bukkit.integration.GeyserManager)1 LightAPIManager (com.elmakers.mine.bukkit.integration.LightAPIManager)1 LogBlockManager (com.elmakers.mine.bukkit.integration.LogBlockManager)1 PlaceholderAPIManager (com.elmakers.mine.bukkit.integration.PlaceholderAPIManager)1 MagicTraitCommandExecutor (com.elmakers.mine.bukkit.magic.command.MagicTraitCommandExecutor)1 MinigamesListener (com.elmakers.mine.bukkit.magic.listener.MinigamesListener)1 WildStackerListener (com.elmakers.mine.bukkit.magic.listener.WildStackerListener)1 AJParkourManager (com.elmakers.mine.bukkit.protection.AJParkourManager)1 CitadelManager (com.elmakers.mine.bukkit.protection.CitadelManager)1 DeadSoulsManager (com.elmakers.mine.bukkit.protection.DeadSoulsManager)1 RedProtectManager (com.elmakers.mine.bukkit.protection.RedProtectManager)1