Prerequisite
It assumes that you have the Spigot-API jar file (obtainable with BuildTools or on The Nexus) which we will use.
1) Start Eclipse; you may change the workspace location if desired.
2) Create a new Project
- Set the project name to whatever you wish. Here, we chose SpigotBlankPlugin. Click next. Help image
- Select Add External JARs under the Libraries tab. In the JAR Selection dialogue box, select the spigot-api-shaded jar file, which can be found in Spigot/Spigot-API/target/ inside your BuildTools folder. Select Finish (Help image)
Right-click on src and click on New > Package. You may use any namespace convention you wish, just be consistent. Here, I use reverse domain name notation (e.g.: com.google.android). (Help image)
4) Create a new class
Right-click on the newly created package and select New > Class. Give it any name; since this is a blank plugin, I gave it the same name as the project. (Help image). Inside the editor, the newly created Java class will open. The code should look somewhat like this:
Code (Java):
package com.meeku.tutorialPlugin;
public class SpigotBlankPlugin {
}
public class SpigotBlankPlugin {
}
Your class must extend from JavaPlugin. This makes your class inherit all fields and methods of the JavaPlugin class. This is the concept of inheritance (homework). Change the class constructor. Eclipse will produce an error as it does not know what JavaPlugin is. If you have successfully imported the Spigot-API, you will be able to import JavaPlugin by adding the import statement. You do not need to manually type that line, simply click the error and select the appropriate action (Help image). Your code should now look like:
Code (Java):
package com.meeku.tutorialPlugin;
import org.bukkit.plugin.java.JavaPlugin;
public class SpigotBlankPlugin extends JavaPlugin {
}
import org.bukkit.plugin.java.JavaPlugin;
public class SpigotBlankPlugin extends JavaPlugin {
}
The JavaPlugin class has some abstract methods which must be implemented by your plugin. Hence, add the onEnable and onDisable functions which will be triggered when the plugin is disabled or enabled in the console. You can leave these blank for now. You are also required to write @Override above the method.
Note: You do not need to add a getLogger when your plugin is enabled or disabled, Bukkit already does that for you.
Code (Java):
package com.meeku.tutorialPlugin;
import org.bukkit.plugin.java.JavaPlugin;
public class SpigotBlankPlugin extends JavaPlugin {
// Fired when plugin is first enabled
@Override
public void onEnable() {
}
// Fired when plugin is disabled
@Override
public void onDisable() {
}
}
import org.bukkit.plugin.java.JavaPlugin;
public class SpigotBlankPlugin extends JavaPlugin {
// Fired when plugin is first enabled
@Override
public void onEnable() {
}
// Fired when plugin is disabled
@Override
public void onDisable() {
}
}
Right-click the project and create a file New > File. Name it plugin.yml. Paste in the following:
Code (YAML):
name: SpigotBlankPlugin
main: com.meeku.tutorialPlugin.SpigotBlankPlugin
version: 1.0
api-version: 1.13
commands:
main: com.meeku.tutorialPlugin.SpigotBlankPlugin
version: 1.0
api-version: 1.13
commands:
Since there are no errors, we can export this project as a JAR. Right-click on the project name, select Export. In the consequential dialogue box, select JAR file (Help Image). Click Next. Change the export destination to your plugins folder.
9) Running
Run the bat file and you should see that the plugin was enabled
![[IMG]](http://proxy.spigotmc.org/e67e092ad9cfd260261757aded8951371d9928c7?url=http%3A%2F%2Fi.imgur.com%2F7AAy9M6.png)