SOLVED THE ORIGINAL PROBLEM: Code: getConfig().options().copyDefaults(true); saveConfig(); was causing a problem. Is this no longer a valid way to automatically generate a config? I'll have to use the if file doesn't exist thing now, I guess. --Original Post-- So, I've been having an issue with configuration on BOTH of my plugins that use bombs. It's giving me errors on the same line "confusion-duration: 10" for both of them, so I know that I'm doing something wrong... Does anyone know why this is happening? Thanks! Config: Code: #Default configuration firelength: 5 defaultXP: 17 bomb: confusion-duration: 10 blindness-duration: 10 snowball: bomb-effect: confuse egg: bomb-effect: real-explosion Error: Code: [SEVERE] Cannot load plugins/SimpleActions/config.yml org.bukkit.configuration.InvalidConfigurationException: mapping values are not allowed here in "<string>", line 7, column 31: confusion-duration: 10 ^ at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:55) at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:138) at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:105) at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:175) at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:117) at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:111) at com.lavacraftserver.SimpleActions.Bomb.onProjectileHit(Bomb.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:330) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462) at net.minecraft.server.EntityProjectile.h_(EntityProjectile.java:159) at net.minecraft.server.World.entityJoinedWorld(World.java:1239) at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:498) at net.minecraft.server.World.playerJoinedWorld(World.java:1221) at net.minecraft.server.World.tickEntities(World.java:1119) at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:567) at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:212) at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:476) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:408) at net.minecraft.server.ThreadServerApplication.run(SourceFile:539) Caused by: mapping values are not allowed here in "<string>", line 7, column 31: confusion-duration: 10 ^ at org.yaml.snakeyaml.scanner.ScannerImpl.fetchValue(ScannerImpl.java:733) at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:305) at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:179) at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:563) at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:161) at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:146) at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:230) at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:160) at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:237) at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:160) at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:237) at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:160) at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:123) at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:106) at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:121) at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:480) at org.yaml.snakeyaml.Yaml.load(Yaml.java:399) at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:53) ... 24 more
Hmm... I'll try it, but... Well, I mean look at the other integers in the config ^_^. Those don't give errors. I'll try that once I get home, which will be in ~2 hours. -_-
Guessing your using "getConfig().getString("bomb.confusion-duration");" Instead of "getConfig().getInteger("bomb.confusion-duration");" ?
I'm not stupid. I can actually see myself doing that. -_- I'll check once I get home; thanks! Code: plugin.getConfig().getInt("bomb.confusion-duration", 5) That's what I'm using. Is that 5 messing it up? I thought that was the default value of the integer. Let me go test without that 5... :3 EDIT: It wasn't the 5's. EDIT 2: Tried that, exact same error. EDIT 3: Rewrote the config; didn't seem to help. EDIT 4: Deleted the config, then retyped. The problem is now magically fixed! Thanks to everyone who took the time to help! EDIT 5: I figured out what the issue was. Code: getConfig().options().copyDefaults(true); saveConfig(); Is this no longer a valid way to generate a config? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
It works for me. May I see your code where you put those lines? EDIT: Caleb is right: you need to refer to "this" when using those methods. So: this.getConfig().options().copyDefaults(true); this.saveConfig();
Actually you don't need the this keyword if it is in your main class. Even if it wasn't in the main class you don't need the this method and would instead use the plugin variable, but since i didn't see that in what he posted i shall assume he is doing this in his onEnable. If he was doing it from another class and wasn't using the plugin variable then he would get a compilation error. I don't have enough code here to see what the actual error may be.
I did use the config generation in the onEnable. I don't think I've ever used this, and haven't had issues before. I'll be able to post the full code here later, but it's literally the above code plopped in the onEnable. theguynextdoor JayzaSapphire