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":
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