Basic Bukkit & Java Tutorial

Discussion in 'Resources' started by UntoldAdventures, Jun 25, 2013.

Thread Status:
Not open for further replies.
  1. Section 1 -- Downloading the required files & programs:

    Step 1)​
    Download the Java Development Kit, or JDK

    Step 2)
    Download Eclipse for JavaEE

    Step 3)
    Download the Bukkit API



    Section 2 -- Setting up your Work Space:
    Step 1)
    Create a Folder dedicated to Plugin Development

    Step 2)
    Launch Eclipse. You will be prompted with a loading screen similar to this:
    [​IMG]
    Step 3)
    Select 'Browse' and Navigate to the Folder you created in Step 1. Select 'OK'



    Step 4)
    Adjust your Tab Sizes until it looks similar to this:[​IMG]

    Step 5)
    Create a new Project, File>New>Project. Select Java Project and name it whatever you'd like.


    Step 6)
    Right Click on your Project and Select BuildPath>ConfigureBuildPath>Libraries>Add External Jars:
    [​IMG]

    Step 7)
    Navigate to the Bukkit API then Select 'OK' Your Project Explorer should now look like this:[​IMG]



    Step 8)
    Right Click on 'src' and select New>Package. If you have a website name it that (net.minecraft, org.bukkit, com.untoldadventures) If you don't name it lastname.firstname



    Step 9)
    Right Click on your package and select New>Class. Name it whatever your plugin will be called (BowSpleef, HungerGames, PvP)


    Section 3 -- Setting Up your Main Class
    Step 1)
    First, lets look at what is already in your class:

      • package (package) -- This is the location of your Class
      • public class (name) -- This is where your class name is defined
    With Java, you will be using a lot of 'Variables.' There are many different types and modifiers for each Variable which makes them "vary" from each other.
    Basic Types:
      • String -- A line of text. Always in double-quotes. Ex: "This is a String!"
      • Integer -- Known as int, this is any number. Ex: 4234
      • Boolean -- This is a basic True or False Ex: true
    Basic Modifiers:
      • Public -- This means other class' can use the variable
      • Private -- This means other class' can't use the variable
      • Static -- This means the variable isn't set. It can change
      • Void -- This means it doesn't return anything. This will make more sense later
    Currently, Bukkit doesn't even know that your class is a plugin. We will fix this by adding
    "extends JavaPlugin" after our Class Declaration:
    Code:java
    1. public class BasicBukkitTutorial extends JavaPlugin
    JavaPlugin is a Type of Variable and "extends" tells Bukkit that your Class is a JavaPlugin.

    Step 2)
    You might notice that there is an error under "JavaPlugin". Hover over it and Select "Import JavaPlugin". You may notice that there is now a line that says:
    Code:java
    1. import org.bukkit.plugin.java.JavaPlugin;
    Import means that your Class uses something from a certain package.class




    Step 3)
    In your Main Body (Inside the Brackets) type:


    Code:java
    1. public void onEnable() {
    2.  
    3. }

    The Code inside these Brackets will be run only when the server is enabling. This is where we will do a lot of our coding. Similarly to onEnable(), onDisable() is called when the server is disabling.​

    ** Note: This Tutorial is not yet Complete. Please let me know if there is any incorrect information or if you'd like to see a certain feature's usage **















     
    foodyling and Mattredsox like this.
Thread Status:
Not open for further replies.

Share This Page