Currently, our configuration file (glowstone.yml) is being read using the ServerConfig class. There are a few fields that may require a certain value range, and I think it would be preferable to warn the user on startup instead of having if-statements all around the code.
Some fields that may need validation include:
server.port: positive integer (valid port number)
server.max-players: positive integer
server.log-file: valid file path
game.gamemode, game.difficulty: valid enums
game.max-build-height: positive integer
creatures.limit.*: positive integers
folder.*: valid directory paths
files.*: valid file paths
And quite a bit more
I suggest we add some sort of Validator system to abstract this
Currently, our configuration file (
glowstone.yml
) is being read using theServerConfig
class. There are a few fields that may require a certain value range, and I think it would be preferable to warn the user on startup instead of having if-statements all around the code.Some fields that may need validation include:
server.port
: positive integer (valid port number)server.max-players
: positive integerserver.log-file
: valid file pathgame.gamemode
,game.difficulty
: valid enumsgame.max-build-height
: positive integercreatures.limit.*
: positive integersfolder.*
: valid directory pathsfiles.*
: valid file pathsI suggest we add some sort of Validator system to abstract this