Plugin doesn´t create config.yml

Discussion in 'Plugin Development' started by HappyMaj0r, Apr 20, 2014.

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

    HappyMaj0r

    Hello everyone,
    I have a problem. I need a config.yml and used this piece of code for creating a config.yml but it doesn´t create it when i start the server.

    My Code :
    Code:java
    1. package main;
    2.  
    3. import java.util.HashMap;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.block.Action;
    13. import org.bukkit.event.player.PlayerInteractEvent;
    14. import org.bukkit.plugin.PluginManager;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16.  
    17. public class main extends JavaPlugin implements Listener
    18. {
    19. public void onEnable()
    20. {
    21. PluginManager pm = this.getServer().getPluginManager();
    22. pm.registerEvents(new EventListener(this), this);
    23. pm.registerEvents(new Waffen(this), this);
    24. pm.registerEvents(this, this);
    25.  
    26. this.reloadConfig();
    27. this.getConfig().options().header("Config for PlayerProfiles");
    28. this.getConfig().addDefault("MyViCrime.PlayerProfiles.Crime", "null");
    29. this.getConfig().options().copyDefaults(true);
    30. this.saveConfig();
    31. System.out.println("[MyViCrime] Config loaded!");
    32. }
    33.  
    34. public void onDisable()
    35. {
    36.  
    37. }
    38.  
     
  2. Offline

    Badeye

    HappyMaj0r have you created the config.yml in your project? There has to be a default one, otherwise the plugin does not create a config/folder.
    Also, do not get the config each time, get the FileConfiguration once and work with that, it is better to work with.
    Code:java
    1. final FileConfiguration config = this.getConfig();

    And you could also just save the default config first, that is defently going to create a file:
    Code:java
    1. this.saveDefaultConfig();
     
    HappyMaj0r likes this.
  3. Offline

    HappyMaj0r

    I created a empty config.yml at /src and exported it.
    But my plugin still doesn´t create the config.yml. I dont even see the config.yml in the exportlist from eclipse.
     
  4. Offline

    Badeye

    HappyMaj0r then you put it at a worng location, make sure it is on the same level as the plugin.yml. Do not put it into the src folder, put it outside of it. If your plugin loads up, then the plugin.yml is at the correct location so just place your config.yml there aswell. Also, refresh your project before exporting.
     
    HappyMaj0r likes this.
  5. Offline

    HappyMaj0r

    Oh its working now. I just deleted my plugin and exported it completely new instead of overwriting it.
    Code:java
    1. final FileConfiguration config = this.getConfig();
    2.  
    3.  


    I did th at now too.
    Its working now thank you !
     
Thread Status:
Not open for further replies.

Share This Page