This commit is contained in:
Xephi59 2015-12-30 23:57:44 +01:00
commit 7f1ce66fd0
4 changed files with 39 additions and 5 deletions

View File

@ -1,7 +1,8 @@
unknown_user: '&fПотребителя не е в БД'
unsafe_spawn: '&fТвоята локация когато излезе не беше безопасна, телепортиран си на Spawn!'
not_logged_in: '&cНе си влязъл!'
reg_voluntarily: '&fМоже да се регистрираш с тази команда:&n "/register парола парола"'
reg_voluntarily: '&fМоже да се регистрираш с тази команда:
"/register парола парола"'
usage_log: '&cКоманда: /login парола'
wrong_pwd: '&cГрешна парола!'
unregistered: '&cУспешно от-регистриран!'

View File

@ -1,7 +1,8 @@
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'
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>'
wrong_pwd: '&cContrasinal equivocado'
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!'
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_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.'
email_exists: '&cA recovery email was already sent! You can discard it and send a new one using the command below:'

View File

@ -3,6 +3,7 @@ package messages;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.util.StringUtils;
import utils.FileUtils;
import java.util.ArrayList;
@ -69,7 +70,7 @@ public class MessageFileVerifier {
private void verifyKeys() {
List<MessageKey> messageKeys = getAllMessageKeys();
List<String> fileLines = FileUtils.readLinesFromFile(messagesFile);
List<String> fileLines = readFileLines();
for (String line : fileLines) {
// Skip comments and empty lines
if (!line.startsWith("#") && !line.trim().isEmpty()) {
@ -138,4 +139,34 @@ public class MessageFileVerifier {
private static List<MessageKey> getAllMessageKeys() {
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));
}
}

View File

@ -53,7 +53,7 @@ public class TagReplacer {
}
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);
if (!matcher.find()) {