Copying contents of a HashMap to a ConfigurationFile

Discussion in 'Plugin Development' started by JRL1004, Nov 17, 2013.

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

    JRL1004

    So I have this code:
    Code:java
    1.  
    2. public class Main extends JavaPlugin {
    3. public FileConfiguration fc = null;
    4. public HashMap<String, Integer> cCount = new HashMap<String, Integer>();
    5.  
    6. @Override
    7. public void onEnable() {
    8. File f = new File(getDataFolder(), "/playerData.yml");
    9. if (!f.exists()) {
    10. try {
    11. f.createNewFile();
    12. } catch (IOException e) {
    13. e.printStackTrace();
    14. }
    15. }
    16. fc = YamlConfiguration.loadConfiguration(f);
    17. PluginManager pm = Bukkit.getPluginManager();
    18. super.onEnable();
    19. }
    20.  
    21. @Override
    22. public void onDisable() {
    23. for(int i = 0; i < cCount.size(); i++) {
    24. String key = null;
    25. Integer amount = cCount.get(i);
    26. fc.set(key, amount);
    27. }
    28. super.onDisable();
    29. }
    30. }
    31.  

    in the onDisable is where I am trying to get the contents of HashMap cCount and put them into the file "fc" as Key: Object. The problem I have is that I do not know how to put the contents of the HashMap into the file
     
  2. Offline

    PogoStick29

    Like this?
     
Thread Status:
Not open for further replies.

Share This Page