protected override void Execute(CallArgs args) { ServerConfig serverConfig = NitroxConfig.Deserialize <ServerConfig>(); serverConfig.SerializerMode = serverConfig.SerializerMode == ServerSerializerMode.PROTOBUF ? ServerSerializerMode.JSON : ServerSerializerMode.PROTOBUF; NitroxConfig.Serialize(serverConfig); worldPersistence.UpdateSerializer(serverConfig.SerializerMode == ServerSerializerMode.PROTOBUF ? (IServerSerializer)protoBufSerializer : jsonSerializer); SendMessage(args.Sender, $"Swapped to {serverConfig.SerializerMode}"); }
protected override void Execute(CallArgs args) { string password = args.Get(0) ?? string.Empty; ServerConfig serverConfig = NitroxConfig.Deserialize <ServerConfig>(); serverConfig.ServerPassword = password; NitroxConfig.Serialize(serverConfig); Log.InfoSensitive("Server password changed to {password} by {playername}", password, args.SenderName); SendMessageToPlayer(args.Sender, "Server password changed. In order to take effect pls restart the server."); }
private static void RegisterCoreDependencies(ContainerBuilder containerBuilder) { containerBuilder.Register(c => NitroxConfig.Deserialize <ServerConfig>()).SingleInstance(); containerBuilder.RegisterType <Server>().SingleInstance(); containerBuilder.RegisterType <PlayerManager>().SingleInstance(); containerBuilder.RegisterType <DefaultServerPacketProcessor>().InstancePerLifetimeScope(); containerBuilder.RegisterType <PacketHandler>().InstancePerLifetimeScope(); containerBuilder.RegisterType <EscapePodManager>().InstancePerLifetimeScope(); containerBuilder.RegisterType <EntitySimulation>().SingleInstance(); containerBuilder.RegisterType <ConsoleCommandProcessor>().SingleInstance(); containerBuilder.RegisterType <LiteNetLibServer>() .As <Communication.NetworkingLayer.NitroxServer>() .SingleInstance(); }
protected override void Execute(CallArgs args) { bool toggle = args.Get <bool>(0); ServerConfig serverConfig = NitroxConfig.Deserialize <ServerConfig>(); if (toggle) { serverConfig.DisableAutoSave = false; Server.Instance.EnablePeriodicSaving(); SendMessage(args.Sender, "Enabled periodical saving"); } else { serverConfig.DisableAutoSave = true; Server.Instance.DisablePeriodicSaving(); SendMessage(args.Sender, "Disabled periodical saving"); } NitroxConfig.Serialize(serverConfig); }
protected override void Execute(CallArgs args) { if (!configOpenLock.Wait(0)) { Log.Warn("Waiting on previous config command to close the configuration file."); return; } ServerConfig currentActiveConfig = NitroxServiceLocator.LocateService <ServerConfig>(); string configFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? "", currentActiveConfig.FileName); if (!File.Exists(configFile)) { Log.Error($"Could not find config file at: {configFile}"); return; } Task.Run(async() => { try { await StartWithDefaultProgram(configFile); } finally { configOpenLock.Release(); } NitroxConfig.Deserialize <ServerConfig>(); // Notifies user if deserialization failed. Log.Info("If you made changes, restart the server for them to take effect."); }) .ContinueWith(t => { #if DEBUG if (t.Exception != null) { throw t.Exception; } #endif }); }