Reading from Config produces error

Discussion in 'Plugin Development' started by caldabeast, Jan 17, 2012.

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


    My configuration setup is not working, and produces a stack trace error to where it reads from the file. If anyone could tell me what I am doing wrong, that would be fantastic!

    The config generator code:
    public class olyNauseate extends JavaPlugin{
        PluginDescriptionFile pdfFile = this.getDescription();
        public final Logger logger = java.util.logging.Logger.getLogger("Minecraft");
        public static olyNauseate plugin;
        FileConfiguration config = null;
        File configFolder = new File("plugins", "olyNauseate");
        File configFile = null;
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
  "[olyNauseate] Version " + pdfFile.getVersion() + " by CalDaBeast is now diabled.");
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
  "[olyNauseate] Version " + pdfFile.getVersion() + " by CalDaBeast is now enabled.");
            PluginManager pm = getServer().getPluginManager();
            if (!configFolder.exists()) {
      "[olyNauseate] This is your first time loading olyNauseate");
      "[olyNauseate] Generating Configuration File...");
      "[olyNauseate] Thank you for choosing olyNauseate!");
                File configFile = new File(configFolder, "config.yml");
                this.getConfig().set("olyNauseate.listOfRawsToUse", 1);
                this.getConfig().set("olyNauseate.effect.duration", 10);
                this.getConfig().set("olyNauseate.effect.strength", 3);
    and the line that actually gives the stack trace error:
    int rawList = config.getInt("olyNauseate.listOfRawsToUse");
  2. Offline


    whats the error, my guess is null pointer exception, and it would be happening because the variable config is null, however that line doesn't exist in the code you posted, and so that's just a guess based on the fact that the initial value of config is null and i don't see you changing it in the snippit of code you posted
  3. Offline


    wwsean08 that text is way down in the plugin, but the only thing giving a problem, but the config file *does* have that in it and, as far as i'm aware, is correct for reading off of. It just gives an error when it tries to do such. Do you (or anyone else) know what's wrong?

    The config file
      listOfRawsToUse: 1
        duration: 10
        strength: 3
  4. Offline


    There's a lot of strange and unnecessary code there :)

    FileConfiguration config;

    //inside onEnable()
    config = getConfig();

  5. Offline


  6. Offline


Thread Status:
Not open for further replies.

Share This Page