Example #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();
        }
Example #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();
                }
            }
        }
Example #3
0
        private WelcomeMessageRemoteData ServerRemote_GetInfo()
        {
            if (ServerScheduledWipeDateUtc.HasValue &&
                ServerScheduledWipeDateUtc.Value <= DateTime.Now)
            {
                // the scheduled wipe date is in the past and no longer valid
                ServerScheduledWipeDateUtc = null;
                NextWipeDateServerTagHelper.ServerRefreshServerInfoTagForNextWipeDate();
            }

            return(new WelcomeMessageRemoteData(serverWelcomeMessageText, ServerScheduledWipeDateUtc));
        }
Example #4
0
        private bool ServerRemote_SetScheduledWipeDate(DateTime?dateTime)
        {
            if (dateTime.HasValue &&
                dateTime.Value <= DateTime.Now)
            {
                throw new Exception("The scheduled wipe date cannot in the past");
            }

            ServerScheduledWipeDateUtc = dateTime;
            Server.Database.Set(ServerDatabaseScheduledWipeDateUtcPrefixAndKey,
                                ServerDatabaseScheduledWipeDateUtcPrefixAndKey,
                                ServerScheduledWipeDateUtc);
            Logger.Important("Next scheduled wipe date changed: "
                             + (ServerScheduledWipeDateUtc.HasValue
                                    ? $"{ServerScheduledWipeDateUtc.Value.ToLongDateString()} at {ServerScheduledWipeDateUtc.Value.ToShortTimeString()}"
                                    : "none"),
                             ServerRemoteContext.Character);

            NextWipeDateServerTagHelper.ServerRefreshServerInfoTagForNextWipeDate();
            return(true);
        }