mirror of
https://github.com/unmojang/drasl.git
synced 2025-08-03 10:56:06 -04:00
config: allow unlimited max player count (-1)
This commit is contained in:
parent
141db389ea
commit
25c0404514
@ -182,8 +182,8 @@ func CleanConfig(config *Config) error {
|
||||
if _, err := os.Open(config.DataDirectory); err != nil {
|
||||
return fmt.Errorf("Couldn't open DataDirectory: %s", err)
|
||||
}
|
||||
if config.DefaultMaxPlayerCount < 0 {
|
||||
return errors.New("DefaultMaxPlayerCount must be >= 0")
|
||||
if config.DefaultMaxPlayerCount < 0 && config.DefaultMaxPlayerCount != Constants.MaxPlayerCountUnlimited {
|
||||
return fmt.Errorf("DefaultMaxPlayerCount must be >= 0, or %d to indicate unlimited players", Constants.MaxPlayerCountUnlimited)
|
||||
}
|
||||
if config.RegistrationExistingPlayer.Allow {
|
||||
if config.RegistrationExistingPlayer.Nickname == "" {
|
||||
|
@ -51,6 +51,14 @@ func TestConfig(t *testing.T) {
|
||||
config.ListenAddress = ""
|
||||
assert.NotNil(t, CleanConfig(config))
|
||||
|
||||
config = configTestConfig(sd)
|
||||
config.DefaultMaxPlayerCount = Constants.MaxPlayerCountUseDefault
|
||||
assert.NotNil(t, CleanConfig(config))
|
||||
|
||||
config = configTestConfig(sd)
|
||||
config.DefaultMaxPlayerCount = Constants.MaxPlayerCountUnlimited
|
||||
assert.Nil(t, CleanConfig(config))
|
||||
|
||||
config = configTestConfig(sd)
|
||||
config.DataDirectory = "/tmp/DraslInvalidDataDirectoryNothingHere"
|
||||
assert.NotNil(t, CleanConfig(config))
|
||||
|
Loading…
x
Reference in New Issue
Block a user