Basic BUKKIT plugin Tutorial

Discussion in 'Resources' started by Samkio, Jan 20, 2011.

  1. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Basic BUKKIT plugin Tutorial

    Hello I noticed although there is great documentation on how to set up a plugin there wasn't much on actually writing it.

    So i thought seeing as i had some free time to make a BUKKIT plugin tutorial that teaches you to make a plugin from scratch that actually does something. Hope this is helpful for people that don't have a clue.

    This tutorial shows you how to make a toggle commandable feature where when the user places a torch it relays a message.

    Video:


    Note: Bukkit has changed since the making of this video. http://forums.bukkit.org/threads/oops-i-broke-your-plugins.599 This post here will tell you what has changed. :)
    See updated tutorial: http://forums.bukkit.org/threads/bukkit-updates-tutorial.7093/

    Note: Do NOT use org.bukkit.* name for your plugin:
    http://forums.bukkit.org/threads/on-namespaces-please-do-not-use-bukkit-in-your-plugins.3732/

    Text:
    First up links:
    Latest BUKKIT: http://ci.bukkit.org/job/dev-Bukkit/
    Eclipse: http://www.eclipse.org/
    Java SE: http://www.oracle.com/technetwork/java/javase/downloads/index.html

    Source (Fully Annotated):
    http://www.mediafire.com/?ep4lze85tqcfqn4

    Souce:
    Basic.javahttp://pastebin.com/dZa0hKDZ
    BasicBlockListenerhttp://pastebin.com/PFT3Gsix
    BasicPlayerListenerhttp://pastebin.com/xmx0UbGr

    Feel free to PM me any questions you have :)
    Guaele and r3Fuze like this.
  2. Offline

    Torrent

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Nice work.
    You're not too quiet this time around! ;)
  3. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks :)
    Added source code.
    Fully Annotated [IMG]
  4. Offline

    Archelaus

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Very nice. I was in the process of writing one of these myself.
  5. Offline

    blaatz0r

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    And I started the day before yesterday and figured it out myself. Haha.

    Still nice! Very helpful.
  6. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks :D
    Awesome can't wait to see some plugins. [IMG]
  7. Offline

    MadMichi

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Very nice tutorial. Too late for me unfotunately [IMG]
    Keep up the good work!
  8. Offline

    Novar234

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks Samkio, im currently learning java, 2nd course now and starting to get a hang of it, just transitioning to bukkit can be overwhelming especially when there isn't much for code reference, lots of code hunting and such!
  9. Offline

    Novar234

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  10. Offline

    zeiser

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I wouldn't call this a tutorial you're just pasting in a bunch of stuff......
  11. Offline

    Novar234

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Yea there is a lot pasting but he explains what each part does.
  12. Offline

    Bizz

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You're a winner. Thank you for this, saw a link to your post in another forum. Anxious to get started now. Downloading everything I need.
  13. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Yes i am currently setting this up.

    + Thanks everyone :D Glad you like it
  14. Offline

    Racha

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Nice, i will try to make something ;D Thanks.
    How can I make plugin withc uses iConomy money?
  15. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Well from what i can gather. iConomy saves the users balance in a flat file.
    This flat file is located root>iConomy>accounts.flat
    What you would need to do is run a method to access the values stored in the flat file.
    In the flatfile the data is: Samkio=50
    So using a players name we can get their balance.
    Hope that helps :)
  16. Offline

    blaatz0r

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I would like to get some more info on how to work with SQLite/flatfiles in combination with Bukkit. Any clues? :)
  17. Offline

    TerraPlay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Can you give us the package import codes, please :S?
  18. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Maybe another tutorial me thinks :p
    As for now look at the source code for other plugins maybe helpful.

    They are in the source code aswell as at the top of these source links:
    Souce:
    Basic.javahttp://pastebin.com/dZa0hKDZ
    BasicBlockListenerhttp://pastebin.com/PFT3Gsix
    BasicPlayerListenerhttp://pastebin.com/xmx0UbGr

    Hope this helps :D
  19. Offline

    Racha

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Can you make a tutorial, how to work with just SQL? I Dont have it, and i dont know what i need to do with it. ;D
  20. Offline

    TerraPlay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thank you, i couldn't find them in the source i downloaded =)
    Will you continue this tutorial and show us how to use permissions, configs and so on? because i need this things for programming a plugin i want. Or can you give me any source examples of more advanced plugins? Thanks!

    Edit: and maybe arguments? ;)
  21. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I will make one seeing as it has had a lot of interest!
    Yes this is a Basic plugin i will make a new one for more advanced stuff. :)
  22. Offline

    Torrent

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I would just say, if you make another tutorial. Try not to copy and paste all the source and put it in a txt file.
    Some people might find it hard to follow along. :)
  23. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I will thing is if i dont copy and paste it will be a very long video.
  24. Offline

    Torrent

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Could break it up into parts. Either way, it's still a good tutorial.
  25. Offline

    TerraPlay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Yeah I agree with Torrent. I don't care if the video is up to 1 hour long if I can really learn something from it. And afaik you can upload up to 5 hours to youtube ;)
  26. Offline

    Samkio

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Sweet stuff :) Ok then im working on a new plugin tutorial slightly more advanced with dir creation, settings files and storing data(Sql/data etc). :D
  27. Offline

    blaatz0r

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    And again, I got it figured out before the tutorial. :p I knew some JDBC from a course on databases, the problem was that I needed to specify the sqlite library in a manifest file. You really want to mention that in your tutorial.
  28. Offline

    MiniKahn

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hello

    I have a question, when I create the plugin.yml file I get errors..
    One of them:
    null; mapping values are not allowed here..

    name: Basic version: 1.1 main:com.bukkit.minikahn.Basic.Basic
    Now when I create it without a space
    ( name: Basic version:1.1 main:com.bukkit.minikahn.Basic.Basic)
    the server says..
    could not load the plugin, because the version is not defined

    so, what I can do?

    ----> name:Basic --> The Name is not definied
    name: Basic -> it's okay
    version:1.1 -> the version is not defined
    version: 1.1 --> the argument is not allowed....( with 1.0 it's the same)

    pls help me!
  29. Offline

    TerraPlay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Just right-click on src, then on new->file, name it plugin.yml and copy this into your file:
    Code:
    name: Basic
    version: 1.1
    main: com.bukkit.minikahn.Basic.Basic
  30. Offline

    MiniKahn

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I am so sorry....

Share This Page