GlowstoneMC / Glowstone

A fast, customizable and compatible open source server for Minecraft: Java Edition
https://glowstone.net
Other
1.9k stars 273 forks source link

Crash on invalid config value type #869

Closed matthi4s closed 6 years ago

matthi4s commented 6 years ago

Glowstone build: 2018.3.0-SNAPSHOT.98b00f3 (MC: 1.12.2)

After searching for a problem with Glowstone server starts, I've discovered a bug in our system, which sets all lines with only monsters: in it to monsters: true/false. Glowstone completely crashes on start because of this (see output below) and doesn't even log anything, which makes it hard to find the issue. I don't know if the server should start when the config is invalid (reading ServerConfig.java it seems that it should only warn and use the default value), but it should probably still log the error and maybe give an information about the invalid option to simplify the debugging here.

To reproduce:

Set a glowstone.yml config option to an invalid type (e.g. set creatures.limit.monsters to true)


Output:

22:37:28 [INFO] This server is running Glowstone version 2018.3.0-SNAPSHOT.98b00f3 (MC: 1.12.2) (Implementing API version 1.12.2-R2.0-SNAPSHOT)
22:37:29 [SEVERE] Error during server startup.
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Integer
    at java.util.function.Predicate.lambda$or$2(Predicate.java:101)
    at net.glowstone.util.config.ServerConfig.load(ServerConfig.java:269)
    at net.glowstone.GlowServer.loadConfig(GlowServer.java:980)
    at net.glowstone.GlowServer.(GlowServer.java:444)
    at net.glowstone.GlowServer.createFromArguments(GlowServer.java:494)
    at net.glowstone.GlowServer.main(GlowServer.java:454)