Custom Config Always Returns Null.

Discussion in 'Spigot Plugin Development' started by Bladian, May 12, 2015.

  1. I currently have a custom config in my Mounts folder inside my plugins folder.

    I access it, through this method, but it always returns null.

    Code (Text):
    public static FileConfiguration getLanguageConfig() {

            File folder = new File(Core.getInstance().getDataFolder() + File.separator, "language.yml");
            FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(folder);

            return fileConfiguration;

    I think I have the folder getter, set incorrectly, and if so, I'm not sure what to change it to.
  2. @BurnerDiamond what exactly is null? YamlConfiguration.loadConfiguration is never null iirc.
  3. Configs can never be null. It always creates a path. I think there's an exception to primitive types e.g checking for a boolean.
  4. Sorry, I meant the strings return null.
  5. then that has nothing to do with config loading...

    null returns mean the value either isn't present or is manually set to null.
  6. But it is present since it's all in the config.

    Code (Text):
    current-mounts-chest-name: MOUNTS
    rental-mounts-chest-name: &e&lRENTAL MOUNTS

      mounts-item: "&e&lMounts"
      rent-mount-item: "&e&lRent-A-Mount"
      advertisement: "&4l&Advertisements and Sales"
      exit: "&4&lExit"

      chicken: Chicken
      cow: Cow
      pig: Pig
      sheep: Sheep
      zombie: Zombie
      creeper: Creeper
      spider: Spider
      skeleton: Skeleton
      enderman: Enderman
  7. @BurnerDiamond print the absolute path and manually check if it exists in your file system.
  8. What exactly do you mean by the absolute path?
  9. @BurnerDiamond File#getAbsolutePath(). That way you are 110% sure that if the file exists, you know that you are looking at the right file as well.