Check if unique name contains chars not supported in regex expression (#1998)

* Check if unique name contains chars not supported in regex expression
Cannot start, contain, or end with special char, cannot contain any numbers.
Can only contain - for word separation

* Negation fix
This commit is contained in:
Galić Mijo 2022-07-06 19:21:36 +02:00 committed by GitHub
parent db323390cf
commit cbd063c9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 23 additions and 0 deletions

View File

@ -51,6 +51,13 @@ public class NamePrompt extends StringPrompt {
if (ChatColor.stripColor(input).length() > 32) {
context.getForWhom().sendRawMessage("Too long");
return this;
/*Check if unique name contains chars not supported in regex expression
Cannot start, contain, or end with special char, cannot contain any numbers.
Can only contain - for word separation*/
}else if (!ChatColor.stripColor(input).matches("^[a-zA-Z]+(?:-[a-zA-Z]+)*$")) {
context.getForWhom().sendRawMessage(user.getTranslation("commands.admin.blueprint.management.name.invalid-char-in-unique-name"));
return this;
}
if (bb == null || !bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)) {
// Make a uniqueid

View File

@ -340,6 +340,7 @@ commands:
prompt: Napiš jméno, nebo 'quit' ke zrušení
too-long: '&c Příliš dlouhé'
pick-a-unique-name: Prosím, zvol více jedinečný název
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Povedlo se!
conversation-prefix: '>'
description:

View File

@ -391,6 +391,7 @@ commands:
prompt: Gib einen Namen ein, oder 'quit' zum Beenden
too-long: "&c Zu lang"
pick-a-unique-name: Wähle bitte einen eindeutigeren Namen
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Erfolg!
conversation-prefix: ">"
description:

View File

@ -367,6 +367,7 @@ commands:
prompt: "Enter a name, or 'quit' to quit"
too-long: "&c Too long"
pick-a-unique-name: "Please pick a more unique name"
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: "Success!"
conversation-prefix: ">"
description:

View File

@ -362,6 +362,7 @@ commands:
prompt: Ingrese un nombre o 'quit' para salir
too-long: "&cDemasiado largo"
pick-a-unique-name: Elige un nombre más exclusivo
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: "¡Éxito!"
conversation-prefix: ">"
description:

View File

@ -86,6 +86,7 @@ commands:
name:
conversation-prefix: ">"
pick-a-unique-name: Veuillez choisir un nom plus unique
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
prompt: Entrez un nom, ou "quitter" pour quitter
quit: quitter
success: Succès !

View File

@ -78,6 +78,7 @@ commands:
name:
conversation-prefix: ">"
pick-a-unique-name: Scegli un nome unico
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
prompt: Inserisci un nome, o 'quit' per uscire
success: Successo!
too-long: "&cTroppo lungo"

View File

@ -328,6 +328,7 @@ commands:
prompt: 名前を入力するか、「quit」で終了します
too-long: "&c長すぎる"
pick-a-unique-name: よりユニークな名前を選んでください
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: 成功!
conversation-prefix: ">"
description:

View File

@ -337,6 +337,7 @@ commands:
prompt: 이름을 입력하세요, quit를 입력하여 종료할수 있습니다
too-long: "&c 너무 깁니다"
pick-a-unique-name: 더 독특한 이름을 선택하십시오
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: 완료!
conversation-prefix: ">"
description:

View File

@ -90,6 +90,7 @@ commands:
name:
conversation-prefix: ">"
pick-a-unique-name: Lūdzu izvēlies unikālu nosaukumu
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
prompt: Ieraksti vārdu vai 'iziet', lai izietu
quit: iziet
success: Izdevās!

View File

@ -393,6 +393,7 @@ commands:
prompt: Voer een naam in of 'quit' om te stoppen
too-long: "&c Te lang"
pick-a-unique-name: Kies een meer unieke naam
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Succes!
conversation-prefix: ">"
description:

View File

@ -345,6 +345,7 @@ commands:
prompt: Wprowadź nazwę, lub wpisz 'wyjdź', by wyjść
too-long: '&cNazwa zbyt długa'
pick-a-unique-name: Wybierz bardziej unikalną nazwę
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Sukces!
conversation-prefix: '>'
description:

View File

@ -354,6 +354,7 @@ commands:
prompt: Digite um nome, ou 'quit' para sair
too-long: '&c Muito comprido'
pick-a-unique-name: Por favor escolha um nome único
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Sucesso!
conversation-prefix: '>'
description:

View File

@ -373,6 +373,7 @@ commands:
prompt: Introduceți un nume sau „renunțați” pentru a renunța
too-long: "&c Prea mult"
pick-a-unique-name: Vă rugăm să alegeți un nume mai unic
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Succes!
conversation-prefix: ">"
description:

View File

@ -384,6 +384,7 @@ commands:
prompt: İsim gir ya da çıkmak için 'quit' yaz.
too-long: "&cÇok uzun."
pick-a-unique-name: Lütfen daha benzersiz bir ad seçin
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Başarılı!
conversation-prefix: ">"
description:

View File

@ -376,6 +376,7 @@ commands:
prompt: Enter a name, or 'quit' to quit
too-long: "&c Too long"
pick-a-unique-name: Please pick a more unique name
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: Success!
conversation-prefix: ">"
description:

View File

@ -367,6 +367,7 @@ commands:
prompt: "&e请输入新名称 或 “&b quit&e” 来退出编辑。"
too-long: "&c新名称太长了"
pick-a-unique-name: "&c这个名称已存在 请另选一个不同的名称!"
invalid-char-in-unique-name: "Unique name cannot contain, start, or end with special characters, neither contain number! "
success: "&a成功"
conversation-prefix: "&3> &r"
description: