@@ -7,9 +7,10 @@ namespace NitroxModel.Server
77{
88 public class ServerConfig
99 {
10+ private readonly ServerConfigItem < ServerGameMode > gameModeSetting ;
1011 private readonly ServerConfigItem < bool > disableConsoleSetting , disableAutoSaveSetting ;
1112 private readonly ServerConfigItem < int > portSetting , saveIntervalSetting , maxConnectionsSetting ;
12- private readonly ServerConfigItem < string > saveNameSetting , serverPasswordSetting , adminPasswordSetting , gameModeSetting , serverSerializerMode ;
13+ private readonly ServerConfigItem < string > saveNameSetting , serverPasswordSetting , adminPasswordSetting , serverSerializerMode ;
1314 private readonly ServerConfigItem < float > oxygenSetting , maxOxygenSetting , healthSetting , foodSetting , waterSetting , infectionSetting ;
1415
1516 public ServerConfig ( ) : this (
@@ -21,12 +22,12 @@ public ServerConfig() : this(
2122 savename : "world" ,
2223 serverpassword : string . Empty ,
2324 adminpassword : StringHelper . GenerateRandomString ( 12 ) ,
24- gamemodeSetting : ServerGameMode . SURVIVAL ,
25+ gamemode : ServerGameMode . SURVIVAL ,
2526 serverserializermode : ServerSerializerMode . PROTOBUF
2627 )
2728 { }
2829
29- public ServerConfig ( int port , int saveinterval , int maxconnection , bool disableconsole , bool disableautosave , string savename , string serverpassword , string adminpassword , ServerGameMode gamemodeSetting , ServerSerializerMode serverserializermode )
30+ public ServerConfig ( int port , int saveinterval , int maxconnection , bool disableconsole , bool disableautosave , string savename , string serverpassword , string adminpassword , ServerGameMode gamemode , ServerSerializerMode serverserializermode )
3031 {
3132 portSetting = new ServerConfigItem < int > ( "Port" , port ) ;
3233 saveIntervalSetting = new ServerConfigItem < int > ( "SaveInterval" , saveinterval ) ;
@@ -36,7 +37,7 @@ public ServerConfig(int port, int saveinterval, int maxconnection, bool disablec
3637 saveNameSetting = new ServerConfigItem < string > ( "SaveName" , savename ) ;
3738 serverPasswordSetting = new ServerConfigItem < string > ( "ServerPassword" , serverpassword ) ;
3839 adminPasswordSetting = new ServerConfigItem < string > ( "AdminPassword" , adminpassword ) ;
39- gameModeSetting = new ServerConfigItem < string > ( "GameMode" , gamemodeSetting . GetAttribute < DescriptionAttribute > ( ) . Description ) ;
40+ gameModeSetting = new ServerConfigItem < ServerGameMode > ( "GameMode" , gamemode ) ;
4041 serverSerializerMode = new ServerConfigItem < string > ( "ServerSerializerMode" , serverserializermode . ToString ( ) ) ;
4142
4243 //We don't want to custom those values for now
@@ -159,7 +160,7 @@ public string AdminPassword
159160 }
160161 }
161162
162- public string GameMode
163+ public ServerGameMode GameModeEnum
163164 {
164165 get
165166 {
@@ -168,20 +169,10 @@ public string GameMode
168169
169170 set
170171 {
171- Validate . IsFalse ( string . IsNullOrWhiteSpace ( value ) , "Gamemode can't be an empty string" ) ;
172- Validate . IsTrue ( Enum . IsDefined ( typeof ( ServerGameMode ) , value . ToUpper ( ) ) , "Gamemode doesn't exists" ) ;
173172 gameModeSetting . Value = value ;
174173 }
175174 }
176175
177- public ServerGameMode GameModeEnum
178- {
179- set
180- {
181- GameMode = value . GetAttribute < DescriptionAttribute > ( ) . Description . ToString ( ) ;
182- }
183- }
184-
185176 public ServerSerializerMode SerializerModeEnum
186177 {
187178 get
@@ -200,9 +191,6 @@ public ServerSerializerMode SerializerModeEnum
200191 public PlayerStatsData DefaultPlayerStats => new PlayerStatsData ( oxygenSetting . Value , maxOxygenSetting . Value , healthSetting . Value , foodSetting . Value , waterSetting . Value , infectionSetting . Value ) ;
201192 #endregion
202193
203- public bool IsGameMode ( string gamemode )
204- {
205- return GameMode == gamemode ;
206- }
194+ public bool IsHardcore => GameModeEnum == ServerGameMode . HARDCORE ;
207195 }
208196}
0 commit comments