Ejemplo n.º 1
0
        public static bool IsGatherer()
        {
            try
            {
                IActPluginV1 plugin = null;

                foreach (var item in ActGlobals.oFormActMain.ActPlugins)
                {
                    if (item.pluginFile.Name.ToUpper() == "FFXIV_ACT_Plugin.dll".ToUpper() &&
                        item.lblPluginStatus.Text.ToUpper() == "FFXIV Plugin Started.".ToUpper())
                    {
                        plugin = item.pluginObj;
                        break;
                    }
                }

                FieldInfo fi;

                fi = plugin.GetType().GetField("_Memory", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
                var pluginMemory = fi.GetValue(plugin);

                fi = pluginMemory.GetType().GetField("_config", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
                var pluginConfig = fi.GetValue(pluginMemory);

                fi = pluginConfig.GetType().GetField("ScanCombatants", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
                dynamic pluginScancombat = fi.GetValue(pluginConfig);

                dynamic playerData = pluginScancombat.GetPlayerData();

                var gatherId = new List <int>()
                {
                    16, 17
                };                                        // 採掘 or 園芸
                return(gatherId.Contains(playerData.JobID));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(false);
            }
        }
        private void Initailize()
        {
            if (!string.IsNullOrEmpty(PlayerData.Instance.Name))
            {
                return;
            }

            Invoke(() =>
            {
                IActPluginV1 o = null;
                foreach (var x in ActGlobals.oFormActMain.ActPlugins)
                {
                    if (x.pluginFile.Name.ToUpper() == "FFXIV_ACT_Plugin.dll".ToUpper() && x.cbEnabled.Checked)
                    {
                        o = x.pluginObj;
                        if (o != null)
                        {
                            try
                            {
                                var pluginType = o.GetType();

                                o.DeInitPlugin();
                                x.pluginObj = o = null;
                                System.Threading.Thread.Sleep(500);
                                x.tpPluginSpace.Controls.Clear();
                                System.Threading.Thread.Sleep(500);

                                IActPluginV1 main = (IActPluginV1)Activator.CreateInstance(pluginType);

                                main.InitPlugin(x.tpPluginSpace, x.lblPluginStatus);
                                x.pluginObj = o = main;
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            });
        }
Ejemplo n.º 3
0
        private int GetLanguageInternal(IActPluginV1 plugin)
        {
            // Cannot "just" cast to FFXIV_ACT_Plugin.FFXIV_ACT_Plugin here, because
            // ACT uses LoadFrom which places the assembly into its own loading
            // context.  This means you can't ever cast to these types, because types
            // in the normal DLL assembly loaded via path is a different type than
            // the one in the other context.  So, time for reflection.  And sadness.
            // This is brittle, but hopefully ravahn never changes these signatures.
            // The other alternative is to find and load the XML settings.
            // See also:
            // http://www.hanselman.com/blog/FusionLoaderContextsUnableToCastObjectOfTypeWhateverToTypeWhatever.aspx
            // https://blogs.msdn.microsoft.com/aszego/2009/10/16/avoid-using-assembly-loadfrom/

            FieldInfo fi       = plugin.GetType().GetField("Settings", BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance);
            var       settings = fi.GetValue(plugin);

            MethodInfo mi             = settings.GetType().GetMethod("GetParseSettings", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance);
            var        parse_settings = mi.Invoke(settings, new object[] { });

            fi = parse_settings.GetType().GetField("LanguageID", BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance);
            return((int)fi.GetValue(parse_settings));
        }