Trying to get multiples YMLs

Discussion in 'Spigot Plugin Development' started by HotDoctor, Aug 18, 2019.

  1. Hey, im using this code:

    The point is for any reason the .yml saved in my .jar is not loaded in the config.yml created by the plugin and is like wtf
    Code (Java):

    public class Main extends JavaPlugin{
        PluginDescriptionFile pluginyml = this.getDescription();
        String rutaConfig;
        File configyml = new File(this.getDataFolder(), "config.yml");
        YamlConfiguration config = YamlConfiguration.loadConfiguration(configyml);
        public void onEnable() {

        public void SendMessageByConsole(String text) {
            String colored = ChatColor.translateAlternateColorCodes('&', text);
        public void registerConfig() {
            rutaConfig = configyml.getAbsolutePath();
            if(!(configyml.exists())) {
        public void setConfigDefaults() {
            this.saveResource("config.yml", true);
        public void saveConfig() {
            try {
            } catch (IOException e) {
                // TODO Auto-generated catch block
  2. JavaPlugin has a method "saveResource()"
    So if you want to save a File on your plugin folder from your jar just call JavaPlugin#saveResource(String fileName);
    ( for you its this.saveResource("config.yml") )
  3. I think I have already put that, check all code.
  4. Oh didnt scroll down...

    What exactly is the problem here? Try to describe what you expect to happen and what you actually observed.

    Edit: Do you have default values in the original yml inside your jar?
    If yes then your call of the method saveConfig is useless and you can delete it.
    #4 7smile7, Aug 18, 2019
    Last edited: Aug 18, 2019
  5. I have practically everything but when I load the plugin it just does not work, I mean the yml is created but it's empty
  6. Is the yml inside your jar empty?
  7. nop, it has content
  8. Instead of trying to use config.yml as a custom config use the default config methods as they are already included in Spigot.

    saveDefaultConfig()- will put the values inside your config from the config.yml in your jar file.

    Your trying to over complicate it.

    Sent from my iPhone using Tapatalk