mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-23 07:11:30 +01:00
Fix #321 Message verifier should understand line breaks
- Make messages verifier understand that indented lines belong to the same message
- Revert newline to &n replacements done in f5583f4
This commit is contained in:
parent
5354a6913f
commit
52222d98e0
@ -1,7 +1,8 @@
|
|||||||
unknown_user: '&fПотребителя не е в БД'
|
unknown_user: '&fПотребителя не е в БД'
|
||||||
unsafe_spawn: '&fТвоята локация когато излезе не беше безопасна, телепортиран си на Spawn!'
|
unsafe_spawn: '&fТвоята локация когато излезе не беше безопасна, телепортиран си на Spawn!'
|
||||||
not_logged_in: '&cНе си влязъл!'
|
not_logged_in: '&cНе си влязъл!'
|
||||||
reg_voluntarily: '&fМоже да се регистрираш с тази команда:&n "/register парола парола"'
|
reg_voluntarily: '&fМоже да се регистрираш с тази команда:
|
||||||
|
"/register парола парола"'
|
||||||
usage_log: '&cКоманда: /login парола'
|
usage_log: '&cКоманда: /login парола'
|
||||||
wrong_pwd: '&cГрешна парола!'
|
wrong_pwd: '&cГрешна парола!'
|
||||||
unregistered: '&cУспешно от-регистриран!'
|
unregistered: '&cУспешно от-регистриран!'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
unknown_user: '&fO usuario non está na base de datos'
|
unknown_user: '&fO usuario non está na base de datos'
|
||||||
unsafe_spawn: '&fA localización dende a que saíches era insegura, teletransportándote ao spawn do mundo'
|
unsafe_spawn: '&fA localización dende a que saíches era insegura, teletransportándote ao spawn do mundo'
|
||||||
not_logged_in: '&cNon te identificaches!'
|
not_logged_in: '&cNon te identificaches!'
|
||||||
reg_voluntarily: '&fPodes rexistrar o teu nome no servidor co comando "/register <contrasinal> <confirmarContrasinal>"'
|
reg_voluntarily: '&fPodes rexistrar o teu nome no servidor co comando
|
||||||
|
"/register <contrasinal> <confirmarContrasinal>"'
|
||||||
usage_log: '&cUso: /login <contrasinal>'
|
usage_log: '&cUso: /login <contrasinal>'
|
||||||
wrong_pwd: '&cContrasinal equivocado'
|
wrong_pwd: '&cContrasinal equivocado'
|
||||||
unregistered: '&cFeito! Xa non estás rexistrado!'
|
unregistered: '&cFeito! Xa non estás rexistrado!'
|
||||||
@ -54,6 +55,7 @@ email_changed: '[AuthMe] Cambiouse o correo!'
|
|||||||
email_send: '[AuthMe] Enviouse o correo de confirmación!'
|
email_send: '[AuthMe] Enviouse o correo de confirmación!'
|
||||||
country_banned: 'O teu país está bloqueado neste servidor'
|
country_banned: 'O teu país está bloqueado neste servidor'
|
||||||
antibot_auto_enabled: '[AuthMe] AntiBotMod conectouse automáticamente debido a conexións masivas!'
|
antibot_auto_enabled: '[AuthMe] AntiBotMod conectouse automáticamente debido a conexións masivas!'
|
||||||
antibot_auto_disabled: '[AuthMe] AntiBotMod desactivouse automáticamente despois de %m minutos,&n esperemos que a invasión se detivera'
|
antibot_auto_disabled: '[AuthMe] AntiBotMod desactivouse automáticamente despois de %m minutos,
|
||||||
|
esperemos que a invasión se detivera'
|
||||||
kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.'
|
kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.'
|
||||||
email_exists: '&cA recovery email was already sent! You can discard it and send a new one using the command below:'
|
email_exists: '&cA recovery email was already sent! You can discard it and send a new one using the command below:'
|
||||||
|
@ -3,6 +3,7 @@ package messages;
|
|||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import utils.FileUtils;
|
import utils.FileUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -69,7 +70,7 @@ public class MessageFileVerifier {
|
|||||||
|
|
||||||
private void verifyKeys() {
|
private void verifyKeys() {
|
||||||
List<MessageKey> messageKeys = getAllMessageKeys();
|
List<MessageKey> messageKeys = getAllMessageKeys();
|
||||||
List<String> fileLines = FileUtils.readLinesFromFile(messagesFile);
|
List<String> fileLines = readFileLines();
|
||||||
for (String line : fileLines) {
|
for (String line : fileLines) {
|
||||||
// Skip comments and empty lines
|
// Skip comments and empty lines
|
||||||
if (!line.startsWith("#") && !line.trim().isEmpty()) {
|
if (!line.startsWith("#") && !line.trim().isEmpty()) {
|
||||||
@ -138,4 +139,34 @@ public class MessageFileVerifier {
|
|||||||
private static List<MessageKey> getAllMessageKeys() {
|
private static List<MessageKey> getAllMessageKeys() {
|
||||||
return new ArrayList<>(Arrays.asList(MessageKey.values()));
|
return new ArrayList<>(Arrays.asList(MessageKey.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read all lines from the messages file and skip empty lines and comment lines.
|
||||||
|
* This method appends lines starting with two spaces to the previously read line,
|
||||||
|
* akin to a YAML parser.
|
||||||
|
*/
|
||||||
|
private List<String> readFileLines() {
|
||||||
|
String[] rawLines = FileUtils.readFromFile(messagesFile).split("\\n");
|
||||||
|
List<String> lines = new ArrayList<>();
|
||||||
|
for (String line : rawLines) {
|
||||||
|
// Skip comments and empty lines
|
||||||
|
if (!line.startsWith("#") && !StringUtils.isEmpty(line)) {
|
||||||
|
// Line is indented, i.e. it needs to be appended to the previous line
|
||||||
|
if (line.startsWith(" ")) {
|
||||||
|
appendToLastElement(lines, line.substring(1));
|
||||||
|
} else {
|
||||||
|
lines.add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void appendToLastElement(List<String> list, String text) {
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
throw new IllegalStateException("List cannot be empty!");
|
||||||
|
}
|
||||||
|
int lastIndex = list.size() - 1;
|
||||||
|
list.set(lastIndex, list.get(lastIndex).concat(text));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class TagReplacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String replaceOptionalTag(String text, String tagName, String tagValue) {
|
private static String replaceOptionalTag(String text, String tagName, String tagValue) {
|
||||||
Pattern regex = Pattern.compile("\\[" + tagName + "\\](.*?)\\[/" + tagName + "\\]", Pattern.DOTALL);
|
Pattern regex = Pattern.compile("\\[" + tagName + "](.*?)\\[/" + tagName + "]", Pattern.DOTALL);
|
||||||
Matcher matcher = regex.matcher(text);
|
Matcher matcher = regex.matcher(text);
|
||||||
|
|
||||||
if (!matcher.find()) {
|
if (!matcher.find()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user