API/How to Setup
Set Up
First, you must add BanRecipe as an external jar to your build path (similar to how you link with Bukkit). To set up your plugin for use with BanRecipe, you must follow this. Put this line directly after the line with 'extends JavaPlugin' in your main class:
public static RecipeHandler recipeHandler;
Now add this method into your main class file, it doesn't matter where:
public void setupBanRecipeHook() { if (recipeHandler != null) { return; } final BanRecipe banRecipe = new BanRecipe(); Plugin banRecipePlugin = this.getServer().getPluginManager() .getPlugin("BanRecipe"); PluginDescriptionFile description = this.getDescription(); String prefix = "[" + description.getName() + "] "; if (banRecipeHookPlugin == null) { this.logger.info(prefix + "BanRecipe not detected, disabling plugin."); this.getPluginLoader().disablePlugin(this); return; } recipeHandler = new RecipeHandler(banRecipeHook); this.logger.info(prefix + "Found and will use BanRecipe version [" + banRecipeHookPlugin.getDescription().getVersion() + "]"); }
These two snippets together sets up the foundation of BanRecipe, and if BanRecipe isn't on the server then it disables your plugin. If you don't want it to disable your plugin, simply remove this.getPluginLoader().disablePlugin(this); from the second snippet.
Before we forget, make sure you put setupBanRecipeHook() into your onEnable() method! If you want to use the API as soon as the plugin starts up, then put your API code after the call to the API setup method.
You're now set to use BanRecipe with your plugin.
Uhh? I am confused. What is this for?