Java Code Examples for org.bukkit.Bukkit#getPluginManager()
The following examples show how to use
org.bukkit.Bukkit#getPluginManager() .
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: CommandManager.java From SonarPet with GNU General Public License v3.0 | 7 votes |
public CommandMap getCommandMap() { if (!(Bukkit.getPluginManager() instanceof SimplePluginManager)) { this.plugin.getLogger().warning("Seems like your server is using a custom PluginManager? Well let's try injecting our custom commands anyways..."); } CommandMap map = null; try { map = SERVER_COMMAND_MAP.get(Bukkit.getPluginManager()); if (map == null) { if (fallback != null) { return fallback; } else { fallback = map = new SimpleCommandMap(EchoPet.getPlugin().getServer()); Bukkit.getPluginManager().registerEvents(new FallbackCommandRegistrationListener(fallback), this.plugin); } } } catch (Exception pie) { this.plugin.getLogger().warning("Failed to dynamically register the commands! Let's give it a last shot..."); // Hmmm.... Pie... fallback = map = new SimpleCommandMap(EchoPet.getPlugin().getServer()); Bukkit.getPluginManager().registerEvents(new FallbackCommandRegistrationListener(fallback), this.plugin); } return map; }
Example 2
Source File: Sniper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
private void callEvent(Event event) { if (Fawe.isMainThread()) { Bukkit.getPluginManager().callEvent(event); } else { if (event.isAsynchronous()) { Bukkit.getPluginManager().callEvent(event); } else { try { PluginManager plm = Bukkit.getPluginManager(); Class<? extends PluginManager> clazz = plm.getClass(); Method methodFireEvent = clazz.getDeclaredMethod("fireEvent", Event.class); methodFireEvent.setAccessible(true); methodFireEvent.invoke(plm, event); } catch (Throwable ignore) {} } } }
Example 3
Source File: CombatManager.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
@Override public void untag(Player player, PlayerUntagEvent.UntagReason untagReason) { if(player == null | untagReason == null || !isInCombat(player)) return; UUID uuid = player.getUniqueId(); uuidToExpireTime.remove(uuid); UUID previousEnemyId = uuidToEnemy.remove(uuid); Entity previousEnemyEntity = (previousEnemyId != null ? getEntityByUUID(previousEnemyId) : null); LivingEntity previousEnemy = (previousEnemyEntity instanceof LivingEntity ? (LivingEntity) previousEnemyEntity : null); PlayerUntagEvent untagEvent = new PlayerUntagEvent(player, untagReason, previousEnemy); PluginManager manager = Bukkit.getPluginManager(); manager.callEvent(untagEvent); }
Example 4
Source File: CommandManager.java From EchoPet with GNU General Public License v3.0 | 6 votes |
public CommandMap getCommandMap() { if (!(Bukkit.getPluginManager() instanceof SimplePluginManager)) { this.plugin.getLogger().warning("Seems like your server is using a custom PluginManager? Well let's try injecting our custom commands anyways..."); } CommandMap map = null; try { map = SERVER_COMMAND_MAP.get(Bukkit.getPluginManager()); if (map == null) { if (fallback != null) { return fallback; } else { fallback = map = new SimpleCommandMap(EchoPet.getPlugin().getServer()); Bukkit.getPluginManager().registerEvents(new FallbackCommandRegistrationListener(fallback), this.plugin); } } } catch (Exception pie) { this.plugin.getLogger().warning("Failed to dynamically register the commands! Let's give it a last shot..."); // Hmmm.... Pie... fallback = map = new SimpleCommandMap(EchoPet.getPlugin().getServer()); Bukkit.getPluginManager().registerEvents(new FallbackCommandRegistrationListener(fallback), this.plugin); } return map; }
Example 5
Source File: CombatManager.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@Override public boolean punish(Player player, PlayerUntagEvent.UntagReason punishReason, LivingEntity previousEnemy) { PlayerPunishEvent punishEvent = new PlayerPunishEvent(player, punishReason, previousEnemy); PluginManager manager = Bukkit.getPluginManager(); manager.callEvent(punishEvent); if(punishEvent.isCancelled()) return false; checkKill(player); runPunishCommands(player, previousEnemy); return true; }
Example 6
Source File: CombatManager.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@Override public void run() { PluginManager manager = Bukkit.getPluginManager(); List<Player> combatPlayerList = getPlayersInCombat(); for(Player player : combatPlayerList) { int timeLeft = getTimerSecondsLeft(player); if(timeLeft <= 0) untag(player, PlayerUntagEvent.UntagReason.EXPIRE); PlayerCombatTimerChangeEvent event = new PlayerCombatTimerChangeEvent(player, timeLeft); manager.callEvent(event); } }
Example 7
Source File: HookMVdWPlaceholderAPI.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
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 8
Source File: Notifier.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
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 9
Source File: HookWorldGuard.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
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 10
Source File: CompatibilityResidence.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@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: CompatibilityLands.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@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 12
Source File: CompatibilityGriefPrevention.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@Override public void onActualEnable() { ICombatLogX plugin = getPlugin(); ExpansionManager expansionManager = plugin.getExpansionManager(); PluginManager manager = Bukkit.getPluginManager(); Logger logger = getLogger(); Plugin pluginGriefPrevention = manager.getPlugin("GriefPrevention"); if(pluginGriefPrevention == null) { logger.info("The GriefPrevention plugin could not be found. This expansion will be automatically disabled."); expansionManager.disableExpansion(this); return; } String version = pluginGriefPrevention.getDescription().getVersion(); logger.info("Successfully hooked into GriefPrevention v" + version); saveDefaultConfig("griefprevention-compatibility.yml"); this.noEntryHandler = new GriefPreventionNoEntryHandler(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 13
Source File: CompatibilityResidence.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
@Override public boolean canEnable() { PluginManager manager = Bukkit.getPluginManager(); return manager.isPluginEnabled("Residence"); }
Example 14
Source File: LoggedPluginManager.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
/** * The constructor */ public LoggedPluginManager() { this(Bukkit.getPluginManager()); }
Example 15
Source File: SkyBlockHook.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
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 16
Source File: DefaultHook.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
public DefaultHook(String pluginName) { this.pluginManager = Bukkit.getPluginManager(); this.servicesManager = Bukkit.getServicesManager(); this.pluginName = pluginName; }
Example 17
Source File: CompatibilityTowny.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
@Override public boolean canEnable() { PluginManager manager = Bukkit.getPluginManager(); return manager.isPluginEnabled("Towny"); }
Example 18
Source File: CompatibilityGriefPrevention.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
@Override public boolean canEnable() { PluginManager manager = Bukkit.getPluginManager(); return manager.isPluginEnabled("GriefPrevention"); }
Example 19
Source File: Rewards.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
@Override public void onEnable() { PluginManager manager = Bukkit.getPluginManager(); JavaPlugin plugin = getPlugin().getPlugin(); manager.registerEvents(new ListenerRewards(this), plugin); }
Example 20
Source File: HookWorldGuard_V7_0.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
public static void registerListeners(NoEntryExpansion expansion) { Listener listener = new Listener_V7_0(expansion); JavaPlugin plugin = expansion.getPlugin().getPlugin(); PluginManager manager = Bukkit.getPluginManager(); manager.registerEvents(listener, plugin); }