Configuration Section

Status
This thread has been locked.

Phear

Feedback score
0
Posts
7
Reactions
4
Resources
0
I'm trying to get a loop going for a configuration section. Here is a config example:

Code:
reports:
  389515f2-6aa6-475a-b5ca-8965422e2729:
    Zoxu: Hacking
    Italic: Fly Hacking

The line of code trying to loop through the config is:
Code:
        for (String users : main.getDataFile().getConfigurationSection("reports." + target.getUniqueId().toString()).getKeys(false)) {

I'm getting a NullPointerExceptionError when this loop runs.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

lightlord323

Feedback score
3
Posts
33
Reactions
19
Resources
0
I dont see what you're doing with the config, you're storing player names under 1 player's uuid?
 

lightlord323

Feedback score
3
Posts
33
Reactions
19
Resources
0
Anyway, the problem is with Main.getDataFile(), this returns an instance of the folder of the plugin inside the plugins folder ("plugins/YourPlugin") and not the yml, instead you should use getConfig()
 

LordOfTime

Feedback score
15
Posts
602
Reactions
245
Resources
0
Anyway, the problem is with Main.getDataFile(), this returns an instance of the folder of the plugin inside the plugins folder ("plugins/YourPlugin") and not the yml, instead you should use getConfig()

He's right. Why would you use .getDatFile()? getConfig() is what you want. If you can't use that because you're not in the your main class, then get a copy of the config in your onEnable, store it in a FileConfiguration variable, and make a small function that returns it that you can call from your other classes.
 
Status
This thread has been locked.
Top