Minecraft Blogs / Tutorial

Creating Bukkit Plugins part 1 - Setting up your workspace

  • 509 views, 3 today
  • 3
  • 0
  • 6
gabe4356's Avatar gabe4356
Level 52 : Grandmaster Blob
205
Hey guys, gabe4356 here, and I will be showing you how to make a bukkit plugin today! Now, I will start off with text tutorials, because, I think it is eaiser to learn from text tutorials rather than video tutorials, but I will be comming out with video tutorials for these as well!

   Before we actually get to coding, we will need to setup our workspace, this is the most important part of this, if the workspace is not setup properly, then nothing will work. So, first you will need to download these to get started:
Java 7 JDK: Download here
Eclipse: Download Here
Up to date version of CraftBukkit: Download Here
If you do not know how to install those, you probably shouldn't be trying to learn how to code bukkit plugins. (You do NOT need to install CraftBukkit, as it is not something you install)

Now, open eclipse. You will be welcomed by a warm welcome screen. Kill..I mean close it.
Now you will need to setup The Project, package, and main class.

Step 1: Right click in the left hand side of the screen. 

new>Java Project

Name the Project something, in this tutorial, I will be naming it 'Tutorial'
Click Finish
Step 2: Click the arrow next to the Folder you created to the left.
Right click src > New > Package
Name the package something, I wil be naming it "com.gabe" You can name it something like "com.YourName"
Click FInish
Step 3: right click the package you just craeted under 'Src'
New > Class
Name it "MainTutorial" or something like that.
Your class should appear to be this:

Code
package com.gabe;

public class MainTutorial {

}


Now we need to add the onEnable and onDisable Methods. So just add this:

Code - onEnable onDisable
package com.gabe;

public class MainTutorial {

public void onDisable() {
    //On Disable method stub
}

public void onEnable() {
   //on Enable Method stub
    {
    
}
}
}

Now we need to add some imports. You first need to build a path. So Right click on your Tutorial Project.
Build Path > Add External Archives
Now Select the craftBukkit.jar you downloaded earlier
It will appear under "Reference Librarys"
Now, we import the needed imports.
Code - Imports
package com.gabe;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class MainTutorial {

public void onDisable() {
    //On Disable method stub
}

public void onEnable() {
   //on Enable Method stub
    {
    
}
}
}

Now, the imports will be highlighted with warnings, because we are not using them. That will fix later.

Now, we need to extend the class to Java Plugin Like this:

Code - Java Plugin
package com.gabe;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class MainTutorial extends JavaPlugin {

public void onDisable() {
    //On Disable method stub
}

public void onEnable() {
   //on Enable Method stub
    {
    
}
}
}

Now we need to create the plugin.yml file. This is quite important. It basicly, registers the plugin.
So, right click src > New > File
Name it plugin.yml (MUST BE NAMED plugin.yml !)
Then click Finish. Now this is the code for plugin.yml file:
Code - Plugin.yml
name: Tutorial
main: com.gabe.MainTutorial
version: 1.0
The name is what shows up when you type /plugins and the main is where the main class is located in the plugin.
So in this cse, it is located in com.gabe.MainTutoiral (MainTutoiral being the class) And the version, well, that is pretty staight forward.

That concludes this tutorial! Note: This plugin will not do anything yet, it is just what we will work with in the next tutorial. I didn't want to make your mind explode :P) I hope this was very helpfull, NOTE: This will be a huge tutorial, I will be adding on more and more.)
  
  Click me to go to next tutorial
Tags

Create an account or sign in to comment.

1
09/03/2014 3:57 pm
Level 27 : Expert Narwhal
awesomeperson50
awesomeperson50's Avatar
well this will be very very useful
1
09/03/2014 4:01 pm
Level 52 : Grandmaster Blob
gabe4356
gabe4356's Avatar
:)  
 
Cheseari Will not Obey The Daleks!


|


|


V

Î⟨•…•⟩Ì
1
09/03/2014 4:10 pm
Level 27 : Expert Narwhal
awesomeperson50
awesomeperson50's Avatar
xD
1
08/31/2014 8:45 pm
Level 13 : Journeyman Modder
MCDiamondHost
MCDiamondHost's Avatar
Good tutorial for users new to Bukkit source.
1
08/31/2014 9:09 pm
Level 52 : Grandmaster Blob
gabe4356
gabe4356's Avatar
Thanks!
1
09/01/2014 12:51 pm
Level 13 : Journeyman Modder
MCDiamondHost
MCDiamondHost's Avatar
No problem :)
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome