L2JMobius

Free Users => Shares/Contributions => Topic started by: binary on December 28, 2021, 04:04:10 AM

Title: GM name pattern check
Post by: binary on December 28, 2021, 04:04:10 AM
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 (https://pastebin.com/r51Rh55X)

Title: Re: GM name pattern check
Post by: Mobius on December 29, 2021, 07:11:07 AM
Might want to use the pre-existing ForbiddenNames configuration (Config.FORBIDDEN_NAMES) for the regex you already use.
Title: Re: GM name pattern check
Post by: binary on December 29, 2021, 03:41:57 PM
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.