Solved if statements not working?

Discussion in 'Plugin Development' started by TopTobster5, Feb 24, 2014.

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

    TopTobster5

    Hi. I have made some if statements but they don't seem to be working propaly.

    Code:java
    1.  
    2. if (Bukkit.getOnlinePlayers().length == 0) {
    3. if (getConfig().getBoolean("SaveOnNoPlayers")) {
    4. getLogger().info("Nobody online. Save not performed.");
    5. } else {
    6. Save();
    7. }
    8. } else {
    9. Save();
    10. }


    However, it is just running the Save() function, even though I have set SaveOnNoPlayers to true in the config. Any ideas?
     
  2. Offline

    Alshain01

    Your conditional looks backward to me. Should it be...?

    Code:java
    1. if (!getConfig().getBoolean("SaveOnNoPlayers")) {
     
  3. Offline

    AoH_Ruthless

    Alshain01
    His conditional is fine. The boolean is true, so it is not supposed to save, but it is saving.

    TopTobster5
    Did you add debug messages?
     
  4. Offline

    TopTobster5

    AoH_Ruthless No, I haven't used them before. How are they implemented.
     
  5. Offline

    Traks

    Add System.out.println("something"); or other methods that send messages, to different parts in the code and see if they get called
     
  6. Offline

    TopTobster5

    Sorry for wasting your time guys, but the problem was completely unrelated to the if statement. I had been working on another plugin, and accidentally exported the plugin for testing under the wrong name, meaning there were 2 versions of the plugin running, and the old version was the one which seem to be running. Thanks for your help anyway. The information about debug messages will come in handy anyway, so thanks again. :)
     
Thread Status:
Not open for further replies.

Share This Page