Brain fart moment..... Bug?

Discussion in 'Plugin Development' started by B3N909, Aug 1, 2014.

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


    I believe I am just having a brain fart moment, but here is my problem.
    1. public void onCreate(String name) {
    2. getConfig().set("space." + name, String.valueOf(name));
    3. saveConfig();
    4. }
    5. public void createOne(String name, double x1, double y1, double z1) {
    6. getConfig().set("space." + name + ".1.x", Double.valueOf(x1));
    7. getConfig().set("space." + name + ".1.y", Double.valueOf(y1));
    8. getConfig().set("space." + name + ".1.z", Double.valueOf(z1));
    9. saveConfig();
    10. }
    11. public void createTwo(String name, double x2, double y2, double z2) {
    12. getConfig().set("space." + name + ".2.x", Double.valueOf(x2));
    13. getConfig().set("space." + name + ".2.y", Double.valueOf(y2));
    14. getConfig().set("space." + name + ".2.z", Double.valueOf(z2));
    15. saveConfig();
    16. }

    What I have it doing is when I run a command I do something like
    2. onCreate(name);
    3. createOne(name, x, y, z);
    4. createTwo(name, x2, y2, z2);
    5. }

    Then when I have that in my code and run this in game it will generate something like this in the config:
    If you notice the error is that the 'createTwo()' overrides my first 'createOne()'???

    - Thanks
  2. Offline


    B3N909 It's overriding because your setting the config variable you used in createOne() in createTwo(), causing it to override it, it's not the method itself, in fact, if you would put createTwo() before createOne(), createOne() would be the overrider.
  3. Offline


    Niknea how could I fix this problem? I still have no idea what you mean by config variable... Do you mean the x,y,z in the second one should be changed to write to like 'x2, y2, z2'?

    Niknea I still got no idea :/


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


    B3N909 Don't bump more than once every 24 hours.

    Also, to fix this just in your onCreate method create 2 configuration sections, and with getConfig()#createSection(String path)

    In addition, I believe you need to learn a bit more Java, for you don't even know what Niknea was referring to by config variable.
    Niknea and TheSpherret like this.
Thread Status:
Not open for further replies.

Share This Page