Skip to content

Making your plugin only start when it detects the API

TheCyberCode edited this page Sep 16, 2018 · 2 revisions

In your plugin.yml make sure you have this line:

depend: [CyberDevAPI]

Also in your main class put this in your onEnable() method:

	PluginDescriptionFile PDF = this.getDescription();
	if((Bukkit.getServer().getPluginManager().getPlugin("CyberDevAPI")==null)) {
		Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "-----------ERROR-----------" );
		Bukkit.getLogger().severe(ChatColor.RED + "[" + PDF.getPrefix() + "] Alert: Fatal Error Detected: CyberDevAPI was not found.");
		Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "-----------ERROR-----------" );
		Bukkit.getPluginManager().disablePlugin(this);
	}
Clone this wiki locally