How to block executing of events

Due to human (non-bot) spam the first contribution of a user has to be reviewed and activated manually, all further contributions do not require this.
As long as a user does not have at least one reviewed and activated contribution, the user is unable to edit his profile, set a avatar, title picture or a signature.
  • Add this method to your code:

    C#
    public static void AddActionPreventer<T>(PlayerActionManager<T> pPlayerActionManager, IActionPreventer<T> pActionPreventer) where T : IPlayerAction, new()
    {
        FieldInfo fi = pPlayerActionManager.GetType().BaseType.GetField("actionPreventers", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        IActionPreventer<T>[] actionPreventers = (IActionPreventer<T>[])fi.GetValue(pPlayerActionManager);
        var preventers = actionPreventers.ToList();
        preventers.Add(pActionPreventer);
        fi.SetValue(pPlayerActionManager, preventers.ToArray());
    }


    Call it like this to register your "Event Listener":

    C#
    AddActionPreventer(PlayerActions.Message, new MyMessagePreventer());


    Now you can create an ActionPreventer (A Factorty of IAtomicActions)

    C#
    public class MyMessagePreventer : IActionPreventer<MessageAction>
      {
          public IAtomicAction CreateAtomicAction(MessageAction action)
          {
              return new FailedAtomicAction(new LocString("Blocked!"));
          }
      }

    Because [ICODE]MessageAction[/ICODE] does not contain the real message, it's not possible to block messages based on the content.
    (With this way)

    Also it's possible to implement your own Action ;)


    Have fun :p


    Thanks to Kronox for help ;)

    Edited 3 times, last by mampf (April 5, 2018 at 9:29 PM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!