Java Code Examples for org.bukkit.plugin.PluginManager#getPlugin()

The following examples show how to use org.bukkit.plugin.PluginManager#getPlugin() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompatibilityMythicMobs.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    Logger logger = getLogger();
    PluginManager manager = Bukkit.getPluginManager();
    if(!manager.isPluginEnabled("MythicMobs")) {
        logger.info("Could not find the MythicMobs plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    Plugin pluginMythicMobs = manager.getPlugin("MythicMobs");
    if(pluginMythicMobs == null) {
        logger.info("Could not find the MythicMobs plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String versionMythicMobs = pluginMythicMobs.getDescription().getVersion();
    logger.info("Successfully hooked into MythicMobs v" + versionMythicMobs);
    
    ListenerMythicMobs listenerMythicMobs = new ListenerMythicMobs(this);
    expansionManager.registerListener(this, listenerMythicMobs);
}
 
Example 2
Source File: CompatibilityFactions.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActualEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();

    this.noEntryHandler = new FactionsNoEntryHandler(this);
    saveDefaultConfig("factions-compatibility.yml");

    NoEntryListener listener = new NoEntryListener(this);
    expansionManager.registerListener(this, listener);

    Plugin pluginProtocolLib = manager.getPlugin("ProtocolLib");
    if(pluginProtocolLib != null) {
        NoEntryForceFieldListener forceFieldListener = new NoEntryForceFieldListener(this);
        expansionManager.registerListener(this, forceFieldListener);

        String version = pluginProtocolLib.getDescription().getVersion();
        logger.info("Successfully hooked into ProtocolLib v" + version);
    }
}
 
Example 3
Source File: AntiVPN.java    From AntiVPN with MIT License 6 votes vote down vote up
private void loadHooks() {
    PluginManager manager = plugin.getServer().getPluginManager();

    Plugin plan;
    if ((plan = manager.getPlugin("Plan")) != null) {
        consoleCommandIssuer.sendInfo(Message.GENERAL__HOOK_ENABLE, "{plugin}", "Plan");
        PlayerAnalyticsHook.create(plugin, plan);
    } else {
        consoleCommandIssuer.sendInfo(Message.GENERAL__HOOK_DISABLE, "{plugin}", "Plan");
    }

    if (manager.getPlugin("PlaceholderAPI") != null) {
        consoleCommandIssuer.sendInfo(Message.GENERAL__HOOK_ENABLE, "{plugin}", "PlaceholderAPI");
        ServiceLocator.register(new PlaceholderAPIHook());
    } else {
        consoleCommandIssuer.sendInfo(Message.GENERAL__HOOK_DISABLE, "{plugin}", "PlaceholderAPI");
    }
}
 
Example 4
Source File: CompatibilityWorldGuard.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActualEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();

    Plugin pluginWorldGuard = manager.getPlugin("WorldGuard");
    if(pluginWorldGuard == null) {
        logger.info("The WorldGuard plugin could not be found. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String version = pluginWorldGuard.getDescription().getVersion();
    logger.info("Successfully hooked into WorldGuard v" + version);

    saveDefaultConfig("worldguard-compatibility.yml");
    this.noEntryHandler = new WorldGuardNoEntryHandler(this);

    ListenerWorldGuard listenerWorldGuard = new ListenerWorldGuard();
    expansionManager.registerListener(this, listenerWorldGuard);

    NoEntryListener listener = new NoEntryListener(this);
    expansionManager.registerListener(this, listener);

    HookWorldGuard.registerListeners(this);

    Plugin pluginProtocolLib = manager.getPlugin("ProtocolLib");
    if(pluginProtocolLib != null) {
        NoEntryForceFieldListener forceFieldListener = new NoEntryForceFieldListener(this);
        expansionManager.registerListener(this, forceFieldListener);

        String versionProtocolLib = pluginProtocolLib.getDescription().getVersion();
        logger.info("Successfully hooked into ProtocolLib v" + versionProtocolLib);
    }
}
 
Example 5
Source File: CompatibilityCrackShot.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();

    if(!manager.isPluginEnabled("CrackShot")) {
        logger.info("Could not find the CrackShot plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    Plugin pluginCrackShot = manager.getPlugin("CrackShot");
    if(pluginCrackShot == null) {
        logger.info("Could not find the CrackShot plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String versionCrackShot = pluginCrackShot.getDescription().getVersion();
    logger.info("Successfully hooked into CrackShot v" + versionCrackShot);

    ListenerCrackShot listener = new ListenerCrackShot(this);
    expansionManager.registerListener(this, listener);
}
 
Example 6
Source File: DynmapCivcraftPlugin.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onEnable() {
	log.info("enabled...");
	PluginManager pm = getServer().getPluginManager();
	
	dynmap = pm.getPlugin("dynmap");
	api = (DynmapAPI)dynmap;
	
	civcraft = pm.getPlugin("civcraft");

	markerapi = api.getMarkerAPI();
	
	townBorderSet = markerapi.createMarkerSet("townborder.markerset", "Town Borders", null, false);
	townBorderSet.setLayerPriority(10);
	townBorderSet.setHideByDefault(false);
	
	cultureSet = markerapi.createMarkerSet("townculture.markerset", "Culture", null, false);
	cultureSet.setLayerPriority(15);
	cultureSet.setHideByDefault(false);
	
	structureSet = markerapi.createMarkerSet("structures.markerset", "Structures", null, false);
	structureSet.setLayerPriority(20);
	structureSet.setHideByDefault(false);
	
	getServer().getScheduler().scheduleSyncRepeatingTask(this, 
			new CivCraftUpdateTask(this.api, this.markerapi, this.townBorderSet, this.cultureSet, this.structureSet), 40, 40);
}
 
Example 7
Source File: CompatibilityPreciousStones.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActualEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();
    
    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();
    
    Plugin pluginPreciousStones = manager.getPlugin("PreciousStones");
    if(pluginPreciousStones == null) {
        logger.info("Could not find the PreciousStones plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }
    
    String versionPreciousStones = pluginPreciousStones.getDescription().getVersion();
    logger.info("Successfully hooked into Residence v" + versionPreciousStones);
    
    saveDefaultConfig("preciousstones-compatibility.yml");
    this.noEntryHandler = new PreciousStonesNoEntryHandler(this);
    
    NoEntryListener listener = new NoEntryListener(this);
    expansionManager.registerListener(this, listener);

    ListenerFieldCreation listenerFieldCreation = new ListenerFieldCreation(this);
    expansionManager.registerListener(this, listenerFieldCreation);
    
    Plugin pluginProtocolLib = manager.getPlugin("ProtocolLib");
    if(pluginProtocolLib != null) {
        NoEntryForceFieldListener forceFieldListener = new NoEntryForceFieldListener(this);
        expansionManager.registerListener(this, forceFieldListener);
        
        String versionProtocolLib = pluginProtocolLib.getDescription().getVersion();
        logger.info("Successfully hooked into ProtocolLib v" + versionProtocolLib);
    }
}
 
Example 8
Source File: CompatibilityCitizens.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkForSentinel() {
    PluginManager manager = Bukkit.getPluginManager();
    if(!manager.isPluginEnabled("Sentinel")) return false;

    Plugin plugin = manager.getPlugin("Sentinel");
    if(plugin == null) return false;

    PluginDescriptionFile description = plugin.getDescription();
    String fullName = description.getFullName();

    Logger logger = getLogger();
    logger.info("Successfully hooked into " + fullName);
    return true;
}
 
Example 9
Source File: CompatibilityRedProtect.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActualEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();


    Plugin pluginRedProtect = manager.getPlugin("RedProtect");
    if(pluginRedProtect == null) {
        logger.info("Could not find the RedProtect plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String versionRedProtect = pluginRedProtect.getDescription().getVersion();
    logger.info("Successfully hooked into RedProtect v" + versionRedProtect);

    saveDefaultConfig("redprotect-compatibility.yml");
    this.noEntryHandler = new RedProtectNoEntryHandler(this);

    NoEntryListener listener = new NoEntryListener(this);
    expansionManager.registerListener(this, listener);

    Plugin pluginProtocolLib = manager.getPlugin("ProtocolLib");
    if(pluginProtocolLib != null) {
        NoEntryForceFieldListener forceFieldListener = new NoEntryForceFieldListener(this);
        expansionManager.registerListener(this, forceFieldListener);

        String versionProtocolLib = pluginProtocolLib.getDescription().getVersion();
        logger.info("Successfully hooked into ProtocolLib v" + versionProtocolLib);
    }
}
 
Example 10
Source File: CompatibilityResidence.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActualEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();

    Plugin pluginResidence = manager.getPlugin("Residence");
    if(pluginResidence == null) {
        logger.info("Could not find the Residence plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String versionResidence = pluginResidence.getDescription().getVersion();
    logger.info("Successfully hooked into Residence v" + versionResidence);

    saveDefaultConfig("residence-compatibility.yml");
    this.noEntryHandler = new ResidenceNoEntryHandler(this);

    NoEntryListener listener = new NoEntryListener(this);
    expansionManager.registerListener(this, listener);

    Plugin pluginProtocolLib = manager.getPlugin("ProtocolLib");
    if(pluginProtocolLib != null) {
        NoEntryForceFieldListener forceFieldListener = new NoEntryForceFieldListener(this);
        expansionManager.registerListener(this, forceFieldListener);

        String versionProtocolLib = pluginProtocolLib.getDescription().getVersion();
        logger.info("Successfully hooked into ProtocolLib v" + versionProtocolLib);
    }
}
 
Example 11
Source File: FloorRegeneratorFactory.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
public FloorRegenerator retrieveRegeneratorInstance() {
    //If FastAsyncWorldEdit is installed, use a special fawe designed
    //generator for compatibility
    PluginManager pluginManager = Bukkit.getPluginManager();
    Plugin fawePlugin = pluginManager.getPlugin(FAWE_PLUGIN_NAME);
    if (fawePlugin != null && fawePlugin.isEnabled()) {
        return faweRegenerator;
    }

    return defaultRegenerator;
}
 
Example 12
Source File: HookWorldGuard.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
public static WorldGuardVersion getWorldGuardVersion() {
    if(worldGuardVersion != null) return worldGuardVersion;

    PluginManager manager = Bukkit.getPluginManager();
    Plugin plugin = manager.getPlugin("WorldGuard");
    if(plugin == null) return (worldGuardVersion = WorldGuardVersion.ERROR);

    PluginDescriptionFile pdf = plugin.getDescription();
    String version = pdf.getVersion();
    if(version.startsWith("6.1")) return (worldGuardVersion = WorldGuardVersion.V6_1);
    if(version.startsWith("6.2")) return (worldGuardVersion = WorldGuardVersion.V6_2);
    if(version.startsWith("7.0")) return (worldGuardVersion = WorldGuardVersion.V7_0);

    return (worldGuardVersion = WorldGuardVersion.ERROR);
}
 
Example 13
Source File: SkyBlockHook.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private static void printHookInfo(CompatibilitySkyBlock expansion, String pluginName) {
    PluginManager manager = Bukkit.getPluginManager();
    if(!manager.isPluginEnabled(pluginName)) return;
    
    Plugin plugin = manager.getPlugin(pluginName);
    if(plugin == null) return;

    PluginDescriptionFile description = plugin.getDescription();
    String fullName = description.getFullName();
    
    Logger logger = expansion.getLogger();
    logger.info("Successfully hooked into " + fullName);
}
 
Example 14
Source File: CompatibilityLands.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActualEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();

    Plugin pluginLands = manager.getPlugin("Lands");
    if(pluginLands == null) {
        logger.info("Could not find the Lands plugin. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String versionLands = pluginLands.getDescription().getVersion();
    logger.info("Successfully hooked into Lands v" + versionLands);

    saveDefaultConfig("lands-compatibility.yml");
    HookLands hook = new HookLands(this);
    this.noEntryHandler = new LandsNoEntryHandler(this, hook);

    NoEntryListener listener = new NoEntryListener(this);
    expansionManager.registerListener(this, listener);

    Plugin pluginProtocolLib = manager.getPlugin("ProtocolLib");
    if(pluginProtocolLib != null) {
        NoEntryForceFieldListener forceFieldListener = new NoEntryForceFieldListener(this);
        expansionManager.registerListener(this, forceFieldListener);

        String versionProtocolLib = pluginProtocolLib.getDescription().getVersion();
        logger.info("Successfully hooked into ProtocolLib v" + versionProtocolLib);
    }
}
 
Example 15
Source File: BukkitServerBridge.java    From PlotMe-Core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Setup PlotMe plugin hooks
 */
@Override
public void setupHooks() {
    PluginManager pluginManager = plotMeCorePlugin.getServer().getPluginManager();
    if (pluginManager.getPlugin("WorldEdit") != null) {
        WorldEdit.getInstance().getEventBus().register(new PlotWorldEditListener(plotMeCorePlugin.getAPI()));
    }

    setUsingLwc(pluginManager.getPlugin("LWC") != null);
}
 
Example 16
Source File: CompatibilityPlaceholderAPI.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();

    if(!manager.isPluginEnabled("PlaceholderAPI")) {
        logger.info("The PlaceholderAPI plugin could not be found. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    Plugin pluginPlaceholderAPI = manager.getPlugin("PlaceholderAPI");
    if(pluginPlaceholderAPI == null) {
        logger.info("The PlaceholderAPI plugin could not be found. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String versionPlaceholderAPI = pluginPlaceholderAPI.getDescription().getVersion();
    logger.info("Successfully hooked into PlaceholderAPI v" + versionPlaceholderAPI);

    HookPlaceholderAPI hookPlaceholderAPI = new HookPlaceholderAPI(this);
    hookPlaceholderAPI.register();
}
 
Example 17
Source File: HookMVdWPlaceholderAPI.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
public static void disableTrigger(String pluginName, String trigger, Player player) {
    try {
        PluginManager manager = Bukkit.getPluginManager();
        if(!manager.isPluginEnabled(pluginName)) return;

        Plugin plugin = manager.getPlugin(pluginName);
        if(plugin == null) return;
        
        if(!manager.isPluginEnabled("MVdWPlaceholderAPI")) return;
        EventAPI.triggerEvent(plugin, player, trigger, false);
    } catch(Exception ignored) {}
}
 
Example 18
Source File: HookUltimateSkyBlock.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public uSkyBlockAPI getAPI() {
    PluginManager manager = Bukkit.getPluginManager();
    Plugin plugin = manager.getPlugin("uSkyBlock");
    return (uSkyBlockAPI) plugin;
}
 
Example 19
Source File: HookEssentials.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static IEssentials getAPI() {
    PluginManager manager = Bukkit.getPluginManager();
    Plugin plugin = manager.getPlugin("Essentials");
    return (IEssentials) plugin;
}
 
Example 20
Source File: SkyBlockHook.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static SkyBlockHook getSkyBlockHook(CompatibilitySkyBlock expansion) {
    if(SKYBLOCK_HOOK != null) return SKYBLOCK_HOOK;

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = expansion.getLogger();

    if(manager.isPluginEnabled("BentoBox")) {
        Plugin plugin = manager.getPlugin("BentoBox");
        if(plugin != null) {
            PluginDescriptionFile description = plugin.getDescription();
            String version = description.getVersion();
            logger.info("Checking 'BentoBox v" + version + "' for BSkyBlock");
            
            if(HookBentoBox.hookIntoBSkyBlock(logger)) {
                SKYBLOCK_HOOK = new HookBSkyBlock();
                return getSkyBlockHook(expansion);
            }
        }
    }

    if(manager.isPluginEnabled("ASkyBlock")) {
        printHookInfo(expansion, "ASkyBlock");
        SKYBLOCK_HOOK = new HookASkyBlock();
        return getSkyBlockHook(expansion);
    }

    if(manager.isPluginEnabled("FabledSkyBlock")) {
        printHookInfo(expansion, "FabledSkyBlock");
        SKYBLOCK_HOOK = new HookFabledSkyBlock();
        return getSkyBlockHook(expansion);
    }
    
    if(manager.isPluginEnabled("SuperiorSkyblock2")) {
        printHookInfo(expansion, "SuperiorSkyblock2");
        SKYBLOCK_HOOK = new HookSuperiorSkyBlock2();
        return getSkyBlockHook(expansion);
    }

    if(manager.isPluginEnabled("uSkyBlock")) {
        printHookInfo(expansion, "uSkyBlock");
        SKYBLOCK_HOOK = new HookUltimateSkyBlock();
        return getSkyBlockHook(expansion);
    }

    return null;
}