Solved Is this the correct method?

Discussion in 'Plugin Development' started by TheDiamond06, Mar 28, 2015.

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

    TheDiamond06

    So to tell if a poll is running or not, when one starts I run this code.
    Code:java
    1.  
    2. plugin.getConfig().set("pollrunning", "true");
    3. plugin.saveConfig();
    4.  

    This obviously does not work because when a poll is running in-game and when I test for it in this code.
    Code:java
    1.  
    2. if(plugin.getConfig().getBoolean("pollrunning") == true)
    3. {
    4.  
    5. }
    6. else
    7. {
    8.  
    9. }
    10.  

    it runs the else statement.
     
  2. Offline

    mine-care

    First things first, you set a string to a string and you try to get a Boolean.
    Remove the quotes from true then don't compare boo leans as Boolean == value but use if(Boolean) and if(!boolean)
    Lastly why you want it to store it in config and not locally in plugin;
     
  3. Offline

    TheDiamond06

    @mine-care I never knew you could store it locally in a plugin. Can you tell me how to do that, or send me a link about it.

    Also thank you, that worked. I thought that since the string is true, the boolean would register it as true. Whatever, but as you probably know saving the config with saveConfig() deletes #comments... You know a way around that
     
    Last edited: Mar 28, 2015
  4. Offline

    mine-care

    By locally I mean having a Boolean variable to hold the true/false and about comments you can extract the file from class path manually
     
Thread Status:
Not open for further replies.

Share This Page