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}");
        }
Ejemplo n.º 2
0
        public void Save()
        {
            if (IsSaving)
            {
                return;
            }

            IsSaving = true;
            NitroxConfig.Serialize(serverConfig); // This is overwriting the config file => server has to be closed before making changes to it
            worldPersistence.Save(world, serverConfig.SaveName);
            IsSaving = false;
        }
Ejemplo n.º 3
0
        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.");
        }
Ejemplo n.º 4
0
        public void Save()
        {
            if (IsSaving)
            {
                return;
            }

            // Don't overwrite config changes that users made to file
            if (!File.Exists(serverConfig.FileName))
            {
                NitroxConfig.Serialize(serverConfig);
            }
            IsSaving = true;
            worldPersistence.Save(world, serverConfig.SaveName);
            IsSaving = false;
        }
Ejemplo n.º 5
0
        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);
        }