TeleportConsumer.cs 982 B

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