TeleportConsumer.cs 855 B

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