public override void ProcessServer()
        {
            bool sync = false;

            switch (Type)
            {
            case ProtectionConfigType.Invert:
                if (ProtectionHandler.Config.ProtectionInverted != Value)
                {
                    sync = true;
                    ProtectionHandler.Config.ProtectionInverted = Value;
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Server", $"The protection is {(Value ? "inverted" : "normal")} now.");
                }
                break;

            case ProtectionConfigType.Enable:
                if (ProtectionHandler.Config.ProtectionEnabled != Value)
                {
                    sync = true;
                    ProtectionHandler.Config.ProtectionEnabled = Value;
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Server", $"The protection is {(Value ? "enabled" : "disabled")} now");
                }
                break;

            case ProtectionConfigType.LandingGear:
                if (ProtectionHandler.Config.ProtectionAllowLandingGear != Value)
                {
                    sync = true;
                    ProtectionHandler.Config.ProtectionAllowLandingGear = Value;
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Server", $"Protection area LandingGear is now {(Value ? "allowed" : "disabled")}.");
                }
                break;
            }

            if (sync)
            {
                ProtectionHandler.Save();
                ConnectionHelper.SendMessageToAllPlayers(new MessageSyncProtection {
                    Config = ProtectionHandler.Config
                });
            }
            else
            {
                MessageClientTextMessage.SendMessage(SenderSteamId, "Server", "The setting was already set to the specified value.");
            }
        }
Beispiel #2
0
        public void Save(string customSaveName = null)
        {
            //write values into cfgFile
            Config.MotdHeadLine   = CommandMessageOfTheDay.HeadLine;
            Config.MotdShowInChat = CommandMessageOfTheDay.ShowInChat;

            //cfg
            Config.WorldLocation = MyAPIGateway.Session.CurrentPath;
            _serverConfigFile.Save(customSaveName);

            //motd
            _motdFile.Save();

            SaveLogs(customSaveName);

            if (customSaveName != null)
            {
                _permissionsFile.Save(customSaveName);
            }

            ProtectionHandler.Save(customSaveName);
            Logger.Debug("Config saved.");
        }
        public override void ProcessServer()
        {
            switch (Type)
            {
            case ProtectionAreaMessageType.Add:
                if (ProtectionHandler.AddArea(ProtectionArea))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Server", "Successfully created area.");
                    ConnectionHelper.SendMessageToAllPlayers(new MessageSyncProtection()
                    {
                        Config = ProtectionHandler.Config
                    });
                    ProtectionHandler.Save();
                }
                else
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Server", "An area with that name already exists.");
                }
                break;

            case ProtectionAreaMessageType.Remove:
                if (ProtectionHandler.RemoveArea(ProtectionArea))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Server", "Successfully removed area.");
                    ConnectionHelper.SendMessageToAllPlayers(new MessageSyncProtection()
                    {
                        Config = ProtectionHandler.Config
                    });
                    ProtectionHandler.Save();
                }
                else
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Server", "An area with that name could not be found.");
                }
                break;
            }
        }