public void SetAndShow(string message, Hooks.CanvasHook yes, Hooks.CanvasHook no) { this.message = message; this.Yes = yes; this.No = no; this.Show(); }
void NetHooks_GetData(Hooks.GetDataEventArgs e) { if (e.MsgID == PacketTypes.Tile) { } }
public void ActivateEvent( Hooks hook, params object[] paramlist ) { switch ( hook ) { case Hooks.BeforeExecuteCommand: if ( BeforeExecuteCommand != null ) { BeforeExecuteCommand( this, new CKFinderEventArgs( paramlist ) ); } break; case Hooks.InitCommand: if ( InitCommand != null ) { InitCommand( this, new CKFinderEventArgs( paramlist ) ); } break; case Hooks.AfterFileUpload: if ( AfterFileUpload != null ) { AfterFileUpload( this, new CKFinderEventArgs( paramlist ) ); } break; } }
private bool ProcessMessage(MessageEvent messageEvent, String text, Hooks hook, int whoAmI) { messageEvent.Message = text; messageEvent.Sender = Main.players[whoAmI]; Program.server.getPluginManager().processHook(hook, messageEvent); return !messageEvent.Cancelled; }
public void registerHook(Hooks hook) { if (!moduleHooks.Contains(hook)) { moduleHooks.Add(hook); Console.WriteLine(hook + " added"); } }
public Hooker <T> CreateHooker() { Hooker <T> hooker = new Hooker <T>(AvailablePort); hooker.OnProcessExited += Hooker_OnProcessExited; hooker.OnProcessStarted += Hooker_OnProcessStarted; Hooks.Add(hooker.ProxyPort, hooker); return(hooker); }
internal static void Init() { Hooks.InitHooks(); // Cards ------------------------- ExtendedSave.CardBeingSaved += OnCardBeingSaved; MakerAPI.ChaFileLoaded += (sender, args) => { var chaControl = MakerAPI.GetCharacterControl(); if (chaControl != null) { ReloadChara(chaControl); } }; // Coordinates ------------------- ExtendedSave.CoordinateBeingSaved += file => { if (file == null) { return; } // Safe to assume we're in maker var character = MakerAPI.GetCharacterControl(); if (character == null) { KoikatuAPI.Log(LogLevel.Error, "[KKAPI] OnCoordinateBeingSaved fired outside chara maker for " + file.coordinateName); KoikatuAPI.Log(LogLevel.Info, new StackTrace()); return; } OnCoordinateBeingSaved(character, file); }; ExtendedSave.CoordinateBeingLoaded += file => { if (Hooks.ClothesFileControlLoading || file == null) { return; } // Coord cards are loaded by loading into the character's nowCoordinate var cf = ChaControls.FirstOrDefault(x => x.nowCoordinate == file); if (cf != null) { OnCoordinateBeingLoaded(cf, file); } }; if (KoikatuAPI.EnableDebugLogging) { RegisterExtraBehaviour <TestCharaCustomFunctionController>(null); } }
static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { Hooks.UnInstallHooks(); foreach (var kp in Hooks.UnInstallResults) { Console.WriteLine("Procedure is : " + kp.Key + " result is : " + kp.Value); } Console.WriteLine("Shutting down..."); // Cleanup here System.Threading.Thread.Sleep(750); }
public SimpleTriggerArgumentBinding( ITriggerBindingStrategy <TMessage, TTriggerValue> hooks, IConverterManager converterManager, bool isSingleDispatch = true) { this._hooks = hooks; this.Contract = Hooks.GetBindingContract(isSingleDispatch); this.ElementType = typeof(TMessage); _converterManager = converterManager; _stringConverter = _converterManager.GetConverter <TMessage, string, Attribute>(); }
public async Task Should_throw_exception_when_participant_does_not_exist() { var seededHearing = await Hooks.SeedVideoHearing(); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var newPerson = new PersonBuilder(true).Build(); var participant = new Individual(newPerson, new HearingRole(1, "Dummy"), new CaseRole(1, "Dummy")); Assert.ThrowsAsync <DomainRuleException>(() => _commandHandler.Handle( new RemoveParticipantFromHearingCommand(seededHearing.Id, participant))); }
protected override void Dispose(bool disposeManagedResources) { // Only clean up managed objects if disposing (i.e. not called from destructor) if (disposeManagedResources) { try { Cleanup(); } catch { } try { // Uninstall Hooks if (Hooks.Count > 0) { // First disable the hook (by excluding all threads) and wait long enough to ensure that all hooks are not active foreach (var hook in Hooks) { // Lets ensure that no threads will be intercepted again hook.Deactivate(); } Thread.Sleep(100); // Now we can dispose of the hooks (which triggers the removal of the hook) foreach (var hook in Hooks) { hook.Dispose(); } Hooks.Clear(); } try { // Remove the event handlers Interface.ScreenshotRequested -= InterfaceEventProxy.ScreenshotRequestedProxyHandler; Interface.DisplayText -= InterfaceEventProxy.DisplayTextProxyHandler; } catch (RemotingException) { } // Ignore remoting exceptions (host process may have been closed) } catch { } } base.Dispose(disposeManagedResources); }
/// <summary> /// Caches forward and reverse translation of assets as they're loaded, but does not apply them. /// to avoid breaking code that relies on original names being present. /// </summary> protected override bool ReplaceOrUpdateAsset(string calculatedModificationPath, ref MapInfo asset, IAssetOrResourceLoadedContext context) { // updating the MapInfo assets directly breaks places that are doing lookups by mapName // instead of id, so we just register this as a place to lookup MapInfo translations and // return true so it appears handled Hooks.Init(); // register new translations with helper without replacing var defaultTranslationFile = Path.Combine(calculatedModificationPath, "translation.txt"); var redirectedResources = RedirectedDirectory.GetFilesInDirectory(calculatedModificationPath, ".txt"); var streams = redirectedResources.Select(x => x.OpenStream()); var cache = new SimpleTextTranslationCache( defaultTranslationFile, streams, false, true); if (cache.IsEmpty) { return(true); } var shouldTrack = IsTranslationRegistrationAllowed(calculatedModificationPath); // register with helper or dump without translating here foreach (var key in asset.param .Select(entry => TextResourceHelper.GetSpecializedKey(entry, GetMapName(entry))) .Where(k => !string.IsNullOrEmpty(k))) { if (cache.TryGetTranslation(key, true, out var translated)) { if (string.IsNullOrEmpty(translated)) { continue; } _mapLookup[key] = translated; _reverseMapLookup[translated] = key; if (shouldTrack) { TrackReplacement(calculatedModificationPath, key, translated); } TranslationHelper.RegisterRedirectedResourceTextToPath(translated, calculatedModificationPath); } else if (AutoTranslatorSettings.IsDumpingRedirectedResourcesEnabled && !string.IsNullOrEmpty(key) && LanguageHelper.IsTranslatable(key)) { cache.AddTranslationToCache(key, key); } } return(true); }
public void UnregisterHook(IHook hook) { try { Hooks.Remove(hook); hook.OnUnhooked(); } catch (Exception ex) { Log.Error("ScriptManager.UnregisterHook: " + ex); } }
public override void Hook() { this.DebugMessage("Hook: Begin"); // Determine method addresses in Direct3D10.Device, and DXGI.SwapChain if (_d3d10VTblAddresses == null) { _d3d10VTblAddresses = new List <IntPtr>(); _dxgiSwapChainVTblAddresses = new List <IntPtr>(); this.DebugMessage("Hook: Before device creation"); using (var factory = new Factory(IntPtr.Zero)) //??????????????????????????? { using (var device = new Device(factory.GetAdapter(0), DeviceCreationFlags.None)) { this.DebugMessage("Hook: Device created"); _d3d10VTblAddresses.AddRange(GetVTblAddresses(device.NativePointer, D3D10_DEVICE_METHOD_COUNT)); using (var renderForm = new System.Windows.Forms.Form()) { using (SharpDX.DXGI.SwapChain sc = new SharpDX.DXGI.SwapChain(factory, device, DXGI.CreateSwapChainDescription(renderForm.Handle))) { _dxgiSwapChainVTblAddresses.AddRange(GetVTblAddresses(sc.NativePointer, DXGI.DXGI_SWAPCHAIN_METHOD_COUNT)); } } } } } // We will capture the backbuffer here DXGISwapChain_PresentHook = LocalHook.Create( _dxgiSwapChainVTblAddresses[(int)DXGI.DXGISwapChainVTbl.Present], new DXGISwapChain_PresentDelegate(PresentHook), this); // We will capture target/window resizes here DXGISwapChain_ResizeTargetHook = LocalHook.Create( _dxgiSwapChainVTblAddresses[(int)DXGI.DXGISwapChainVTbl.ResizeTarget], new DXGISwapChain_ResizeTargetDelegate(ResizeTargetHook), this); /* * Don't forget that all hooks will start deactivated... * The following ensures that all threads are intercepted: * Note: you must do this for each hook. */ DXGISwapChain_PresentHook.ThreadACL.SetExclusiveACL(new Int32[1]); DXGISwapChain_ResizeTargetHook.ThreadACL.SetExclusiveACL(new Int32[1]); Hooks.Add(DXGISwapChain_PresentHook); Hooks.Add(DXGISwapChain_ResizeTargetHook); }
public override void Hook() { this.DebugMessage("Hook: Begin"); // Determine method addresses in Direct3D10.Device, and DXGI.SwapChain if (_d3d10_1VTblAddresses == null) { _d3d10_1VTblAddresses = new List <IntPtr>(); _dxgiSwapChainVTblAddresses = new List <IntPtr>(); this.DebugMessage("Hook: Before device creation"); using (Factory1 factory = new Factory1()) { using (var device = new global::SharpDX.Direct3D10.Device1(factory.GetAdapter(0), global::SharpDX.Direct3D10.DeviceCreationFlags.None, global::SharpDX.Direct3D10.FeatureLevel.Level_10_1)) { this.DebugMessage("Hook: Device created"); _d3d10_1VTblAddresses.AddRange(GetVTblAddresses(device.NativePointer, D3D10_1_DEVICE_METHOD_COUNT)); using (var renderForm = new global::SharpDX.Windows.RenderForm()) { using (var sc = new SwapChain(factory, device, DXGI.CreateSwapChainDescription(renderForm.Handle))) { _dxgiSwapChainVTblAddresses.AddRange(GetVTblAddresses(sc.NativePointer, DXGI.DXGI_SWAPCHAIN_METHOD_COUNT)); } } } } } // We will capture the backbuffer here DXGISwapChain_PresentHook = new Hook <DXGISwapChain_PresentDelegate>( _dxgiSwapChainVTblAddresses[(int)DXGI.DXGISwapChainVTbl.Present], new DXGISwapChain_PresentDelegate(PresentHook), this); // We will capture target/window resizes here DXGISwapChain_ResizeTargetHook = new Hook <DXGISwapChain_ResizeTargetDelegate>( _dxgiSwapChainVTblAddresses[(int)DXGI.DXGISwapChainVTbl.ResizeTarget], new DXGISwapChain_ResizeTargetDelegate(ResizeTargetHook), this); /* * Don't forget that all hooks will start deactivated... * The following ensures that all threads are intercepted: * Note: you must do this for each hook. */ DXGISwapChain_PresentHook.Activate(); DXGISwapChain_ResizeTargetHook.Activate(); Hooks.Add(DXGISwapChain_PresentHook); Hooks.Add(DXGISwapChain_ResizeTargetHook); }
public async Task should_update_person() { var externalRefId = Guid.NewGuid(); await Hooks.AddJudiciaryPerson(externalRefId); var updateCommand = new UpdateJudiciaryLeaverByExternalRefIdCommand(externalRefId, true); await _commandHandler.Handle(updateCommand); var updatePerson = await _getJudiciaryPersonByExternalRefIdQueryHandler.Handle(new GetJudiciaryPersonByExternalRefIdQuery(externalRefId)); updatePerson.ExternalRefId.Should().Be(updateCommand.ExternalRefId); updatePerson.HasLeft.Should().BeTrue(); }
/// <summary> /// invoke hooks having the given name /// </summary> /// <param name="name">hook name</param> public void InvokeHooks( CommandEvaluationContext context, Hooks name, Action <object> callBack = null ) { if (context.ShellEnv.IsOptionSetted(ShellEnvironmentVar.debug_enableHookTrace)) { context.Out.Echo(context.ShellEnv.Colors.Log + "[invoke hook: " + name + "] "); } InvokeHooks(context, name + "", callBack); }
internal static void Init() { Hooks.SetupHooks(); ExtensibleSaveFormat.ExtendedSave.SceneBeingSaved += path => OnSceneBeingSaved(); _functionControllerContainer = new GameObject("SceneCustomFunctionController Zoo"); _functionControllerContainer.transform.SetParent(BepInEx.Bootstrap.Chainloader.ManagerObject.transform, false); if (KoikatuAPI.EnableDebugLogging) { RegisterExtraBehaviour <TestSceneFunctionController>(null); } }
public bool RemoveHook(string hook, ulong id) { if (!Hooks.ContainsKey(hook)) { return(false); } if (!Hooks[hook].Contains(id)) { return(false); } Hooks[hook].Remove(id); return(true); }
void NPCKilled_Test() { try { DamageEvent damageEvent = new DamageEvent(); Log("NPCKilled_Test: Test 1"); Hooks.NPCKilled(ref damageEvent); } catch (Exception ex) { Logger.LogException(ex); } }
internal void RunArgumentHook(ArgHook.HookContext context, Func <ArgHook, int> orderby, Action <ArgHook> hookAction) { context.Property = Source as PropertyInfo; context.CurrentArgument = this; foreach (var hook in Hooks.OrderBy(orderby)) { hookAction(hook); } context.Property = null; context.CurrentArgument = null; }
void PlayerKilled_Test() { try { DamageEvent damageEvent = new DamageEvent(); Log("PlayerKilled_Test: Test 1"); Hooks.PlayerHurt(ref damageEvent); } catch (Exception ex) { Logger.LogException(ex); } }
public async Task Should_return_person_that_exists() { var seededHearing = await Hooks.SeedVideoHearing(); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var existingPerson = seededHearing.GetParticipants().First().Person; var query = new GetPersonByUsernameQuery(existingPerson.Username); var person = await _handler.Handle(query); person.Should().NotBeNull(); person.Should().BeEquivalentTo(existingPerson); }
public async Task Should_be_able_to_update_representative_participant() { var editPrefix = " _Edit"; var seededHearing = await Hooks.SeedVideoHearing(); var beforeUpdatedDate = seededHearing.UpdatedDate; TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); _newHearingId = seededHearing.Id; var representativeParticipant = seededHearing.GetParticipants().FirstOrDefault(x => x.HearingRole.UserRole.Name.Equals("Representative")); var title = representativeParticipant.Person.Title + editPrefix; var displayName = representativeParticipant.DisplayName + editPrefix; var telephoneNumber = "11112222333"; var houseNumber = "HouseNumber" + editPrefix; var street = "Street" + editPrefix; var postcode = "ED1 5NR"; var city = "City" + editPrefix; var county = "County" + editPrefix; var organisationName = "Organisation" + editPrefix; NewAddress address = new NewAddress() { HouseNumber = houseNumber, Street = street, City = city, County = county, Postcode = postcode }; const string reference = "Marvel Comics Division"; var representee = "Iron Man Inc."; RepresentativeInformation repInfo = new RepresentativeInformation() { Reference = reference, Representee = representee }; var updateParticipantCommand = new UpdateParticipantCommand(representativeParticipant.Id, title, displayName, telephoneNumber, address, organisationName, seededHearing, repInfo); await _commandHandler.Handle(updateParticipantCommand); var updatedRepresentative = (Representative)updateParticipantCommand.UpdatedParticipant; updatedRepresentative.Should().NotBeNull(); updatedRepresentative.UpdatedDate.Should().BeAfter(beforeUpdatedDate); updatedRepresentative.Person.Title.Should().Be(title); updatedRepresentative.DisplayName.Should().Be(displayName); updatedRepresentative.Person.TelephoneNumber.Should().Be(telephoneNumber); updatedRepresentative.Person.Address.Should().BeNull(); updatedRepresentative.Person.Organisation.Should().NotBeNull(); updatedRepresentative.Person.Organisation.Name.Should().Be(organisationName); updatedRepresentative.Reference.Should().Be(repInfo.Reference); updatedRepresentative.Representee.Should().Be(repInfo.Representee); }
//public void ProcessChains() //{ // for (int i = 0; i < chains.Count; i++) // { // for (int j = 0; j < chains[i].segments.Count; j++) // { // if (chains[i].segments[j].IsValid()) // { // if (chains[i].segments[j].rope.Length > chains[i].segmentLength) // { // chains[i].segments[j].rope.Length = chains[i].segmentLength; // //chains[i].segments[j].rope.ResetLength(true); // } // } // } // } //} private void UpdateDebugStuff() { DebugInfo += "Active Hooks: " + Hooks.Count; String format = "0.00"; if (Game.Player.Exists() && !Game.Player.IsDead && Game.Player.CanControlCharacter) { if (Game.Player.IsAiming) { RaycastResult rayResult = Util.CameraRaycastForward(); Entity targetEntity = rayResult.HitEntity; if (rayResult.DitHitEntity && Util.IsValid(targetEntity)) { Vector3 pos = targetEntity.Position; Vector3 rot = targetEntity.Rotation; Vector3 vel = targetEntity.Velocity; float dist = targetEntity.Position.DistanceTo(Game.Player.Character.Position); float speed = vel.Length(); DebugInfo += "\n | Entity Detected: " + targetEntity.GetType() + " | " + (Util.IsStatic(targetEntity) ? "Static" : "Dynamic") + "\n Position(X:" + pos.X.ToString(format) + ", Y:" + pos.Y.ToString(format) + ", Z:" + pos.Z.ToString(format) + ")" + " Rotation(" + rot.X.ToString(format) + ", Y:" + rot.Y.ToString(format) + ", Z:" + rot.Z.ToString(format) + ")" + //"\n Velocity(" + vel.X.ToString(format) + ", Y:" + vel.Y.ToString(format) + ", Z:" + vel.Z.ToString(format) + ")" + "\n Speed(" + speed.ToString(format) + ") Distance(" + dist.ToString(format) + ")"; } } if (Hooks.Count > 0 && Hooks.Last() != null && Hooks.Last().Exists()) { if (Hooks.Last().entity1 != null) { DebugInfo += "\n | E1.Distance(" + Game.Player.Character.Position.DistanceTo(Hooks.Last().entity1.Position).ToString("0.00") + ")"; } if (Hooks.Last().entity2 != null) { DebugInfo += " |E2.Distance(" + Game.Player.Character.Position.DistanceTo(Hooks.Last().entity2.Position).ToString("0.00") + ")"; } } Vector3 ppos = Game.Player.Character.Position; DebugInfo += "\n Player[" + " Speed(" + Game.Player.Character.Velocity.Length().ToString(format) + ")," + " Position(X:" + ppos.X.ToString(format) + ", Y:" + ppos.Y.ToString(format) + ", Z:" + ppos.Z.ToString(format) + ") ]" + "\nHookedPeds(" + HookedPedCount + ")" + " Clock(" + DateTime.Now.ToString("HH:mm:ss") + ")"; } }
public async Task Should_get_hearing_details_by_id() { var seededHearing = await Hooks.SeedVideoHearing(); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var hearing = await _handler.Handle(new GetHearingByIdQuery(seededHearing.Id)); hearing.Should().NotBeNull(); hearing.CaseType.Should().NotBeNull(); hearing.HearingVenue.Should().NotBeNull(); hearing.HearingType.Should().NotBeNull(); var participants = hearing.GetParticipants(); participants.Any().Should().BeTrue(); var individuals = participants.Where(x => x.GetType() == typeof(Individual)) .ToList(); individuals.Should().NotBeNullOrEmpty(); var representatives = participants.Where(x => x.GetType() == typeof(Representative)); representatives.Should().NotBeNullOrEmpty(); var judges = participants.Where(x => x.GetType() == typeof(Judge)); judges.Should().NotBeNullOrEmpty(); var persons = hearing.GetPersons(); persons.Count.Should().Be(participants.Count); persons[0].Title.Should().NotBeEmpty(); var cases = hearing.GetCases(); hearing.GetCases().Any(x => x.IsLeadCase).Should().BeTrue(); cases.Count.Should().Be(2); cases[0].Name.Should().NotBeEmpty(); hearing.HearingRoomName.Should().NotBeEmpty(); hearing.OtherInformation.Should().NotBeEmpty(); hearing.CreatedBy.Should().NotBeNullOrEmpty(); foreach (var individual in individuals) { var address = individual.Person.Address; address.Should().NotBeNull(); address.HouseNumber.Should().NotBeNullOrEmpty(); address.Street.Should().NotBeNullOrEmpty(); address.Postcode.Should().NotBeNullOrEmpty(); } }
public async Task Should_throw_exception_when_searching_with_judge_username() { var hearing = await Hooks.SeedVideoHearing(); await Hooks.SeedVideoHearing(); await Hooks.SeedVideoHearing(); var username = hearing.GetParticipants().First(x => x.HearingRole.UserRole.IsJudge).Person.Username; var query = new GetHearingsByUsernameForDeletionQuery(username); Assert.ThrowsAsync <PersonIsAJudgeException>(() => _handler.Handle(query)).Message.Should().Contain("is a judge"); }
internal static void Init() { Hooks.InitHooks(); // Cards ------------------------- ExtendedSave.CardBeingSaved += OnCardBeingSaved; //MakerAPI.ChaFileLoaded += (sender, args) => //{ // var chaControl = MakerAPI.GetCharacterControl(); // if (chaControl != null) // { // ReloadChara(chaControl); // } //}; // Coordinates ------------------- ExtendedSave.CoordinateBeingSaved += file => { if (file == null) { return; } var character = GameObject.FindObjectOfType <Human>(); //MakerAPI.GetCharacterControl(); if (character == null) { KoikatuAPI.Logger.LogError("OnCoordinateBeingSaved fired outside chara maker"); KoikatuAPI.Logger.LogInfo(new StackTrace()); //return; } OnCoordinateBeingSaved(character, file); }; //ExtendedSave.CoordinateBeingLoaded += file => //{ // //if (Hooks.ClothesFileControlLoading || file == null) return; // // // Coord cards are loaded by loading into the character's nowCoordinate // var cf = ChaControls.FirstOrDefault(x => x.customParam == file); // if (cf != null) // { // OnCoordinateBeingLoaded(cf, file); // } //}; if (KoikatuAPI.EnableDebugLogging) { RegisterExtraBehaviour <TestCharaCustomFunctionController>(null); } }
public static void CreateHook(HookPair source, bool copyHook = true, float minRopeLength = MIN_MIN_ROPE_LENGTH, float customRopeLength = 0.0f) { if (!CheckHookPermission(source)) { return; } HookPair resultHook = CreateEntityHook(source, copyHook, HookPedsAtBonesCoords, minRopeLength, customRopeLength); if (resultHook != null) { Hooks.Add(resultHook); } }
private static void Begin() { Hooks.DoHook(); AllocConsole(); IntPtr stdHandle = GetStdHandle(STD_OUTPUT_HANDLE); SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true); FileStream fileStream = new FileStream(safeFileHandle, FileAccess.Write); Encoding encoding = Encoding.GetEncoding(MY_CODE_PAGE); StreamWriter standardOutput = new StreamWriter(fileStream, encoding); standardOutput.AutoFlush = true; System.Console.SetOut(standardOutput); }
private void SetAllByTriggerIfRequired(string tag, Hooks hook) { if (TargetTriggerTags.Contains(tag)) { if (ActivateBy == hook) { SetAll(true); } else if (DeactivateBy == hook) { SetAll(false); } } }
public new async Task TearDown() { if (_newHearingId != Guid.Empty) { TestContext.WriteLine($"Removing test hearing {_newHearingId}"); await Hooks.RemoveVideoHearing(_newHearingId); } if (_secondHearingId != Guid.Empty) { TestContext.WriteLine($"Removing test hearing {_secondHearingId}"); await Hooks.RemoveVideoHearing(_secondHearingId); } }
/// <summary> /// Gets a basic string representation of the definition. /// </summary> /// <returns>a basic string representation of the definition</returns> public override string ToString() { var ret = ""; if (ArgumentScaffoldType != null) { ret += ArgumentScaffoldType.Name; } ret += "(Arguments=" + Arguments.Count + ")"; ret += "(Actions=" + Actions.Count + ")"; ret += "(Hooks=" + Hooks.Count() + ")"; return(ret); }
public async Task Should_Remove_ParticipantLink_When_Participant_Is_Removed() { var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Booked, 0, false, true); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var participantWithALink = seededHearing.Participants.First(x => x.LinkedParticipants.Any()); await _commandHandler.Handle( new RemoveParticipantFromHearingCommand(seededHearing.Id, participantWithALink)); var hearingWithNoLinks = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); hearingWithNoLinks.Participants.Where(x => x.LinkedParticipants.Any()).Should().BeNullOrEmpty(); }
public bool AddHook(string hook, ulong id) { if (!Hooks.TryGetValue(hook, out List <ulong> current)) { current = new List <ulong>(); } if (current.Contains(id)) { return(false); } current.Add(id); Hooks[hook] = current; return(true); }
/// <summary>OnPlayerPreLogin - Internal hook fired when on player pre login.</summary> /// <param name="args">args - The PlayerPreLoginEventArgs object.</param> private void OnPlayerPreLogin(Hooks.PlayerPreLoginEventArgs args) { if (args.Player.IsLoggedIn) args.Player.SaveServerCharacter(); }
/// <summary>OnAccountDelete - Internal hook fired on account delete.</summary> /// <param name="args">args - The AccountDeleteEventArgs object.</param> private void OnAccountDelete(Hooks.AccountDeleteEventArgs args) { CharacterDB.RemovePlayer(args.User.ID); }
/// <summary>OnAccountCreate - Internal hook fired on account creation.</summary> /// <param name="args">args - The AccountCreateEventArgs object.</param> private void OnAccountCreate(Hooks.AccountCreateEventArgs args) { CharacterDB.SeedInitialData(Users.GetUser(args.User)); }
/// <summary> /// Occurs when the server receives data. /// </summary> void NetHooks_GetData(Hooks.GetDataEventArgs e) { if (e.MsgID == PacketTypes.PlayerUpdate) { byte plyID = e.Msg.readBuffer[e.Index]; byte flags = e.Msg.readBuffer[e.Index + 1]; var player = PlayerList[plyID]; if (player != null && player.LastState != flags) { player.LastState = flags; player.IdleCount = 0; } } }
public void processHook(Hooks Hook, Event Event) { foreach (Plugin plugin in pluginList) { try { if (plugin.containsHook(Hook)) { switch (Hook) { case Hooks.CONSOLE_COMMAND: { plugin.onPlayerCommandProcess((ConsoleCommandEvent)Event); break; } case Hooks.PLAYER_COMMAND: { plugin.onPlayerCommand((PlayerCommandEvent)Event); break; } case Hooks.PLAYER_CHAT: { plugin.onPlayerChat((PlayerChatEvent)Event); break; } case Hooks.PLAYER_PRELOGIN: { plugin.onPlayerPreLogin((LoginEvent)Event); break; } case Hooks.PLAYER_LOGIN: { plugin.onPlayerJoin((LoginEvent)Event); break; } case Hooks.PLAYER_LOGOUT: { plugin.onPlayerLogout((LogoutEvent)Event); break; } case Hooks.PLAYER_PARTYCHANGE: { plugin.onPlayerPartyChange((PartyChangeEvent)Event); break; } case Hooks.TILE_BREAK: { plugin.onTileBreak((TileBreakEvent)Event); break; } case Hooks.PLAYER_HURT: { plugin.onPlayerHurt((PlayerHurtEvent)Event); break; } case Hooks.PLAYER_CHEST: { plugin.onPlayerOpenChest((ChestOpenEvent)Event); break; } } } } catch (Exception exception) { Console.WriteLine("Error Passing Event " + Hook.ToString() + " to " + plugin.Name); Console.WriteLine(exception.ToString()); } } }
/// <summary> /// Determines whether a plugins has registered a hook, then fires the appropriate method if so /// </summary> /// <param name="hook">Hook to process</param> /// <param name="hookEvent">Event instance to pass to any hooked methods</param> public void processHook(Hooks hook, Event hookEvent) { foreach (Plugin plugin in plugins.Values) { try { if (plugin.containsHook(hook)) { switch (hook) { case Hooks.CONSOLE_COMMAND: plugin.onConsoleCommand((ConsoleCommandEvent)hookEvent); break; case Hooks.PLAYER_COMMAND: plugin.onPlayerCommand((PlayerCommandEvent)hookEvent); break; case Hooks.PLAYER_CHAT: plugin.onPlayerChat((MessageEvent)hookEvent); break; case Hooks.PLAYER_PRELOGIN: plugin.onPlayerPreLogin((PlayerLoginEvent)hookEvent); break; case Hooks.PLAYER_LOGIN: plugin.onPlayerJoin((PlayerLoginEvent)hookEvent); break; case Hooks.PLAYER_LOGOUT: plugin.onPlayerLogout((PlayerLogoutEvent)hookEvent); break; case Hooks.PLAYER_PARTYCHANGE: plugin.onPlayerPartyChange((PartyChangeEvent)hookEvent); break; case Hooks.PLAYER_TILECHANGE: plugin.onPlayerTileChange((PlayerTileChangeEvent)hookEvent); break; case Hooks.PLAYER_HURT: plugin.onPlayerHurt((PlayerHurtEvent)hookEvent); break; case Hooks.PLAYER_CHEST: plugin.onPlayerOpenChest((PlayerChestOpenEvent)hookEvent); break; case Hooks.PLAYER_DEATH: plugin.onPlayerDeath((PlayerDeathEvent)hookEvent); break; case Hooks.DOOR_STATECHANGE: plugin.onDoorStateChange((DoorStateChangeEvent)hookEvent); break; case Hooks.PLAYER_EDITSIGN: plugin.onPlayerEditSign((PlayerEditSignEvent)hookEvent); break; case Hooks.PLAYER_PROJECTILE: plugin.onPlayerProjectileUse((PlayerProjectileEvent)hookEvent); break; case Hooks.NPC_DEATH: plugin.onNPCDeath((NPCDeathEvent)hookEvent); break; case Hooks.NPC_SPAWN: plugin.onNPCSpawn((NPCSpawnEvent)hookEvent); break; case Hooks.PLAYER_TELEPORT: plugin.onPlayerTeleport((PlayerTeleportEvent)hookEvent); break; case Hooks.PLAYER_MOVE: plugin.onPlayerMove((PlayerMoveEvent)hookEvent); break; case Hooks.PLAYER_KEYPRESS: plugin.onPlayerKeyPress((PlayerKeyPressEvent)hookEvent); break; case Hooks.PLAYER_PVPCHANGE: plugin.onPlayerPvPChange((PlayerPvPChangeEvent)hookEvent); break; case Hooks.PLAYER_AUTH_QUERY: plugin.onPlayerAuthQuery ((PlayerLoginEvent) hookEvent); break; case Hooks.PLAYER_AUTH_REPLY: plugin.onPlayerAuthReply ((PlayerLoginEvent) hookEvent); break; case Hooks.NPC_BOSSDEATH: plugin.onNPCBossDeath((NPCBossDeathEvent)hookEvent); break; case Hooks.NPC_BOSSSUMMON: plugin.onNPCBossSummon((NPCBossSummonEvent)hookEvent); break; case Hooks.PLAYER_FLOWLIQUID: plugin.onPlayerFlowLiquid ((PlayerFlowLiquidEvent)hookEvent); break; case Hooks.PLAYER_CHESTBREAK: plugin.onPlayerChestBreak((PlayerChestBreakEvent)hookEvent); break; case Hooks.TIME_CHANGED: plugin.onTimeChange((TimeChangedEvent)hookEvent); break; } } } catch (Exception exception) { ProgramLog.Log (exception, "Error passing event " + hook.ToString() + " to " + plugin.Name); } } }
private void OnPlayerLogin(Hooks.PlayerPostLoginEventArgs args) { User u = Users.GetUserByName(args.Player.UserAccountName); List<String> KnownIps = new List<string>(); if (!string.IsNullOrWhiteSpace(u.KnownIps)) { KnownIps = JsonConvert.DeserializeObject<List<String>>(u.KnownIps); } bool found = KnownIps.Any(s => s.Equals(args.Player.IP)); if (!found) { if (KnownIps.Count == 100) { KnownIps.RemoveAt(0); } KnownIps.Add(args.Player.IP); } u.KnownIps = JsonConvert.SerializeObject(KnownIps, Formatting.Indented); Users.UpdateLogin(u); }
public bool containsHook(Hooks Hook) { return pluginHooks.Contains(Hook); }
public bool registerHook(Hooks Hook) { if (!containsHook(Hook)) { pluginHooks.Add(Hook); return true; } return false; }
public void processHook(Hooks hook, Event hookEvent) { foreach (Plugin plugin in plugins.Values) { try { if (plugin.containsHook(hook)) { switch (hook) { case Hooks.CONSOLE_COMMAND: { plugin.onPlayerCommandProcess((ConsoleCommandEvent)hookEvent); break; } case Hooks.PLAYER_COMMAND: { plugin.onPlayerCommand((PlayerCommandEvent)hookEvent); break; } case Hooks.PLAYER_CHAT: { plugin.onPlayerChat((MessageEvent)hookEvent); break; } case Hooks.PLAYER_PRELOGIN: { plugin.onPlayerPreLogin((PlayerLoginEvent)hookEvent); break; } case Hooks.PLAYER_LOGIN: { plugin.onPlayerJoin((PlayerLoginEvent)hookEvent); break; } case Hooks.PLAYER_LOGOUT: { plugin.onPlayerLogout((PlayerLogoutEvent)hookEvent); break; } case Hooks.PLAYER_PARTYCHANGE: { plugin.onPlayerPartyChange((PartyChangeEvent)hookEvent); break; } case Hooks.TILE_CHANGE: { plugin.onTileChange((PlayerTileChangeEvent)hookEvent); break; } case Hooks.PLAYER_HURT: { plugin.onPlayerHurt((PlayerHurtEvent)hookEvent); break; } case Hooks.PLAYER_CHEST: { plugin.onPlayerOpenChest((PlayerChestOpenEvent)hookEvent); break; } case Hooks.PLAYER_STATEUPDATE: { plugin.onPlayerStateUpdate((PlayerStateUpdateEvent)hookEvent); break; } case Hooks.PLAYER_DEATH: { plugin.onPlayerDeath((PlayerDeathEvent)hookEvent); break; } case Hooks.DOOR_STATECHANGE: { plugin.onDoorStateChange((DoorStateChangeEvent)hookEvent); break; } case Hooks.PLAYER_EDITSIGN: { plugin.onPlayerEditSign((PlayerEditSignEvent)hookEvent); break; } case Hooks.PLAYER_PROJECTILE: { plugin.onPlayerProjectileUse((PlayerProjectileEvent)hookEvent); break; } } } } catch (Exception exception) { Program.tConsole.WriteLine("Error Passing Event " + hook.ToString() + " to " + plugin.Name); Program.tConsole.WriteLine(exception.ToString()); } } }
/// <summary> /// Occurs when the server has a chunk of data to send /// </summary> static void NetHooks_SendData(Hooks.SendDataEventArgs e) { if (e.MsgID == PacketTypes.NpcStrike) { //occurs when the sevrer sends NPC strike acknowledgements //ignoreClient is the slot of the player who did the damage //number is the NPC that was struck //number2 is the amount of damage the server acknowledged. lock (__dictionaryLock) { AddNPCDamage(Terraria.Main.npc[e.number], e.ignoreClient >= 0 ? Terraria.Main.player[e.ignoreClient] : null, Convert.ToInt32(e.number2)); } } else if (e.MsgID == PacketTypes.NpcUpdate) { //occurs when the server sends NPC updates. not active means a mob died or somehow got deleted //rewards for it in the dictionary should be handed to players that hit it Terraria.NPC npc = Terraria.Main.npc[e.number]; if (npc != null && !npc.active) { lock (__dictionaryLock) { GiveRewardsForNPC(npc); } } } else if (e.MsgID == PacketTypes.PlayerDamage) { //occurs when a player hits another player. ignoreClient is the player that hit, e.number is the //player that got hit, and e.number4 is a flag indicating PvP damage if ( Convert.ToBoolean(e.number4) && Terraria.Main.player[e.number] != null ) { lock (__pvpLock) { PlayerHitPlayer(e.ignoreClient, e.number); } } } else if (e.MsgID == PacketTypes.PlayerKillMe) { //Occrs when the player dies. lock (__dictionaryLock) { ProcessDeath(e.number, Convert.ToBoolean(e.number4)); } } }
/// <summary> /// Occurs when the server sends data. /// </summary> void NetHooks_SendData(Hooks.SendDataEventArgs e) { if (e.MsgID == PacketTypes.NpcStrike) { NPC npc = Main.npc[e.number]; if (npc != null) { if (npc.boss) { if (npc.life <= 0) { for (int i = BossList.Count - 1; i >= 0; i--) { if (BossList[i].Npc == null) BossList.RemoveAt(i); else if (BossList[i].Npc == npc) { var rewardDict = BossList[i].GetRecalculatedReward(); foreach (KeyValuePair<int, long> reward in rewardDict) { if (PlayerList[reward.Key] != null) { SEconomy.Economy.EconomyPlayer ePlayer = SEconomyPlugin.GetEconomyPlayerSafe(reward.Key); if (ePlayer != null) { //Pay from the world account to the reward recipient. Journal.BankAccountTransferOptions options = Journal.BankAccountTransferOptions.None; if (Config.AnnounceBossGain) { options |= Journal.BankAccountTransferOptions.AnnounceToReceiver; } SEconomyPlugin.WorldAccount.TransferTo(ePlayer.BankAccount, reward.Value, options); } } } BossList.RemoveAt(i); } else if (!BossList[i].Npc.active) BossList.RemoveAt(i); } if (e.ignoreClient >= 0) { var player = PlayerList[e.ignoreClient]; if (player != null) player.AddKill(npc.netID); } } else if (e.ignoreClient >= 0) { var bossnpc = BossList.Find(n => n.Npc == npc); if (bossnpc != null) bossnpc.AddDamage(e.ignoreClient, (int)e.number2); else { BossNPC newBoss = new BossNPC(npc); newBoss.AddDamage(e.ignoreClient, (int)e.number2); BossList.Add(newBoss); } } } else if (npc.life <= 0 && e.ignoreClient >= 0) { var player = PlayerList[e.ignoreClient]; if (player != null) { if (npc.value > 0) { float Mod = 1; if (player.TSPlayer.TPlayer.buffType.Contains(13)) { // battle potion Mod *= Config.BattlePotionModifier; } if (Config.OptionalMobModifier.ContainsKey(npc.netID)) { Mod *= Config.OptionalMobModifier[npc.netID]; // apply custom modifiers } int minVal = (int)((npc.value - (npc.value * 0.1)) * Mod); int maxVal = (int)((npc.value + (npc.value * 0.1)) * Mod); int rewardAmt = _r.Next(minVal, maxVal); int i = player.TSPlayer.Index; SEconomy.Economy.EconomyPlayer epl = SEconomyPlugin.GetEconomyPlayerSafe(i); Journal.BankAccountTransferOptions options = Journal.BankAccountTransferOptions.None; if (Config.AnnounceKillGain) { options |= Journal.BankAccountTransferOptions.AnnounceToReceiver; } SEconomyPlugin.WorldAccount.TransferTo(i, rewardAmt, options); } player.AddKill(npc.netID); } } } } else if (e.MsgID == PacketTypes.PlayerKillMe) { //Console.WriteLine("(SendData) PlayerKillMe -> 1:{0} 2:{4} 3:{5} 4:{6} 5:{1} remote:{2} ignore:{3}", e.number, e.number5, e.remoteClient, e.ignoreClient, e.number2, e.number3, e.number4); // 1-playerID, 2-direction, 3-dmg, 4-PVP var deadPlayer = PlayerList[e.number]; Economy.EconomyPlayer eDeadPlayer = SEconomyPlugin.GetEconomyPlayerSafe(e.number); if (deadPlayer != null) { long penaltyAmmount = 0; if (Config.StaticDeathPenalty) { penaltyAmmount = _r.Next(Config.DeathPenaltyMin, Config.DeathPenaltyMax); } else if ( eDeadPlayer.BankAccount != null ) { penaltyAmmount = (long)(eDeadPlayer.BankAccount.Balance * (Config.DeathPenaltyPercent / 100f)); } // Console.WriteLine("penalty ammount: {0}", penaltyAmmount); if (e.number4 == 1) { if (!deadPlayer.TSPlayer.Group.HasPermission("vault.bypass.death") /* && deadPlayer.ChangeMoney(-penaltyAmmount, MoneyEventFlags.PvP, true) */ && Config.PvPWinnerTakesLoosersPenalty && deadPlayer.LastPVPID != -1) { var killer = PlayerList[deadPlayer.LastPVPID]; Economy.EconomyPlayer eKiller = SEconomyPlugin.GetEconomyPlayerSafe(deadPlayer.LastPVPID); if (eKiller != null && eKiller.BankAccount != null) { Journal.BankAccountTransferOptions options = Journal.BankAccountTransferOptions.MoneyFromPvP | Journal.BankAccountTransferOptions.AnnounceToReceiver | Journal.BankAccountTransferOptions.AnnounceToSender; // killer.ChangeMoney(penaltyAmmount, MoneyEventFlags.PvP, true); //Here in PVP the loser pays the winner money out of their account. eDeadPlayer.BankAccount.TransferTo(deadPlayer.LastPVPID, penaltyAmmount, options); } } } else if (!deadPlayer.TSPlayer.Group.HasPermission("vault.bypass.death")) { Journal.BankAccountTransferOptions options = Journal.BankAccountTransferOptions.MoneyFromPvP | Journal.BankAccountTransferOptions.AnnounceToReceiver | Journal.BankAccountTransferOptions.AnnounceToSender; // deadPlayer.ChangeMoney(-penaltyAmmount, MoneyEventFlags.Death, true); SEconomyPlugin.WorldAccount.TransferTo(deadPlayer.Index, -penaltyAmmount, options); } } } else if (e.MsgID == PacketTypes.PlayerDamage) { // Console.WriteLine("(SendData) PlayerDamage -> 1:{0} 2:{4} 3:{5} 4:{6} 5:{1} remote:{2} ignore:{3}", e.number, e.number5, e.remoteClient, e.ignoreClient, e.number2, e.number3, e.number4); // 1: pID, ignore: Who, 2: dir, 3:dmg, 4:pvp; if (e.number4 == 1) { // if PvP { var player = PlayerList[e.number]; if (player != null) { player.LastPVPID = e.ignoreClient; } } } }
/// <summary> /// Do the browseToToolStripMenuItem method /// </summary> public void notecEdfrm_HookEvent(Hooks message, object args) { browseToToolStripMenuItem_Click(message, EventArgs.Empty); }
private void windowsHook_MouseHook(object sender, Hooks.MouseHookEventArgs e) { switch(e.Message) { case Hooks.MouseMessages.LButtonDblClk: case Hooks.MouseMessages.LButtonDown: case Hooks.MouseMessages.LButtonUp: case Hooks.MouseMessages.MButtonDblClk: case Hooks.MouseMessages.MButtonDown: case Hooks.MouseMessages.MButtonUp: case Hooks.MouseMessages.RButtonDblClk: case Hooks.MouseMessages.RButtonDown: case Hooks.MouseMessages.RButtonUp: case Hooks.MouseMessages.XButtonDblClk: case Hooks.MouseMessages.XButtonDown: if (this.CloseOnMouseClick) Close(); break; case Hooks.MouseMessages.MouseMove: if (this.CloseOnMouseMove) Close(); break; } }
public HookAttribute(Hooks hook) { Hook = hook; }
private void windowsHook_KeyBoardHook(object sender, Hooks.KeyBoardHookEventArgs e) { this.Close(); }
public static void callHook(Hooks hook, Client client, Event ev = null) { foreach (ModulePlugin module in moduleList) { try { if (module.moduleHooks.Contains(hook)) { Console.WriteLine("hook " + hook + " : " + module.ToString()); switch (hook) { case Hooks.USER_CHANNEL_PRIVMSG: { ChannelMessageEvent me = (ChannelMessageEvent)ev; if (me.channel.containsUser(me.user)) { module.onUserMessageChannel(me); } break; } case Hooks.USER_MESSAGE_CLIENT: { Console.WriteLine("message called"); UserMessageEvent me = (UserMessageEvent)ev; if (me.sendee == client) { module.onUserMessageClient(me); } break; } case Hooks.CLIENT_KILLED: { KillEvent me = (KillEvent)ev; if (me.killee == client) { module.onClientKilled(me); } break; } case Hooks.USER_CONNECT: { UserEvent me = (UserEvent)ev; if (me.user != client) { module.onUserConnect(me); } break; } case Hooks.USER_NICKCHANGE: { UserNickChangeEvent me = (UserNickChangeEvent)ev; if (me.user != client) { module.onUserNickChange(me); } break; } case Hooks.CHANNEL_LOG: { ChannelLogEvent me = (ChannelLogEvent)ev; module.onChannelLog(me); break; } case Hooks.CLIENT_INTRO: { ClientIntroduceEvent me = (ClientIntroduceEvent)ev; Console.WriteLine("Client " + me.client.nickname + " introduced!"); module.onClientIntroduce(me); break; } case Hooks.SERVER_BURST: { module.onServerBurst(); break; } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } } }
private void OnPlayerLogin(Hooks.PlayerPostLoginEventArgs args) { if (args.Player.IsRaptor) { Task.Factory.StartNew(() => { args.Player.SendRaptorPermissions(); if (args.Player.Group.HasPermission(Permissions.manageregion)) { for (int i = 0; i < Regions.Regions.Count; i++) args.Player.SendRaptorRegion(Regions.Regions[i]); } if (args.Player.Group.HasPermission(Permissions.managewarp)) { for (int i = 0; i < Warps.Warps.Count; i++) args.Player.SendRaptorWarp(Warps.Warps[i]); } }); } User u = Users.GetUserByName(args.Player.UserAccountName); List<String> KnownIps = new List<string>(); if (!string.IsNullOrWhiteSpace(u.KnownIps)) { KnownIps = JsonConvert.DeserializeObject<List<String>>(u.KnownIps); } bool found = KnownIps.Any(s => s.Equals(args.Player.IP)); if (!found) { if (KnownIps.Count == 100) { KnownIps.RemoveAt(0); } KnownIps.Add(args.Player.IP); } u.KnownIps = JsonConvert.SerializeObject(KnownIps, Formatting.Indented); Users.UpdateLogin(u); }
/// <summary> /// stop the server /// </summary> public void Stop() { // request thread be stopped _go = false; if (tl != null) tl.Stop(); if (!_valid) return; try { // stop thread bw.CancelAsync(); // release symbols foreach (Security sec in _mb) esig.ReleaseSymbol(sec.symbol); } catch (Exception ex) { if (GotDebug != null) GotDebug(ex.Message + ex.StackTrace); } // garbage collect esignal object esig = null; }
public void Start(string user, string password, string data1, int data2) { try { // paper trading ptt.GotCancelEvent += new LongDelegate(tl.newCancel); ptt.GotFillEvent += new FillDelegate(tl.newFill); ptt.GotOrderEvent += new OrderDelegate(tl.newOrder); ptt.SendDebugEvent += new DebugDelegate(ptt_SendDebugEvent); ptt.UseBidAskFills = isPaperTradeUsingBidAsk; debug("attempting to start connection"); // connect to esignal esig = new Hooks(); // handle historical bars esig.OnBarsReceived += new _IHooksEvents_OnBarsReceivedEventHandler(esig_OnBarsReceived); // handle esignal quotes esig.OnQuoteChanged += new _IHooksEvents_OnQuoteChangedEventHandler(esig_OnQuoteChanged); } catch (Exception ex) { const string url = @"http://code.google.com/p/tradelink/wiki/EsignalConfig"; System.Diagnostics.Process.Start(url); debug("Exception loading esignal: " + ex.Message + ex.StackTrace); _valid = false; debug("For more info see: " + url); _valid = false; return; } if ((user==null) || (user==string.Empty)) return; esig.SetApplication(user); _valid = esig.IsEntitled != 0; if (_valid) { debug("success"); _go = true; // start background processing if (!bw.IsBusy) bw.RunWorkerAsync(); } else debug("failed."); }
private void OnPlayerPreLogin(Hooks.PlayerPreLoginEventArgs args) { if (args.Player.IsLoggedIn) args.Player.SaveServerCharacter(); if (args.Player.ItemInHand.type != 0) { args.Player.SendErrorMessage("Attempting to bypass SSC with item in hand."); args.Handled = true; } }