Пример #1
0
        protected override void PrepareSystem()
        {
            if (IsClient)
            {
                BootstrapperClientGame.InitCallback += _ => RefreshWelcomeMessage();
                return;
            }

            serverWelcomeMessageText = SharedTextHelper.TrimAndFilterProfanity(Api.Server.Core.WelcomeMessageText);
            serverDescriptionText    = SharedTextHelper.TrimAndFilterProfanity(Api.Server.Core.DescriptionMessageText);
            Server.Database.TryGet(ServerDatabaseScheduledWipeDateUtcPrefixAndKey,
                                   ServerDatabaseScheduledWipeDateUtcPrefixAndKey,
                                   out DateTime? wipeDateUtc);

            if (wipeDateUtc.HasValue &&
                wipeDateUtc.Value < DateTime.Now)
            {
                // the scheduled wipe date is in the past and no longer valid
                wipeDateUtc = null;
            }

            ServerScheduledWipeDateUtc = wipeDateUtc;

            NextWipeDateServerTagHelper.ServerRefreshServerInfoTagForNextWipeDate();
        }
Пример #2
0
        protected override void PrepareSystem()
        {
            if (IsServer)
            {
                serverWelcomeMessageText = SharedTextHelper.TrimAndFilterProfanity(Api.Server.Core.WelcomeMessageText);
                serverDescriptionText    = SharedTextHelper.TrimAndFilterProfanity(Api.Server.Core.DescriptionMessageText);
                Server.Database.TryGet(ServerDatabaseScheduledWipeDateUtcPrefixAndKey,
                                       ServerDatabaseScheduledWipeDateUtcPrefixAndKey,
                                       out DateTime? wipeDateUtc);

                if (wipeDateUtc.HasValue &&
                    wipeDateUtc.Value < DateTime.Now)
                {
                    // the scheduled wipe date is in the past and no longer valid
                    wipeDateUtc = null;
                }

                ServerScheduledWipeDateUtc = wipeDateUtc;

                NextWipeDateServerTagHelper.ServerRefreshServerInfoTagForNextWipeDate();
                return;
            }

            Client.Characters.CurrentPlayerCharacterChanged += Refresh;

            void Refresh()
            {
                if (Api.Client.Characters.CurrentPlayerCharacter is not null)
                {
                    RefreshWelcomeMessage();
                }
            }
        }
Пример #3
0
        private bool ServerRemote_SetDescription(string text)
        {
            text = text?.Trim() ?? string.Empty;
            text = SharedTextHelper.TrimSpacesOnEachLine(text);

            if (text.Length > MaxDescriptionLength)
            {
                throw new Exception("Max description length exceeded");
            }

            text = ProfanityFilteringSystem.SharedApplyFilters(text);
            Api.Server.Core.DescriptionMessageText = serverDescriptionText = text;

            Logger.Important("Server description message changed to:"
                             + Environment.NewLine
                             + text.Replace("[br]", Environment.NewLine + "[br]"));
            return(true);
        }
Пример #4
0
        private void ServerRemote_OfficerSetDescription(string text, bool isPrivateDescription)
        {
            text = text?.Trim() ?? string.Empty;
            text = SharedTextHelper.TrimSpacesOnEachLine(text);

            var officer = ServerRemoteContext.Character;

            ServerValidateHasAccessRights(officer,
                                          FactionMemberAccessRights.EditDescription,
                                          out var faction);

            text = ProfanityFilteringSystem.SharedApplyFilters(text);
            SharedValidateDescriptionLength(text, isPrivateDescription);

            var privateState = Faction.GetPrivateState(faction);

            if (isPrivateDescription)
            {
                if (privateState.DescriptionPrivate == text)
                {
                    return;
                }

                privateState.DescriptionPrivate = text;
            }
            else
            {
                if (privateState.DescriptionPublic == text)
                {
                    return;
                }

                privateState.DescriptionPublic = text;
            }

            ServerAddLogEntry(faction, new FactionLogEntryDescriptionChanged(officer));
        }