mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-04-06 13:30:43 +08:00
Add option to customize nickname regex filter (#5200)
This commit is contained in:
parent
40540ebb3d
commit
cb6187bbf2
@ -424,6 +424,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean showZeroBaltop();
|
||||
|
||||
String getNickRegex();
|
||||
|
||||
BigDecimal getMultiplier(final User user);
|
||||
|
||||
int getMaxItemLore();
|
||||
|
@ -2120,6 +2120,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("show-zero-baltop", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNickRegex() {
|
||||
return config.getString("allowed-nicks-regex", "^[a-zA-Z_0-9§]+$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMultiplier(final User user) {
|
||||
BigDecimal multiplier = defaultMultiplier;
|
||||
|
@ -63,7 +63,7 @@ public class Commandnick extends EssentialsLoopCommand {
|
||||
|
||||
private String formatNickname(final User user, final String nick) throws Exception {
|
||||
final String newNick = user == null ? FormatUtil.replaceFormat(nick) : FormatUtil.formatString(user, "essentials.nick", nick);
|
||||
if (!newNick.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$") && user != null && !user.isAuthorized("essentials.nick.allowunsafe")) {
|
||||
if (!newNick.matches(ess.getSettings().getNickRegex()) && user != null && !user.isAuthorized("essentials.nick.allowunsafe")) {
|
||||
throw new TranslatableException("nickNamesAlpha");
|
||||
} else if (getNickLength(newNick) > ess.getSettings().getMaxNickLength()) {
|
||||
throw new TranslatableException("nickTooLong");
|
||||
|
@ -33,6 +33,11 @@ nickname-prefix: '~'
|
||||
# The maximum length allowed in nicknames. The nickname prefix is not included in this.
|
||||
max-nick-length: 15
|
||||
|
||||
# The regex pattern used to determine if a requested nickname should be allowed for use.
|
||||
# If the a request nickname does not matched this pattern, the nickname will be rejected.
|
||||
# Users with essentials.nick.allowunsafe will be able to bypass this check.
|
||||
allowed-nicks-regex: '^[a-zA-Z_0-9§]+$'
|
||||
|
||||
# A list of phrases that cannot be used in nicknames. You can include regular expressions here.
|
||||
# Users with essentials.nick.blacklist.bypass will be able to bypass this filter.
|
||||
nick-blacklist:
|
||||
|
Loading…
x
Reference in New Issue
Block a user