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 ;)

    3 Mal editiert, zuletzt von mampf (5. April 2018 um 21:29)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!