getConfig retrieves incorrect value

Discussion in 'Plugin Development' started by Pink__Slime, May 26, 2013.

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

    Pink__Slime

    Hey Community.
    I'm having a problem with my config file.
    I have set boolean values in my config and currently, they are all true but it's saying one is false (tank).

    I have it so if it's disabled, the icon won't appear in the menu and the ones after it will fill in the gap.
    I also created a Enabled/Disabled list to check which were enabled or disabled when I entered a command and Tank is the only one showing as disabled.

    In the menu, tank doesn't show either.

    In the pastes I have the lines involving Tank highlighted.
    Config:
    http://pastie.org/private/3cbiraznzcbku0xforxhbw#14

    Creating the Inventory:
    http://pastie.org/private/07ktur1nkouhhbeksoitma#156-158

    Disabled/Enabled List:
    http://pastie.org/private/syiqmdek0gk7tymwb3oq#27-31

    I've checked for typos, changed the way I did it slightly, everything I thought of doing didn't change it.
    There are no errors either which is strange.

    Just added a System.out.println("") to Tank in my Enabled/Disabled list and it's returning false there as well.

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    beastman3226

    What does inst() return?
     
  3. Pink__Slime
    Why don't you use the local 'plugin' field if you bothered to create one instead of Main.inst() ?
     
  4. Offline

    Pink__Slime

    Main class.

    Because it never seems to work for me and I create them still out of habit. Don't ask why, just a habit.

    Anyways, it's not because of that. Well at least I doubt it's because of that.

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  5. Offline

    Pink__Slime

    Could this be an issue in the way I load my config file?
     
  6. Pink__Slime
    Probably, post debug messages with the value everywhere and see where it turns false... and expecially after you load the config.
     
  7. Offline

    Pink__Slime

    Digi Only tank is returning false.
     
  8. Pink__Slime
    Well, start posting some more code then... or if you want you can post the jar and the config and I'll try to find the issue.
     
  9. Offline

    Wingzzz

    So if you can get the value of "kits.tank.enabled" do:
    Code:java
    1. enabledKits.add(enabled + "Tank" + base);

    else do:
    Code:java
    1. enabledKits.add(disabled + "Tank" + base);

    I think the check should make more sense like
    Code:java
    1. if(Main.inst().getConfig().getBoolean("kits.tank.enabled") == true) {
    2. enabledKits.add(enabled + "Tank" + base);
    3. } else {
    4. enabledKits.add(disabled + "Tank" + base);
    5. }

    ... Anyways you should also try using your plugin variable you so nicely put in your constructor but never used. If you have difficulty with using a plugin variable of your main class, you need to make sure your class is initialized with the correct parameter ie:
    Code:java
    1. // if initializing the variable onEnable() or from somewhere in the main you can simply use the keyword 'this'
    2. Enabled enabled = new Enabled(this);
     
  10. Offline

    Pink__Slime

    Digi
    I'll pm you a link to the jar file.

    WiredWingzzz
    I don't understand what you mean... That's exactly what I am doing except I don't have the "== true" in it because it's not needed. And I had that before anyways.
     
  11. Pink__Slime
    Are you sure your <server>/plugins/SlimeKits/config.yml does not have kits.tank.enabled: false ? Because I just installed your plugin as-is with required dependencies and your debug message prints "true".
    Code:
    16:39:43 [INFO] [SlimeKits] Enabling SlimeKits v1.6
    16:39:44 [INFO] Configuration created.
    16:39:44 [INFO] Kits menu created
    16:39:44 [INFO] Select menu created
    16:39:44 [INFO] Armour added to ArrayList
    16:39:44 [INFO] true
    So I don't know what you really have there but the plugin is reading the config correctly... however, I can not change the config without shutting down the server because you're overwriting it in onDisable, but once I disabled that the config was also read correctly when I set certain stuff to false and then back to true.
     
  12. Offline

    Wingzzz

    Good to know :) (I'm a readability fanatic)
     
Thread Status:
Not open for further replies.

Share This Page