L2JMobius

C6 GM name pattern check

binary · 3 · 2375

Offline binary

  • Vassal
  • *
    • Posts: 3
Hello people !

I am new to this forum and I made this little code to share with you.
It is a simple setup to verify that the name of characters with GM status are validated against a whitelist of real admin names within your project.
The whitelist of names should be built with a regular expression.
The default regular expression is: "^(admin)$", this expression only accepts as GM name "Admin" case insensitive. To validate multiple names it is possible to use an expression like this "^(admin|gm|gamemaster)$".
To test a regular expression you can use this page: https://regexr.com/ or https://regex101.com/
For more info. about regular expressions read: https://www.w3schools.com/java/java_regex.asp.
I hope you find this mod useful.

Thank you very much for your attention, Regards.

BinaryDev.

https://pastebin.com/r51Rh55X



Online Mobius

  • Distinguished King
  • *****
    • Posts: 16010
Might want to use the pre-existing ForbiddenNames configuration (Config.FORBIDDEN_NAMES) for the regex you already use.


Offline binary

  • Vassal
  • *
    • Posts: 3
Hello, thank you for your reply.

Yes, I could have used that functionality instead of creating another one.  But the difference is that the code I shared implements a whitelist which is always in general a better practice than a BlackList and also this regular expression only applies to characters with GM/Admin status.

Greetings,
BinaryDev.