TeleportConsumer.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using Dalamud.Plugin.Ipc;
  3. namespace HuntBuddy.Ipc;
  4. public class TeleportConsumer: ConsumerBase {
  5. public override string RequiredPlugin { get; } = "TeleporterPlugin";
  6. protected override bool Validate() {
  7. this.consumerMessageSetting.InvokeFunc();
  8. return true;
  9. }
  10. private ICallGateSubscriber<bool> consumerMessageSetting = null!;
  11. private ICallGateSubscriber<uint, byte, bool> consumerTeleport = null!;
  12. private void Subscribe() {
  13. try {
  14. this.consumerTeleport = Service.PluginInterface.GetIpcSubscriber<uint, byte, bool>("Teleport");
  15. this.consumerMessageSetting = Service.PluginInterface.GetIpcSubscriber<bool>("Teleport.ChatMessage");
  16. }
  17. catch (Exception ex) {
  18. Service.PluginLog.Debug($"Failed to subscribe to Teleporter\nReason: {ex}");
  19. }
  20. }
  21. public TeleportConsumer() => this.Subscribe();
  22. public bool Teleport(uint aetheryteId) {
  23. try {
  24. return this.consumerTeleport.InvokeFunc(aetheryteId, 0);
  25. }
  26. catch {
  27. Service.Chat.PrintError("Teleporter plugin is not responding", Plugin.Instance.Name);
  28. return false;
  29. }
  30. }
  31. }