Solved Trying to load my yml config, throws FileNotFound

Discussion in 'BungeeCord Plugin Development' started by Trophonix, Jun 9, 2016.

  1. Hey! I'm pretty new to Bungee, and I'm trying to use the YML config API. I was using this wiki post as a reference.

    Code (Text):
    import net.md_5.bungee.api.connection.ProxiedPlayer;
    import net.md_5.bungee.api.event.PluginMessageEvent;
    import net.md_5.bungee.api.plugin.Listener;
    import net.md_5.bungee.api.plugin.Plugin;
    import net.md_5.bungee.config.Configuration;
    import net.md_5.bungee.config.ConfigurationProvider;
    import net.md_5.bungee.config.YamlConfiguration;
    import net.md_5.bungee.event.EventHandler;
    the private Configuration data; is line 22
    Code (Text):
        private Configuration data;

        public void onEnable() {
            getProxy().getPluginManager().registerListener(this, this);
            try {
                data = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "data.yml"));
            } catch (IOException ex) {
    Code (Text):
    17:18:21 [SEVERE] plugins/TeleportBeaconBungee/data.yml (No such file or directory)
    17:18:21 [SEVERE]     at Method)
    17:18:21 [SEVERE]     at
    17:18:21 [SEVERE]     at<init>(
    17:18:21 [SEVERE]     at<init>(
    17:18:21 [SEVERE]     at net.md_5.bungee.config.YamlConfiguration.load(
    17:18:21 [SEVERE]     at net.md_5.bungee.config.YamlConfiguration.load(
    17:18:21 [SEVERE]     at com.trophonix.teleportbeacon.TeleportBeaconBungee.onEnable(
    17:18:21 [SEVERE]     at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(
    17:18:21 [SEVERE]     at net.md_5.bungee.BungeeCord.start(
    17:18:21 [SEVERE]     at net.md_5.bungee.BungeeCordLauncher.main(
    17:18:21 [SEVERE]     at net.md_5.bungee.Bootstrap.main(
    So... Yeah. Am I supposed to be running something to specifically create the "data.yml"?
    If I do new File(getDataFolder(), "data.yml")).mkdirs(); it makes a directory called "data.yml".
    #1 Trophonix, Jun 9, 2016
    Last edited: Jun 10, 2016
  2. The file just doesn't exist. There's a method in the file class called .exists (); and if it returns false, you have to create the file with the method in the file class. I forgot the name but I think it's something like createFile(); then it should work.
    You shouldn't do mkdirs because you don't want data.yml to be a folder.
    • Like Like x 1
  3. Oh my gosh... I tried the .createNewFile() thing but I forgot that was inside an if statement checking if the DATA FOLDER doesn't exist (and it did exist because of previous failed attempts). Deeerrrp. ;-; Thanks xD