private void SetupTypes(PluginInfo plugin)
        {
            //Loads Events
            foreach (MethodInfo method in plugin.MainClassType.GetMethods())
            {
                foreach (Attribute attribute in method.GetCustomAttributes(true))
                {
                    if (attribute is IRSEEventAttribute)
                    {
                        IRSEEventAttribute hea = attribute as IRSEEventAttribute;

                        HandleEvent(method, plugin, hea.EventType);
                    }
                }
            }
        }
        private PluginInfo ValidatePlugin(String library)
        {
            byte[]   bytes;
            Assembly libraryAssembly;

            try
            {
                bytes           = File.ReadAllBytes(library);
                libraryAssembly = Assembly.Load(bytes);
                //Bug Guid is Glitched Right Now
                //Guid guid = new Guid(((GuidAttribute)libraryAssembly.GetCustomAttributes(typeof(GuidAttribute), true)[0]).Value);

                bool       plug   = true;
                PluginInfo plugin = new PluginInfo();
                //Plugin.Guid = guid;
                plugin.Assembly = libraryAssembly;

                //Command[] CommandList;

                Type[] PluginTypes = libraryAssembly.GetExportedTypes();

                foreach (Type PluginType in PluginTypes)
                {
                    /*
                     * if (PluginType.BaseType == typeof(Command))
                     * {
                     *  plugin.FoundCommands.Add(PluginType);
                     *  //Permissions In Command
                     *  //Load Permissions
                     *  foreach (Attribute attribute in PluginType.GetCustomAttributes(true))
                     *  {
                     *      if (attribute is PermissionAttribute)
                     *      {
                     *          PermissionAttribute pa = attribute as PermissionAttribute;
                     *          //Add To plugin
                     *          //Onplayer Join Event Add Default Perms to player
                     *          ServerInstance.Instance.PermissionManager.AddPermissionAttribute(pa);
                     *      }
                     *  }
                     *  continue;
                     * }*/

                    if (PluginType.GetInterface(typeof(IPlugin).FullName) != null && plug)
                    {
                        mainLog.Warn("Loading Plugin Located at " + library);

                        PluginAttribute attr = PluginType.GetCustomAttribute <PluginAttribute>();

                        plugin.MainClassType = PluginType;
                        plugin.Name          = attr.Name;
                        plug = false;
                        continue;
                    }
                }
                //B4 resturn Check for Events here
                //Now Look for Events... IN THE PLUGIN TYPE!!!!!!!
                //Events
                if (!plug)
                {
                    //Loads Events
                    foreach (MethodInfo method in plugin.MainClassType.GetMethods())
                    {
                        foreach (Attribute attribute in method.GetCustomAttributes(true))
                        {
                            if (attribute is IRSEEventAttribute)
                            {
                                IRSEEventAttribute hea = attribute as IRSEEventAttribute;

                                plugin = HandleEvent(method, plugin, hea.EventType);
                            }
                        }
                    }


                    /*
                     * //Load Permissions
                     * foreach (Attribute attribute in plugin.GetType().GetCustomAttributes(true))
                     * {
                     *  if (attribute is PermissionAttribute)
                     *  {
                     *      PermissionAttribute pa = attribute as PermissionAttribute;
                     *      //Add To plugin
                     *      //Onplayer Join Event Add Default Perms to player
                     *      ServerInstance.Instance.PermissionManager.AddPermissionAttribute(pa);
                     *  }
                     * }
                     */
                }
                return(plugin);
            }
            catch (Exception ex)
            {
                mainLog.Error("Failed to load assembly: " + library + " Error: " + ex.ToString());
            }
            return(null);
        }