From a3eb58724f5777ccb12c47d110a5afe3994d3ac4 Mon Sep 17 00:00:00 2001 From: pop4959 Date: Sun, 2 Sep 2018 04:14:26 -0700 Subject: [PATCH] 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. --- .../src/com/earth2me/essentials/commands/Commandnick.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java index 40c901163..93e13002d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java @@ -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"));