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

The following examples show how to use org.bukkit.plugin.PluginManager#isPluginEnabled() . 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: Notifier.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
public String replacePlaceholders(Player player, String string) {
    if(player == null) return string;
    ICombatLogX plugin = getPlugin();
    
    PluginManager manager = Bukkit.getPluginManager();
    if(manager.isPluginEnabled("PlaceholderAPI")) string = HookPlaceholderAPI.replacePlaceholders(player, string);
    if(manager.isPluginEnabled("MVdWPlaceholderAPI")) string = HookMVdWPlaceholderAPI.replacePlaceholders(player, string);
    
    String timeLeft = PlaceholderReplacer.getTimeLeftSeconds(plugin, player);
    String inCombat = PlaceholderReplacer.getInCombat(plugin, player);
    String combatStatus = PlaceholderReplacer.getCombatStatus(plugin, player);

    String enemyName = PlaceholderReplacer.getEnemyName(plugin, player);
    String enemyHealth = PlaceholderReplacer.getEnemyHealth(plugin, player);
    String enemyHealthRounded = PlaceholderReplacer.getEnemyHealthRounded(plugin, player);
    String enemyHearts = PlaceholderReplacer.getEnemyHearts(plugin, player);
    
    return string.replace("{time_left}", timeLeft).replace("{in_combat}", inCombat)
            .replace("{status}", combatStatus).replace("{enemy_name}", enemyName)
            .replace("{enemy_health}", enemyHealth)
            .replace("{enemy_health_rounded}", enemyHealthRounded)
            .replace("{enemy_hearts}", enemyHearts);
}
 
Example 2
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 3
Source File: CheatPrevention.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEnable() {
    PluginManager manager = Bukkit.getPluginManager();
    JavaPlugin plugin = getPlugin().getPlugin();

    // All Versions
    manager.registerEvents(new ListenerBlocks(this), plugin);
    manager.registerEvents(new ListenerChat(this), plugin);
    manager.registerEvents(new ListenerCommandBlocker(this), plugin);
    manager.registerEvents(new ListenerEntities(this), plugin);
    manager.registerEvents(new ListenerFlight(this), plugin);
    manager.registerEvents(new ListenerGameMode(this), plugin);
    manager.registerEvents(new ListenerInventories(this), plugin);
    manager.registerEvents(new ListenerPotions(this), plugin);
    manager.registerEvents(new ListenerTeleport(this), plugin);

    int minorVersion = VersionUtil.getMinorVersion();

    // 1.9+ Elytra
    if(minorVersion >= 9) manager.registerEvents(new ListenerElytra(this), plugin);

    // 1.11+ Totem of Undying
    if(minorVersion >= 11) manager.registerEvents(new ListenerTotemOfUndying(this), plugin);

    // 1.12+ PlayerPickupItemEvent --> EntityPickupItemEvent
    Listener itemPickupListener = minorVersion >= 12 ? new ListenerNewItemPickup(this) : new ListenerLegacyItemPickup(this);
    manager.registerEvents(itemPickupListener, plugin);

    // 1.13+ Riptide Enchantment
    if(minorVersion >= 13) manager.registerEvents(new ListenerRiptide(this), plugin);
    
    // Essentials Hook
    if(manager.isPluginEnabled("Essentials")) {
        ListenerEssentials listenerEssentials = new ListenerEssentials(this);
        manager.registerEvents(listenerEssentials, plugin);
    }
}
 
Example 4
Source File: HookMVdWPlaceholderAPI.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
public static void enableTrigger(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, true);
    } catch(Exception ignored) {}
}
 
Example 5
Source File: ListenerVanish.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkSuperVanish(Player player) {
    FileConfiguration config = this.expansion.getConfig("vanish-compatibility.yml");
    if(!config.getBoolean("check-super-vanish")) return false;
    
    PluginManager manager = Bukkit.getPluginManager();
    if(!manager.isPluginEnabled("SuperVanish") && !manager.isPluginEnabled("PremiumVanish")) return false;
    
    return HookSuperVanish.isVanished(player);
}
 
Example 6
Source File: ListenerVanish.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkEssentialsVanish(Player player) {
    FileConfiguration config = this.expansion.getConfig("vanish-compatibility.yml");
    if(!config.getBoolean("check-essentials-vanish")) return false;
    
    PluginManager manager = Bukkit.getPluginManager();
    if(!manager.isPluginEnabled("Essentials")) return false;
    
    return HookEssentials.isVanished(player);
}
 
Example 7
Source File: uSkyBlock.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public synchronized boolean isRequirementsMet(CommandSender sender, Command command, String... args) {
    if (maintenanceMode && !(
            (command instanceof AdminCommand && args != null && args.length > 0 && args[0].equals("maintenance")) ||
                    command instanceof SetMaintenanceCommand)) {
        sender.sendMessage(tr("\u00a7cMAINTENANCE:\u00a7e uSkyBlock is currently in maintenance mode"));
        return false;
    }
    if (missingRequirements == null) {
        PluginManager pluginManager = getServer().getPluginManager();
        missingRequirements = "";
        for (String[] pluginReq : depends) {
            if (pluginReq.length > 2 && pluginReq[2].equals("optional")) {
                // Do check the version if an optional requirement is present.
                if (!pluginManager.isPluginEnabled(pluginReq[0])) {
                    continue;
                }
            }
            if (pluginReq.length > 2 && pluginReq[2].equals("optionalIf")) {
                if (pluginManager.isPluginEnabled(pluginReq[3])) {
                    continue;
                }
            }
            if (pluginManager.isPluginEnabled(pluginReq[0])) {
                PluginDescriptionFile desc = pluginManager.getPlugin(pluginReq[0]).getDescription();
                if (VersionUtil.getVersion(desc.getVersion()).isLT(pluginReq[1])) {
                    missingRequirements += tr("\u00a7buSkyBlock\u00a7e depends on \u00a79{0}\u00a7e >= \u00a7av{1}\u00a7e but only \u00a7cv{2}\u00a7e was found!\n", pluginReq[0], pluginReq[1], desc.getVersion());
                }
            } else {
                missingRequirements += tr("\u00a7buSkyBlock\u00a7e depends on \u00a79{0}\u00a7e >= \u00a7av{1}", pluginReq[0], pluginReq[1]);
            }
        }
    }
    if (missingRequirements.isEmpty()) {
        return true;
    } else {
        sender.sendMessage(missingRequirements.split("\n"));
        return false;
    }
}
 
Example 8
Source File: ForceField.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
public void unregisterProtocol() {
    PluginManager pluginManager = Bukkit.getPluginManager();
    if(!pluginManager.isPluginEnabled("ProtocolLib")) return;

    ProtocolManager manager = ProtocolLibrary.getProtocolManager();
    manager.removePacketListeners(this.plugin.getPlugin());
}
 
Example 9
Source File: Notifier.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private void hookIfEnabled(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 nameAndVersion = description.getFullName();

    Logger logger = getLogger();
    logger.info("Successfully hooked into " + nameAndVersion);
}
 
Example 10
Source File: CompatibilityMVdWPlaceholderAPI.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("MVdWPlaceholderAPI")) {
        logger.info("The MVdWPlaceholderAPI plugin could not be found. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    Plugin pluginPlaceholderAPI = manager.getPlugin("MVdWPlaceholderAPI");
    if(pluginPlaceholderAPI == null) {
        logger.info("The MVdWPlaceholderAPI 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 MVdWPlaceholderAPI v" + versionPlaceholderAPI);

    HookMVdW hookMVdW = new HookMVdW(this);
    hookMVdW.register();
}
 
Example 11
Source File: CompatibilityCitizens.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkForCitizens() {
    PluginManager manager = Bukkit.getPluginManager();
    if(!manager.isPluginEnabled("Citizens")) return true;
    
    Plugin plugin = manager.getPlugin("Citizens");
    if(plugin == null) return true;

    PluginDescriptionFile description = plugin.getDescription();
    String fullName = description.getFullName();
    
    Logger logger = getLogger();
    logger.info("Successfully hooked into " + fullName);
    return false;
}
 
Example 12
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 13
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 14
Source File: CompatibilityRedProtect.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnable() {
    PluginManager manager = Bukkit.getPluginManager();
    return manager.isPluginEnabled("RedProtect");
}
 
Example 15
Source File: CompatibilityResidence.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnable() {
    PluginManager manager = Bukkit.getPluginManager();
    return manager.isPluginEnabled("Residence");
}
 
Example 16
Source File: CompatibilityWorldGuard.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnable() {
    PluginManager manager = Bukkit.getPluginManager();
    return manager.isPluginEnabled("WorldGuard");
}
 
Example 17
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;
}
 
Example 18
Source File: CompatibilityLands.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnable() {
    PluginManager manager = Bukkit.getPluginManager();
    return manager.isPluginEnabled("Lands");
}
 
Example 19
Source File: CompatibilityPreciousStones.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnable() {
    PluginManager manager = Bukkit.getPluginManager();
    return manager.isPluginEnabled("PreciousStones");
}
 
Example 20
Source File: FastLoginBukkit.java    From FastLogin with MIT License 4 votes vote down vote up
@Override
public void onEnable() {
    core = new FastLoginCore<>(this);
    core.load();

    if (getServer().getOnlineMode()) {
        //we need to require offline to prevent a loginSession request for a offline player
        logger.error("Server has to be in offline mode");
        setEnabled(false);
        return;
    }

    bungeeManager = new BungeeManager(this);
    bungeeManager.initialize();
    
    PluginManager pluginManager = getServer().getPluginManager();
    if (bungeeManager.isEnabled()) {
        markInitialized();
    } else {
        if (!core.setupDatabase()) {
            setEnabled(false);
            return;
        }

        if (pluginManager.isPluginEnabled("ProtocolSupport")) {
            pluginManager.registerEvents(new ProtocolSupportListener(this, core.getRateLimiter()), this);
        } else if (pluginManager.isPluginEnabled("ProtocolLib")) {
            ProtocolLibListener.register(this, core.getRateLimiter());
            pluginManager.registerEvents(new SkinApplyListener(this), this);
        } else {
            logger.warn("Either ProtocolLib or ProtocolSupport have to be installed if you don't use BungeeCord");
        }
    }

    //delay dependency setup because we load the plugin very early where plugins are initialized yet
    getServer().getScheduler().runTaskLater(this, new DelayedAuthHook(this), 5L);

    pluginManager.registerEvents(new ConnectionListener(this), this);

    //register commands using a unique name
    getCommand("premium").setExecutor(new PremiumCommand(this));
    getCommand("cracked").setExecutor(new CrackedCommand(this));

    if (pluginManager.isPluginEnabled("PlaceholderAPI")) {
        new PremiumPlaceholder(this).register();
    }
}