Tutorial The Definitive Guide to Bukkit Plugin Development

Discussion in 'Resources' started by Dragonphase, Dec 12, 2014.

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


    The Definitive Guide to Bukkit Plugin Development
    This post is designed to act as a bookmark for anyone wishing to forward people towards resources that may aid them in learning the principles of Object Oriented Programming (OOP), how to use Java and how to use the Bukkit API. I am aware that several resources similar to this exist within the forums, however it is clear that they are not used as often as they could be, thus I urge you to reference this thread to anyone who clearly shows a lack of understanding of the aforementioned, as opposed to wasting your time trying to teach them something they do not understand.

    Additional Notes:
    • This post will not teach you how to create a program using Java.
    • This post will not teach you how to develop a plugin using the Bukkit API.
    So you play Minecraft, you play on several cool servers and you want to contribute to the development of plugins that could be used to improve the game or add new features to it. Chances are you have a limited understanding of Java and the principles of OOP. You've probably Googled "How to make a Bukkit plugin" and clicked on the first YouTube link in the results, and you've tried to make a simple plugin using the same code. Well, that's your first mistake, and I'm going to tell you why.

    Why to ignore YouTube videos for Bukkit Plugin Development
    Almost every YouTube video tutorial for Bukkit Plugin Development shows the use of bad programming practices. Most of these videos are also outdated. Take the first video result for example - How To Make a Bukkit Plugin: Episode 1 *The Basics* | 1.8+ |. This video was uploaded in early 2012 and demonstrates the following, in order:
    • A disregard for the requirement of Java knowledge and the principles of OOP.
    • A biased requirement to use the Eclipse IDE, as opposed to detailing any other IDEs that could be used.
    • Incorrect package naming convention.
    • A static field reference to the Plugin┬╣.
    • A static Logger field reference to Minecraft's Logger.
    • Custom Enable / Disable messages.
    • A lack of demonstration of development in an Object Oriented fashion.
    • An unchecked cast from CommandSender to Player.
    A large majority of these videos are made by people with minimal knowledge of Java and/or the Bukkit API. Very few of these videos encourage or require you to have knowledge of Java before proceeding to watch them. Additionally, almost everyone who watches these videos end up copying the coding standards used in them.

    The first thing you should have done was clicked on the first result - Plugin Tutorial - BukkitWiki. It provides resources that are designed to aid you in plugin development.

    What is a Bukkit Plugin?[​IMG]
    A Bukkit Plugin is a .jar file that is loaded from the server's "plugins" folder when it is executed. It contains Java code that is compiled into .class files, which is then read and executed by the server. The code used in the plugin determines how the plugin should operate; a plugin uses the Bukkit API to improve the usability of the server or add unique new features. Bukkit Plugins are designed to operate server-side, which means that the default behavior of the Minecraft Client remains unchanged. Bukkit Plugins are written using Java.

    What to do before considering developing a Bukkit Plugin[​IMG]
    You've probably been told this before, but if you've managed to read this far, there may be hope; pick up a Java Book and read it. This is the single best thing that anyone can do if they have no knowledge of how to use Java. Any Java Book should teach you the principles of Object Oriented Programming, or at the very least, reference materials that provide that information.

    Use the examples provided in the books and make some simple programs. One of the best ways to learn is to start coding something. Assuming you understand Java and the principles of OOP, create a Hello World program, then a calculator, then a text editor, and so on. Don't just copy a full program's source code from the internet, as you won't learn anything.

    How to overcome issues in development[​IMG]
    Don't quit because you have made mistakes in your programs. Making mistakes is a great way to learn, especially when programming, as it encourages you to think about the problem and understand how to resolve it. There are resources available to you if you can't seem to resolve an issue by yourself; StackOverflow is a great one, as there's a good chance that someone else has had the same problem and resolved it.

    Learn to read and understand Stack Traces. You will encounter bugs in your programs; Stack Traces will help you trace where the bugs occur and provide you with detailed information as to what went wrong. You should see this in any Java book.

    Do some Rubber Duck Debugging. That's not a metaphor, and it's a real and effective method of debugging code. You don't necessarily have to use a rubber duck. Verbally explaining the problem or purpose of your program can help you better understand its operation and find a solution.

    Keep a record of your progress in a personal diary and add to it at the end of the day. By keeping track of what you've done thus far, it may help you understand what more needs to be done, and provide you with a better understanding of how your program should operate.

    I know Java, I don't know Bukkit - What do I do?[​IMG]
    As explained above, the first place you should look is here - Plugin Tutorial - BukkitWiki. It contains everything you need to know to develop a Bukkit Plugin. It's incredibly detailed without being overly-complicated. If you're willing to learn and read, I suggest you start there.

    If you managed to somehow miss the section of the Bukkit Javadocs, here's a link to them. The Javadocs contain detailed documentation of the Bukkit API which should be used to better understand the API and how it operates.

    I'm stuck and I need help[​IMG]
    As explained above, there are resources available to you if you can't seem to resolve an issue you have encountered. One such resource is right here, in the Plugin Development section of the Bukkit Forums. Please read the sticky posts at the top of the forum before posting a new thread. You can also use the search function located at the top of every forum page.

    Try to be as clear as possible when asking for support in the forums, as it helps others understand what your problem is. Provide as much information as possible which relates to your problem, including a description of what you are trying to achieve, any code you have and any Stack Traces you have encountered.

    Don't take responses so critically, and if you are responding to a topic in aid of another developer, try not to appear condescending or critical. If you can't deal with a situation in a mature fashion then you should not be using the forums.

    Finally, there's also the Resources sub-forum, which contains resources that other keen developers have willingly contributed to aid others in plugin development.

    Additional Resources[​IMG]
    Google Java Style - A document detailing the Java Style that Google uses, and an extremely useful resource for anyone wishing to use a similar style for well-structured programming.

    Improving your plugin code - A useful resource submitted by teej107 detailing how to improve your plugin code by using better programming practices.

    ┬╣ - desht explains this very well in his post here.
    Last edited: Dec 13, 2014
  2. Offline


    I even created a thread to inform those poor unfortunate developers who stumbled upon poorly made video tutorials and told them how to fix the mistakes.
    Dragonphase likes this.
  3. Offline


    Very true! The Rubber Duck method works almost every time I walk through a logic bug.
    teej107 likes this.
  4. Offline


    I'll try the rubber duck today. :')
Thread Status:
Not open for further replies.

Share This Page