Example #1
0
        /// <summary>
        /// Initializes a new instance of the TestPlugin class.
        /// This is where you set the plugin's order and perfrom other constructor logic
        /// </summary>
        public Advert(Main game) : base(game)
        {
            Instance = this;

            Type[] regrs = Util.GetTypesWithAttribute(typeof(AdvertRegistrarAttribute)).ToArray();
            List <IAdvertRegistrar> regr = new List <IAdvertRegistrar>();

            foreach (Type t in regrs)
            {
                if (!t.GetInterfaces().Contains(typeof(IAdvertRegistrar)))
                {
                    Console.Error.WriteLine("AdvertRegistrar '{}' does not implement IAdvertRegistrar!");
                    continue;
                }

                var constr = t.GetConstructor(new Type[] { typeof(Main) });
                var args   = new object[] { game };

                if (constr == null)
                {
                    constr = t.GetConstructor(new Type[] {});
                    args   = new object[] {};
                }

                IAdvertRegistrar o = (IAdvertRegistrar)constr.Invoke(args);

                if (typeof(CommandAdverts).IsInstanceOfType(o))
                {
                    cmdAdv = (CommandAdverts)o;
                }

                regr.Add(o);
            }

            registrars = regr.ToArray();
        }
Example #2
0
 public RemindPlayerCheck(TSPlayer ply, CommandAdverts ths)
 {
     player = ply;
     self   = ths;
 }