My plugin needs two '/chests reload' to work, anyone see why?

Discussion in 'Plugin Development' started by dxwarlock, Jun 9, 2012.

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

    dxwarlock

    Do i have to order or such wrong here?
    my reload command works..and sends data in chat of the variables..but I have to reload twice for it to actually read the config

    this is my reload plubic void

    Code:java
    1.  
    2. //manual load-------------------------------------
    3. public void readConfig(Player p) {
    4. FileConfiguration fconfig = getConfig();
    5. reloadConfig();
    6. Roll = fconfig.getInt("Roll", 10);
    7. Money = fconfig.getInt("Money", 10);
    8. MoneyChance = fconfig.getInt("MoneyChance", 10);
    9. ratioChance = fconfig.getInt("RatioChance", 10);
    10. Ultra = fconfig.getInt("UltraItems", 16);
    11. Rare = fconfig.getInt("RareItems", 8);
    12. Normal = fconfig.getInt("NormalItems", 8);
    13. Crap = fconfig.getInt("CrapItems", 8);
    14. //------
    15. UltraPer = fconfig.getInt("UltraPer", 16);
    16. RarePer = fconfig.getInt("RarePer", 16);
    17. NormPer = fconfig.getInt("NormPer", 16);
    18. CrapPer = fconfig.getInt("CrapPer", 16);
    19. //------
    20. p.sendMessage("Roll:" + Roll);
    21. p.sendMessage("Money:" + Money);
    22. p.sendMessage("MoneyChance:" + MoneyChance);
    23. p.sendMessage("ratioChance:" + ratioChance);
    24. p.sendMessage("UltraPer: " + UltraPer + " CountMax: " + Ultra);
    25. p.sendMessage("Rareper: " + RarePer + " CountMax: " + Rare);
    26. p.sendMessage("NormPer: " + NormPer + " CountMax: " + Normal);
    27. p.sendMessage("CrapPer: " + CrapPer + " CountMax: " + Crap);
    28.  


    I'm pretty sure anything after " CrapPer = fconfig.getInt("CrapPer", 16);" can be ignored for debugging..
    but anyone see anything in this that would need TWO /chests reload to work?
     
  2. Offline

    nehuskerfan2

    So this is how to do a reload? Sorry I'm a bit of a newbie, and not helping here. I can't seem to get a generating configuration file working. Can you help me on that? :confused: Sorry lol
     
  3. Offline

    dxwarlock

    no this just reloads it, but it takes me 2 tries of the same command
     
  4. The problem:
    Code:
    FileConfiguration fconfig = getConfig();
    reloadConfig();
    You're storing the old reference, swap the codes and it will work properly:
    Code:
    reloadConfig();
    FileConfiguration fconfig = getConfig();
     
    ferrybig likes this.
  5. Offline

    dxwarlock

    Last edited by a moderator: May 26, 2016
Thread Status:
Not open for further replies.

Share This Page