Basic BUKKIT plugin Tutorial

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

Thread Status:
Not open for further replies.
  1. Offline

    Samkio

    <font color="rgb(51, 102, 255)">Basic BUKKIT plugin Tutorial</font>

    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):
    <Edit by Moderator: Redacted mediafire url>

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

    <font color="rgb(0, 0, 255)">Feel free to PM me any questions you have </font>:)
     
    Last edited by a moderator: Dec 15, 2016
    Guaele and r3Fuze like this.
  2. Offline

    Torrent

    Nice work.
    You're not too quiet this time around! ;)
     
  3. Offline

    Samkio

    Thanks :)
    Added source code.
    Fully Annotated [​IMG]
     
  4. Offline

    Archelaus

    Very nice. I was in the process of writing one of these myself.
     
  5. Offline

    blaatz0r

    And I started the day before yesterday and figured it out myself. Haha.

    Still nice! Very helpful.
     
  6. Offline

    Samkio

    Thanks :D
    Awesome can't wait to see some plugins. [​IMG]
     
  7. Offline

    MadMichi

    Very nice tutorial. Too late for me unfotunately [​IMG]
    Keep up the good work!
     
  8. Offline

    Novar234

    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!

    Samkio, maybe useful for adding a section for git to grab the source code to use in the reference libraries with the .jar file? https://github.com/Bukkit/Bukkit.git

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 6, 2016
  9. Offline

    zeiser

    I wouldn't call this a tutorial you're just pasting in a bunch of stuff......
     
  10. Offline

    Novar234

    Yea there is a lot pasting but he explains what each part does.
     
  11. Offline

    Bizz

    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.
     
  12. Offline

    Samkio

    Yes i am currently setting this up.

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

    Racha

    Nice, i will try to make something ;D Thanks.
    How can I make plugin withc uses iConomy money?
     
  14. Offline

    Samkio

    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 :)
     
  15. Offline

    blaatz0r

    I would like to get some more info on how to work with SQLite/flatfiles in combination with Bukkit. Any clues? :)
     
  16. Offline

    TerraPlay

    Can you give us the package import codes, please :S?
     
  17. Offline

    Samkio

    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
     
  18. Offline

    Racha

    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
     
  19. Offline

    TerraPlay

    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? ;)
     
  20. Offline

    Samkio

    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. :)
     
  21. Offline

    Torrent

    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. :)
     
  22. Offline

    Samkio

    I will thing is if i dont copy and paste it will be a very long video.
     
  23. Offline

    Torrent

    Could break it up into parts. Either way, it's still a good tutorial.
     
  24. Offline

    TerraPlay

    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 ;)
     
  25. Offline

    Samkio

    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
     
  26. Offline

    blaatz0r

    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.
     
  27. Offline

    MiniKahn

    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!
     
  28. Offline

    TerraPlay

    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
     
  29. Offline

    MiniKahn

    I am so sorry....
     
  30. Offline

    Samkio

    Thanks for this. Sometimes the reader reads it wrong so its best to write on 3 sepertate lines.
    Will update tutorial. :D
     
Thread Status:
Not open for further replies.

Share This Page