Ejemplo n.º 1
0
 public void Initialize(DalamudPluginInterface pluginInterface)
 {
     Interface = pluginInterface;
     Config    = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
     Config.Initialize(pluginInterface);
     AetheryteDataManager.Init(pluginInterface);
     Manager = new TeleportManager(this);
     Interface.CommandManager.AddHandler("/tp", new CommandInfo(CommandHandler)
     {
         HelpMessage = "<name> - Teleport to <name>"
     });
     Interface.CommandManager.AddHandler("/tpt", new CommandInfo(CommandHandler)
     {
         HelpMessage = "<name> - Teleport to <name> using Aetheryte Tickets if possible"
     });
     Interface.CommandManager.AddHandler("/tpm", new CommandInfo(CommandHandler)
     {
         HelpMessage = "<mapname> - Teleport to <mapname>"
     });
     Interface.CommandManager.AddHandler("/tptm", new CommandInfo(CommandHandler)
     {
         HelpMessage = "<mapname> - Teleport to <mapname> using Aetheryte Tickets if possible"
     });
     Gui = new PluginUi(this);
     Interface.Framework.Gui.Chat.OnChatMessage += Gui.LinksWindow.ChatOnChatMessage;
 }
Ejemplo n.º 2
0
        private AetheryteLocation GetClosestAetheryte()
        {
            var aetherytes = AetheryteDataManager.GetAetheryteLocationsByTerritoryId(TerritoryId, _plugin.Language);

            if (aetherytes.Count <= 0)
            {
                return(null);
            }
            return(aetherytes.Aggregate((curMin, x) => curMin == null || x.Distance2D(Location) < curMin.Distance2D(Location) ? x : curMin));
        }
Ejemplo n.º 3
0
        private void HandleTeleportCommand(string command, string args)
        {
            var locationString = args.Replace("\xe040", "").Replace("\xe041", "").Trim();

            var type = command.Equals("/tpt", StringComparison.OrdinalIgnoreCase) || command.Equals("/tptm", StringComparison.OrdinalIgnoreCase)
                ? TeleportType.Ticket
                : TeleportType.Direct;

            var useMap       = command.EndsWith("m", StringComparison.OrdinalIgnoreCase);
            var matchPartial = Config.AllowPartialMatch;

            if (TryGetAlias(locationString, out var alias, Config.AllowPartialAlias))
            {
                locationString = alias.Aetheryte;
                matchPartial   = false;
            }

            if (Config.UseGilThreshold)
            {
                var locationName = useMap ? AetheryteDataManager.GetAetheryteLocationsByTerritoryName(locationString, Language, matchPartial).FirstOrDefault()?.Name : locationString;
                var location     = Manager.GetLocationByName(locationName);
                if (location != null)
                {
                    if (location.GilCost > Config.GilThreshold)
                    {
                        type = TeleportType.Ticket;
                    }
                }
            }

            switch (type)
            {
            case TeleportType.Direct:
                Manager.Teleport(locationString, matchPartial, useMap);
                break;

            case TeleportType.Ticket:
                Manager.TeleportTicket(locationString, Config.SkipTicketPopup, matchPartial, useMap);
                break;

            default:
                LogError($"Unable to get a valid type for Teleport: '{string.Join(" ", args)}'");
                break;
            }
        }
        private void UpdateAetheryteList()
        {
            if (DateTime.UtcNow.Subtract(_lastAetheryteListUpdate).TotalMilliseconds < 5000)
            {
                return;
            }
            var list    = Plugin.Manager.AetheryteList.ToList();
            var mapList = new HashSet <string>();

            foreach (var location in list)
            {
                var locF = AetheryteDataManager.GetAetheryteLocationsByTerritoryId(location.ZoneId, Plugin.Language).FirstOrDefault();
                if (locF == null)
                {
                    continue;
                }
                mapList.Add(locF.TerritoryName);
            }
            _mapList                 = mapList.ToArray();
            _aetheryteList           = list.Select(a => a.Name).ToArray();
            _lastAetheryteListUpdate = DateTime.UtcNow;
        }