Linking To NightCrawlerCore

Working with the API is simple. Here are some example tutorials about how to work with this plugin.

Linking to NightCrawlerCore:

It is important to make sure that your plugin can link to NightCrawlerCore, or else it will not load properly. There are a few steps to make it link.

1) First off, you'll need to make NightCrawlerCore a dependency for your plugin. This means that Bukkit won't load your plugin unless the admin has both your plugin AND NightCrawlerCore. to do this, go into your plugin.yml. It'll look something like this.

name: EpicSnakes
main: path.to.EpicSnakes
author: You
version: 1.23
description: >
             Make epic snakes!

Now just go under version, and add this line.

"depend: [NightCrawlerCore]"

note, is this plugin has other dependency's, just add a comma and then NightCrawlerCore. Like this:

"depend: [SuperFireBall, MegaJump, NightCrawlerCore]"

Your plugin.yml should look like this now:

name: EpicSnakes
main: path.to.EpicSnakes
author: You
version: 1.23
depend: [SuperFireBall, MegaJump, NightCrawlerCore]
description: >
             Make epic snakes!

2) Now you have to make sure that the admin is using the right version of NightCrawlerCore. Otherwise, it make conflict and things won't work right. Lets go do that now. Head over to the onEnable section of your plugin. Add this method to your plugin, and then call it from the onEnable.

private static final int CORE_VERSION = 1;
public void hasCoreVersion(){
   Plugin core = this.getServer().getPluginManager().getPlugin("NightCrawlerCore");
   if(core==null){
   System.err.println("[//PLUGIN NAME//] Could not link to NightCrawlerCore! Disabling plugin...");
   this.setEnabled(false);
   return;
   }
   int version = Integer.valueOf(core.getDescription().getVersion());
   if(CORE_VERSION>version)System.err.println("[//PLUGIN NAME//] It appears you are using an out of date version of Core. This plugin is made to run for version "+CORE_VERSION+" of Core. This means some features may not work as intended, or may result in errors. It is recommended that you update Core soon.");
   else if(CORE_VERSION!=version)System.err.println("[//PLUGIN NAME//] It appears you are running a version of Core that this plugin does not support. This plugin is made to run for version "+CORE_VERSION+" of Core. This means some features may not work as intended, or may result in errors. It is recommended that you update this plugin, or downgrade Core to fit with this version soon.");
}

Only editing you'll have to do here is put your plugin name in. The rest of it you can copy and paste.

Note: the variable CORE_VERSION tells the plugin what version of NightCrawlerCore you want to use. NightCrawlerCore will always used whole numbers to represent its build version, so don't worry about changing it so a string or double.

3) The final step is to add NightCrawlerCore as a build path to your plugin. Do this the same way you put in Bukkit. Because it is different for every java editing tool, I cannot explain how to do this well.

And your done! Your plugin now fully links to NightCrawlerCore!


Comments

Posts Quoted:
Reply
Clear All Quotes