1.15.2 Problem get config.

Discussion in 'Spigot Plugin Development' started by Lulusmx, Sep 16, 2020 at 8:54 PM.

  1. Hello, I have a big problem, I created a hub plugin, and a command allows to save the inventory, xplevel, location, armor and after to restore them. Since I save all in the config.yml file I have to recover it's variables. The problem is that I can't get the x y z pitch yaw of the player's location as soon as I get it back, she puts all its values to 0, that's why I would need your help to solve this.

    Sorry for my english
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      135.6 KB
      Views:
      13
    • 2.PNG
      2.PNG
      File size:
      75.8 KB
      Views:
      8
    • 3.PNG
      3.PNG
      File size:
      19.6 KB
      Views:
      9
    • 4.PNG
      4.PNG
      File size:
      147.4 KB
      Views:
      8
    • 5.PNG
      5.PNG
      File size:
      110 KB
      Views:
      9
  2. I forgot to specify it works very well for xp and inventory tack, but not for location.
     
  3. pleasepleaseplease use hastebin or something like that i dont want to read through all that code in a picture
     
  4. are you sure that you always reload the config before using it and saving the config when you edit something?
     
  5. I just added in my code but same problem, I don't understand, yet its working fine with the inventory and experience, I think the problem is that the plugin cannot get the configuration
     
  6. Yes it is.




    You can use this code:
    private final File file = new File("plugins//YOURPLUGIN//config.yml");
    private final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);


    then add a getter for yamlconfig and replace it with "getConfig". also add in the onEnable this:
    try {
    yamlConfiguration.save(this.file);
    } catch (IOException e) {
    e.printStackTrace();
    }
    to create it if its not visible
     
  7. I go, but i dont understands. What should I do next?
     

    Attached Files:

    • 6.PNG
      6.PNG
      File size:
      16.4 KB
      Views:
      2
    • 7.PNG
      7.PNG
      File size:
      15.8 KB
      Views:
      2
  8. put this in yr main class tutomain
    private final File file = new File("plugins//YOURPLUGIN//config.yml");
    private final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);


    and not in the other
     
  9. and also you have to put try {
    yamlConfiguration.save(file);
    } catch (IOException e) {
    e.printStackTrace();
    } this in yr onEnable!
     
  10. Like this?
     

    Attached Files:

    • 8.PNG
      8.PNG
      File size:
      131.9 KB
      Views:
      2
  11. no you have to add it in the onEnable
     
  12. Oh ok sorry i dont understands, this good
     

    Attached Files:

    • 9.PNG
      9.PNG
      File size:
      130.9 KB
      Views:
      1
  13. Send it as hastebin pls