mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Add a way to use unsafe nicknames (#2152) @pop4959
Pretty much what the title says. Closes #1630. This is a fun little feature that I'm sure many people have always wanted. I can understand that the original authors of Essentials were probably concerned about users entering names that cannot display correctly in the chat, and that is understandable. I have added a new permission "essentials.nick.allowunsafe", which must be given to anyone who is allowed to use characters outside of the alphanumeric set. The name of the permission is inspired from "essentials.enchantments.allowunsafe", which allows unsafe enchantment levels to be applied to items without guaranteed behaviour. Similarly, the permission "essentials.nick.allowunsafe" allows unsafe characters to be entered for the user's nickname without making any guarantee that those characters will show up in chat correctly.
This commit is contained in:
parent
6c9c9ad42a
commit
a3eb58724f
@ -75,7 +75,7 @@ public class Commandnick extends EssentialsLoopCommand {
|
||||
|
||||
private String formatNickname(final User user, final String nick) throws Exception {
|
||||
String newNick = user == null ? FormatUtil.replaceFormat(nick) : FormatUtil.formatString(user, "essentials.nick", nick);
|
||||
if (!newNick.matches("^[a-zA-Z_0-9\u00a7]+$")) {
|
||||
if (!newNick.matches("^[a-zA-Z_0-9\u00a7]+$") && user != null && !user.isAuthorized("essentials.nick.allowunsafe")) {
|
||||
throw new Exception(tl("nickNamesAlpha"));
|
||||
} else if (getNickLength(newNick) > ess.getSettings().getMaxNickLength()) {
|
||||
throw new Exception(tl("nickTooLong"));
|
||||
|
Loading…
Reference in New Issue
Block a user