Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.lenis0012.pluginutils.config.mapping.ConfigKey;
import com.lenis0012.pluginutils.config.mapping.ConfigMapper;
import lombok.Getter;
import org.bukkit.Bukkit;

@Getter
@ConfigMapper(fileName = "config.yml", header = {
Expand Down Expand Up @@ -70,6 +71,8 @@ public class LoginSecurityConfig extends AbstractConfig {
})
@ConfigKey(path="username.filter-special-chars")
private boolean filterSpecialChars = true;
@ConfigKey(path="username.filter-regex")
private String filterRegex = "[^a-zA-Z0-9_]";
@ConfigKey(path="username.min-length")
private int usernameMinLength = 3;
@ConfigKey(path="username.max-length")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
// Verify name
final String name = event.getName();
final LoginSecurityConfig config = LoginSecurity.getConfiguration();
if(config.isFilterSpecialChars() && !name.replaceAll("[^a-zA-Z0-9_]", "").equals(name)) {
if(config.isFilterSpecialChars() && !name.replaceAll(config.getFilterRegex(), "").equals(name)) {
event.setLoginResult(Result.KICK_OTHER);
event.setKickMessage("[LoginSecurity] " + translate(KICK_USERNAME_CHARS));
return;
Expand Down