下面列出了org.bukkit.plugin.PluginManager#getPlugin ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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");
}
}
@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);
}
}
@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);
}
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) {}
}
@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();
}
/**
* 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);
}
@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);
}
}
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);
}
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);
}
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;
}
@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);
}
}
@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);
}
}
@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);
}
}
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;
}
@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);
}
}
@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);
}
@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);
}
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;
}
public uSkyBlockAPI getAPI() {
PluginManager manager = Bukkit.getPluginManager();
Plugin plugin = manager.getPlugin("uSkyBlock");
return (uSkyBlockAPI) plugin;
}
public static IEssentials getAPI() {
PluginManager manager = Bukkit.getPluginManager();
Plugin plugin = manager.getPlugin("Essentials");
return (IEssentials) plugin;
}