pdinklag / MinecraftStats

A Minecraft player statistics browser for the web - supports 1.13 and later!
https://discord.gg/brH5PGG8By
Other
230 stars 55 forks source link

Error trying to parse BlueMap config in Paper #229

Closed pdinklag closed 11 months ago

pdinklag commented 1 year ago

A user reported the following error message related to loading BlueMap's config in Paper:

[14:21:31 ERROR]: Cannot load /home/container/plugins/BlueMap/webserver.conf
org.bukkit.configuration.InvalidConfigurationException: while parsing a flow mapping
 in 'reader', line 21, column 6:
    log: {
         ^
expected ',' or '}', but got <scalar>
 in 'reader', line 31, column 3:
      append: false
      ^
        at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:111) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:160) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:128) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:309) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at de.pdinklag.mcstats.bukkit.BlueMapWebserver.<init>(BlueMapWebserver.java:21) ~[MinecraftStats.jar:?]
        at de.pdinklag.mcstats.bukkit.PluginWebserver.find(PluginWebserver.java:23) ~[MinecraftStats.jar:?]
        at de.pdinklag.mcstats.bukkit.MinecraftStatsPlugin.onEnable(MinecraftStatsPlugin.java:27) ~[MinecraftStats.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:189) ~[paper-1.20.1.jar:git-Paper-169]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.1.jar:git-Paper-169]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugin(CraftServer.java:640) ~[paper-1.20.1.jar:git-Paper-169]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugins(CraftServer.java:551) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:635) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:434) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1100) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.20.1.jar:git-Paper-169]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing a flow mapping
 in 'reader', line 21, column 6:
    log: {
         ^
expected ',' or '}', but got <scalar>
 in 'reader', line 31, column 3:
      append: false
      ^
        at org.yaml.snakeyaml.parser.ParserImpl$ParseFlowMappingKey.produce(ParserImpl.java:896) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:319) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157) ~[snakeyaml-2.0.jar:?]
        at org.yaml.snakeyaml.Yaml.compose(Yaml.java:575) ~[snakeyaml-2.0.jar:?]
        at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:104) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 18 more
Dad-Ju commented 12 months ago

Just Looked around a bit, wouldn't it be better to use the official API anyways ? API DOCS: https://bluecolored.de/bluemapapi/latest/de/bluecolored/bluemap/api/WebApp.html#getWebRoot()

Install : https://github.com/BlueMap-Minecraft/BlueMapAPI/wiki

Dad-Ju commented 12 months ago

Hey, Check the discord i wrote down some stuff there :)

pdinklag commented 12 months ago

Replying here to keep technicalities where they belong. First off, thanks for doing research on this!

So apparently BlueMap doesn't use YAML but whatever HOCON is, that explains of course. By adding BlueMap as a soft dependency to MinecraftStats, you should be able to force it to load after BlueMap and then the API could be used.

However, the BlueMap support is meant to be a small convenience feature. I won't increase the required Java version just for that, and the Configurate library that they use is totally overkill just to parse one particular string from their config.

The way I see it, I should probably just not try and parse the configuration at all, but just use a regular expression on the file to get the webRoot.

Dad-Ju commented 12 months ago

Sure thing, happy to help out! :D Using a regex might be the best anyways to ignore special configtypes like that.