My arena configs are not saving it its own .yml

Discussion in 'Plugin Development' started by xxmobkiller, Sep 29, 2014.

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

    xxmobkiller

    my Config will not work its keep using the old name to create a new file so if i type /arena create test it wil create file test.yml then if i type /arena create test2 it replace the test.yml in side it with my location when i used /arena create test2 i want it to create each arena its own config file.yml

    Code:java
    1. public class ArenasConfig implements Listener {
    2.  
    3. public FileConfiguration StorageFilef = null;
    4. private File customConfigFile = null;
    5. private TNTWars plugin;
    6.  
    7. public ArenasConfig(TNTWars plugin) {
    8. this.plugin = plugin;
    9. }
    10.  
    11. @SuppressWarnings("deprecation")
    12. public void reloadDataConfig(String name) {
    13. if (customConfigFile == null) {
    14. customConfigFile = new File(plugin.getDataFolder() + File.separator + "arenas" + File.separator, name + ".yml");
    15. }
    16. StorageFilef = YamlConfiguration.loadConfiguration(customConfigFile);
    17. InputStream defConfigStream = plugin.getResource("/arenas/" + name + ".yml");
    18. if (defConfigStream != null) {
    19. YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
    20. StorageFilef.setDefaults(defConfig);
    21. }
    22. }
    23.  
    24. public FileConfiguration getDataConfig(String name) {
    25. if (StorageFilef == null) {
    26. this.reloadDataConfig(name);
    27. }
    28. return StorageFilef;
    29. }
    30.  
    31. public void saveDataConfig(String name) {
    32. if (StorageFilef == null || customConfigFile == null) {
    33. return;
    34. }
    35. try {
    36. getDataConfig(name).save(customConfigFile);
    37. } catch (IOException ex) {
    38. TNTWars.getInstance().getLogger().log(Level.SEVERE,"Could not save config to " + customConfigFile, ex);
    39. }
    40. }
    41.  
    42. }
     
  2. maybe its because you forgot to save the file ?
    Code:
    StorageFilef.save(defConfig);
    
     
Thread Status:
Not open for further replies.

Share This Page