Tutorial Diagnosing problems

Discussion in 'Resources' started by 0ct0berBkkitPlgins, Sep 18, 2015.

Thread Status:
Not open for further replies.
  1. A lot of people who post on the main part of the forum have not put a diagnostic system into their code. When you write your plugin, unless it's very small code and has little conditions, I HIGHLY RECCOMEND you add a debug system. To put it simply, a debug system allows you to tell when certain conditions aren't being met, and why.

    If you're going to be doing this a lot, I suggest you create this method at the bottom of your plugin, or on a separate class:
    public void debug(String message, Player p) {
    if (getConfig().getBoolean("debug")//Configuration option to turn debugging on {
    p.sendMessage("[Debug] " + message);
    In order for this to be ran, you'll need to turn debug to true in your configuration. This way not only you can debug the process, but also your plugin users if they did something wrong.

    Now I will show how to apply this in a common area of mistakes- item names:
    if (item.getDisplayName().equals("ยง6Magic Wand") {
    } else {debug("Incorrect item name: " + item.getDisplayName(), player);}
    If the in-game item name doesn't match what you're testing for and the debug mode is on, the player testing it will receive the message notifying them of what their item name is. You can apply this to any condition to help fix your problems without needing to wait for a reply on the forum.
    Last edited: Oct 21, 2015
    Matroxko likes this.
Thread Status:
Not open for further replies.

Share This Page