コード例 #1
0
        void CreateSampleEvents(int count, IUser user)
        {
            EventPlugin eventPlugin   = PluginHelper.GetPluginWithCurrentSettings <EventPlugin>();
            Category    eventCategory = _categoryRepository.GetCategory(eventPlugin.CategoryName);

            DateTime startDate = DateTime.Today.AddMonths(-count / 2);

            for (int i = 1; i <= count; i++)
            {
                Post post = CreatePost(user);
                post.Title      = String.Format("Sample Event {0}", i);
                post.PostBody   = String.Format("<h3>Sample Event {0} Heading</h3><p>Sample Event {0} contents</p>", i);
                post.CategoryId = eventCategory.Id;

                // One event from 9 AM to 6 PM every two months.
                startDate = startDate.AddMonths(2).AddDays(1);
                post[eventPlugin.StartDateField] = startDate.AddHours(9).ToString();
                post[eventPlugin.EndDateField]   = startDate.AddHours(18).ToString();
                if (i % 2 == 0)
                {
                    post[eventPlugin.LocationField]           = "Sample location";
                    post[eventPlugin.SpeakerField]            = "Sample speaker";
                    post[eventPlugin.RegistrationNeededField] = "on";
                }

                _postRepository.Save(post);
            }
        }
コード例 #2
0
        public override void OnEnable()
        {
            File.WriteAllBytes(@"C:\Users\Krystian\Desktop\Recipes.json", Utf8Json.JsonSerializer.Serialize(Plugin.CreateDefaultList()));
            LoadConfig();
            if (PluginConfig.Cfg.Enabled)
            {
                EventPlugin.RegisterDamageType(Scp914DamageType);

                EventPlugin.Scp914KnobChangeEventPatchDisable  = true;
                EventPlugin.Scp914ActivationEventPatchDisabled = true;
                EventPlugin.Scp914UpgradeEventPatchDisable     = true;

                Events.PlayerDeathEvent        += OnPlayerDeath;
                Events.PlayerJoinEvent         += OnPlayerJoin;
                Events.PlayerLeaveEvent        += OnPlayerLeave;
                Events.RemoteAdminCommandEvent += CommandHandler;

                try
                {
                    Recipes         = Plugin.CreateDefaultList();
                    HarmonyInstance = HarmonyInstance.Create("kirun9.b914." + ++HarmonyCounter);
                    HarmonyInstance.PatchAll();
                }
                catch (System.Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
        }
コード例 #3
0
        protected override void Establish_context()
        {
            _sut = new EventPlugin(MockRepository.GenerateMock <IPostRepository>(),
                                   MockRepository.GenerateMock <IMapper <NameValueCollection, Settings> >(),
                                   MockRepository.GenerateMock <IValidator <Settings> >());

            _post = MockRepository.GenerateStub <DataBuddyBase>();
        }
コード例 #4
0
        protected override void Establish_context()
        {
            base.Establish_context();

            _sut = Container.Create <EventPlugin>();

            _post = MockRepository.GenerateStub <DataBuddyBase>();

            Mocks.ReplayAll();
        }
コード例 #5
0
        protected override void Establish_context()
        {
            base.Establish_context();

            _sut = Container.Create <EventPlugin>();
            _sut.CategoryName = "Event category";

            _post = new Post();

            IoC.Resolve <IPostRepository>().Stub(x => x.GetCategoryNameOf(_post)).Return(_sut.CategoryName);
            IoC.Resolve <IEventValidator>().Expect(x => x.Validate(_post)).Return(new ValidationReport());

            Mocks.ReplayAll();
        }
コード例 #6
0
        protected override void Establish_context()
        {
            var postRepository = MockRepository.GenerateMock <IPostRepository>();

            _sut = new EventPlugin(postRepository,
                                   MockRepository.GenerateMock <IMapper <NameValueCollection, Settings> >(),
                                   MockRepository.GenerateMock <IValidator <Settings> >())
            {
                CategoryName = "Event category"
            };

            _post = new Post();

            postRepository.Stub(x => x.GetCategoryNameOf(_post)).Return("Some other category");
        }
コード例 #7
0
ファイル: RoundEndPatch.cs プロジェクト: Killers0992/EXILED
 public static void Prefix(string text, Color c, bool nospace)
 {
     if (!text.StartsWith("Round finished! Anomalies: ") || EventPlugin.GetRoundDuration() < 2)
     {
         return;
     }
     try
     {
         Events.InvokeRoundEnd();
     }
     catch (Exception e)
     {
         Log.Error($"Round end event error: {e}");
     }
 }
コード例 #8
0
ファイル: PlayerLeaveEvent.cs プロジェクト: js6pak/EXILED
        public static void Prefix(ReferenceHub __instance)
        {
            if (EventPlugin.PlayerLeaveEventPatchDisable)
            {
                return;
            }

            EventPlugin.ToMultiAdmin("Player disconnect: ");

            try
            {
                Events.InvokePlayerLeave(__instance);
            }
            catch (Exception exception)
            {
                Log.Error($"PlayerLeaveEvent error: {exception}");
            }
        }
コード例 #9
0
        protected override void Establish_context()
        {
            base.Establish_context();

            _sut = Container.Create <EventPlugin>();
            _sut.CategoryName = "Event category";

            _post = new Post();

            Container.Get <IPostRepository>().Stub(x => x.GetCategoryNameOf(_post)).Return(_sut.CategoryName);
            Container.Get <IEventValidator>().Stub(x => x.Validate(_post)).Return(new ValidationReport
            {
                new ValidationError("something", "some field"),
                new ValidationError("some other thing")
            });

            Mocks.ReplayAll();
        }
コード例 #10
0
        public static void Prefix(PlayerStats __instance)
        {
            if (EventPlugin.RoundRestartEventPatchDisable)
            {
                return;
            }

            EventPlugin.ToMultiAdmin("Round restarting");

            try
            {
                Events.InvokeRoundRestart();
                Events.InvokeRoundEnd();
            }
            catch (Exception exception)
            {
                Log.Error($"RoundRestartEvent/RoundEndEvent error: {exception}");
            }
        }
コード例 #11
0
        protected override void Establish_context()
        {
            var postRepository = MockRepository.GenerateMock <IPostRepository>();

            _sut = new EventPlugin(postRepository,
                                   MockRepository.GenerateMock <IMapper <NameValueCollection, Settings> >(),
                                   MockRepository.GenerateMock <IValidator <Settings> >())
            {
                CategoryName                        = "Event category",
                LocationField                       = LocationField,
                LocationUnknownField                = LocationUnknownField,
                RegistrationRecipientField          = RegistrationRecipientField,
                MaximumNumberOfRegistrationsField   = MaximumNumberOfRegistrationsField,
                DefaultLocation                     = DefaultLocation,
                DefaultRegistrationRecipient        = DefaultRegistrationRecipient,
                DefaultMaximumNumberOfRegistrations = DefaultMaximumNumberOfRegistrations
            };

            _post = new Post();

            postRepository.Stub(x => x.GetCategoryNameOf(_post)).Return(_sut.CategoryName);
        }
コード例 #12
0
ファイル: Plugin.cs プロジェクト: kirun9/Better914
        public override void OnEnable()
        {
            LoadConfig();
            if (PluginConfig.Cfg.Enabled)
            {
                EventPlugin.RegisterDamageType(Scp914DamageType);

                EventPlugin.Scp914KnobChangeEventPatchDisable  = true;
                EventPlugin.Scp914ActivationEventPatchDisabled = true;
                EventPlugin.Scp914UpgradeEventPatchDisable     = true;

                Events.PlayerDeathEvent        += OnPlayerDeath;
                Events.PlayerJoinEvent         += OnPlayerJoin;
                Events.PlayerLeaveEvent        += OnPlayerLeave;
                Events.RemoteAdminCommandEvent += CommandHandler;

                try
                {
                    var recipesPath = Path.Combine(PluginManager.ExiledDirectory, $"Better914Recipes-{ServerStatic.ServerPort}.json");
                    if (File.Exists(recipesPath))
                    {
                        Recipes = Utf8Json.JsonSerializer.Deserialize <List <Scp914Recipe> >(File.ReadAllBytes(Path.Combine()));
                    }
                    else
                    {
                        Recipes = Plugin.CreateDefaultList();
                    }
                    HarmonyInstance = HarmonyInstance.Create("kirun9.b914." + ++HarmonyCounter);
                    HarmonyInstance.PatchAll();
                }
                catch (System.Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
        }
コード例 #13
0
        public static void Postfix(NicknameSync __instance)
        {
            if (EventPlugin.PlayerJoinEventPatchDisable)
            {
                return;
            }

            EventPlugin.ToMultiAdmin($"Player connect: ");

            if (PlayerManager.players.Count >= CustomNetworkManager.slots)
            {
                EventPlugin.ToMultiAdmin($"Server full");
            }

            try
            {
                ReferenceHub player = __instance.gameObject.GetPlayer();

                Timing.CallDelayed(0.25f, () =>
                {
                    if (player != null && player.IsMuted())
                    {
                        player.characterClassManager.SetDirtyBit(1UL);
                    }
                });

                if (!string.IsNullOrEmpty(player.characterClassManager.UserId))
                {
                    Events.InvokePlayerJoin(player);
                }
            }
            catch (Exception exception)
            {
                Log.Error($"PlayerJoinEvent error: {exception}");
            }
        }
コード例 #14
0
        public string EventCategoryName()
        {
            EventPlugin eventPlugin = PluginHelper.GetPluginWithCurrentSettings <EventPlugin>();

            return(eventPlugin.CategoryName);
        }
コード例 #15
0
 public EventHandlers(EventPlugin plugin) => this.plugin = plugin;