Config can not be resolved

Discussion in 'Spigot Plugin Development' started by PsykoRaspberry, Dec 7, 2017.

  1. Hey! I use Eclipse to code my plugin and while I'm trying to make my config, this comes up:
    Screen Shot 2017-12-06 at 10.22.18 PM.png
    If you look close enough, you'll see that the "config" in "if (config.getBoolean("enable"))", is underlined in red. When I hover over it to try to import something, these are the only options it gives me:
    • Create local variable config
    • Create field config
    • Create paramater config
    • Create class config
    • Create constant config
    • Create interface config
    • Create enum config
    • Change to ColomnConfig
    • Change to Configurator
    • Change to CorsConfig
    • Fix Project Setup
    Please help me because don't know what to do because there is usually an option to import something.
  3. It would not. And pretty much anyone here will give you the same advice. Don't try to make plugins without learning Java, it'll just be as bad as try to make a house without knowing carpentry; sure, you'll make one even if you don't know carpentry but it'll be a rather bad house instead of good one that you would've made if you knew it.

    You just have to learn the basic concepts and fundamental principles, then you can go ahead with the trial and error path.
    • Like Like x 1
  4. Basically, what you have done is created a resource (a file inside the project) now you cant use a resource as a variable (a file/resource is not a variable) to access a file as a variable you must do something like File variable = new File("C:/folder/file.txt"), but for spigot there is a getDataFolder method, this method returns a directory that would be where your config files would be, this directory is usually "pathToServer/plugins/myPlugin", now to use your resource you have to copy it into the data folder, if your resource is config.yml spigot already has a method called saveDefaultConfig(), which basically copies the data from the resource to the config.yml in data folder, now to access the config inside your class spigot has a method called getConfig(), to save its saveConfig(), i have explained what it is your doing wrong but it would be much better if you were to learn java before getting into development
  5. I already know basic Java, but I just can't figure this out.
  6. Bro, this is BASIC problem solving. You have no variable called config, and you have to find a way to either grab a FileConfiguration object and assign it to the config variable that you create or not use a variable called config for your FileConfiguration.

    This isn't advanced Java, this is basic programming.
    • Agree Agree x 2
  7. I don't think it's even basic programming, I think it's simple logic. You can't use something if it doesn't exist.
  8. FileConfiguration config = this.getConfig();

    There you go.

Share This Page