#1467 Change message keys and messages_en to new structure

This commit is contained in:
ljacqu 2018-01-29 20:56:30 +01:00
parent dfe47066cd
commit f714e9d564
4 changed files with 257 additions and 197 deletions

View File

@ -6,298 +6,298 @@ package fr.xephi.authme.message;
public enum MessageKey { public enum MessageKey {
/** In order to use this command you must be authenticated! */ /** In order to use this command you must be authenticated! */
DENIED_COMMAND("denied_command"), DENIED_COMMAND("error.denied_command"),
/** A player with the same IP is already in game! */ /** A player with the same IP is already in game! */
SAME_IP_ONLINE("same_ip_online"), SAME_IP_ONLINE("on_join_validation.same_ip_online"),
/** In order to chat you must be authenticated! */ /** In order to chat you must be authenticated! */
DENIED_CHAT("denied_chat"), DENIED_CHAT("error.denied_chat"),
/** AntiBot protection mode is enabled! You have to wait some minutes before joining the server. */ /** AntiBot protection mode is enabled! You have to wait some minutes before joining the server. */
KICK_ANTIBOT("kick_antibot"), KICK_ANTIBOT("antibot.kick_antibot"),
/** This user isn't registered! */ /** This user isn't registered! */
UNKNOWN_USER("unknown_user"), UNKNOWN_USER("error.unregistered_user"),
/** You're not logged in! */ /** You're not logged in! */
NOT_LOGGED_IN("not_logged_in"), NOT_LOGGED_IN("error.not_logged_in"),
/** Usage: /login <password> */ /** Usage: /login <password> */
USAGE_LOGIN("usage_log"), USAGE_LOGIN("login.command_usage"),
/** Wrong password! */ /** Wrong password! */
WRONG_PASSWORD("wrong_pwd"), WRONG_PASSWORD("login.wrong_password"),
/** Successfully unregistered! */ /** Successfully unregistered! */
UNREGISTERED_SUCCESS("unregistered"), UNREGISTERED_SUCCESS("unregister.success"),
/** In-game registration is disabled! */ /** In-game registration is disabled! */
REGISTRATION_DISABLED("reg_disabled"), REGISTRATION_DISABLED("registration.disabled"),
/** Logged-in due to Session Reconnection. */ /** Logged-in due to Session Reconnection. */
SESSION_RECONNECTION("valid_session"), SESSION_RECONNECTION("session.valid_session"),
/** Successful login! */ /** Successful login! */
LOGIN_SUCCESS("login"), LOGIN_SUCCESS("login.success"),
/** Your account isn't activated yet, please check your emails! */ /** Your account isn't activated yet, please check your emails! */
ACCOUNT_NOT_ACTIVATED("vb_nonActiv"), ACCOUNT_NOT_ACTIVATED("misc.account_not_activated"),
/** You already have registered this username! */ /** You already have registered this username! */
NAME_ALREADY_REGISTERED("user_regged"), NAME_ALREADY_REGISTERED("registration.name_taken"),
/** You don't have the permission to perform this action! */ /** You don't have the permission to perform this action! */
NO_PERMISSION("no_perm"), NO_PERMISSION("error.no_permission"),
/** An unexpected error occurred, please contact an administrator! */ /** An unexpected error occurred, please contact an administrator! */
ERROR("error"), ERROR("error.unexpected_error"),
/** Please, login with the command: /login <password> */ /** Please, login with the command: /login <password> */
LOGIN_MESSAGE("login_msg"), LOGIN_MESSAGE("login.login_request"),
/** Please, register to the server with the command: /register <password> <ConfirmPassword> */ /** Please, register to the server with the command: /register <password> <ConfirmPassword> */
REGISTER_MESSAGE("reg_msg"), REGISTER_MESSAGE("registration.register_request"),
/** You have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection! */ /** You have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection! */
MAX_REGISTER_EXCEEDED("max_reg", "%max_acc", "%reg_count", "%reg_names"), MAX_REGISTER_EXCEEDED("error.max_registration", "%max_acc", "%reg_count", "%reg_names"),
/** Usage: /register <password> <ConfirmPassword> */ /** Usage: /register <password> <ConfirmPassword> */
USAGE_REGISTER("usage_reg"), USAGE_REGISTER("registration.command_usage"),
/** Usage: /unregister <password> */ /** Usage: /unregister <password> */
USAGE_UNREGISTER("usage_unreg"), USAGE_UNREGISTER("unregister.command_usage"),
/** Password changed successfully! */ /** Password changed successfully! */
PASSWORD_CHANGED_SUCCESS("pwd_changed"), PASSWORD_CHANGED_SUCCESS("misc.password_changed"),
/** Passwords didn't match, check them again! */ /** Passwords didn't match, check them again! */
PASSWORD_MATCH_ERROR("password_error"), PASSWORD_MATCH_ERROR("password.match_error"),
/** You can't use your name as password, please choose another one... */ /** You can't use your name as password, please choose another one... */
PASSWORD_IS_USERNAME_ERROR("password_error_nick"), PASSWORD_IS_USERNAME_ERROR("password.name_in_password"),
/** The chosen password isn't safe, please choose another one... */ /** The chosen password isn't safe, please choose another one... */
PASSWORD_UNSAFE_ERROR("password_error_unsafe"), PASSWORD_UNSAFE_ERROR("password.unsafe_password"),
/** Your password contains illegal characters. Allowed chars: REG_EX */ /** Your password contains illegal characters. Allowed chars: %valid_chars */
PASSWORD_CHARACTERS_ERROR("password_error_chars", "REG_EX"), PASSWORD_CHARACTERS_ERROR("password.forbidden_characters", "%valid_chars"),
/** Your IP has been changed and your session data has expired! */ /** Your IP has been changed and your session data has expired! */
SESSION_EXPIRED("invalid_session"), SESSION_EXPIRED("session.invalid_session"),
/** Only registered users can join the server! Please visit http://example.com to register yourself! */ /** Only registered users can join the server! Please visit http://example.com to register yourself! */
MUST_REGISTER_MESSAGE("reg_only"), MUST_REGISTER_MESSAGE("registration.reg_only"),
/** You're already logged in! */ /** You're already logged in! */
ALREADY_LOGGED_IN_ERROR("logged_in"), ALREADY_LOGGED_IN_ERROR("error.logged_in"),
/** Logged out successfully! */ /** Logged out successfully! */
LOGOUT_SUCCESS("logout"), LOGOUT_SUCCESS("misc.logout"),
/** The same username is already playing on the server! */ /** The same username is already playing on the server! */
USERNAME_ALREADY_ONLINE_ERROR("same_nick"), USERNAME_ALREADY_ONLINE_ERROR("on_join_validation.same_nick_online"),
/** Successfully registered! */ /** Successfully registered! */
REGISTER_SUCCESS("registered"), REGISTER_SUCCESS("registration.success"),
/** Your password is too short or too long! Please try with another one! */ /** Your password is too short or too long! Please try with another one! */
INVALID_PASSWORD_LENGTH("pass_len"), INVALID_PASSWORD_LENGTH("password.wrong_length"),
/** Configuration and database have been reloaded correctly! */ /** Configuration and database have been reloaded correctly! */
CONFIG_RELOAD_SUCCESS("reload"), CONFIG_RELOAD_SUCCESS("misc.reload"),
/** Login timeout exceeded, you have been kicked from the server, please try again! */ /** Login timeout exceeded, you have been kicked from the server, please try again! */
LOGIN_TIMEOUT_ERROR("timeout"), LOGIN_TIMEOUT_ERROR("login.timeout_error"),
/** Usage: /changepassword <oldPassword> <newPassword> */ /** Usage: /changepassword <oldPassword> <newPassword> */
USAGE_CHANGE_PASSWORD("usage_changepassword"), USAGE_CHANGE_PASSWORD("misc.usage_change_password"),
/** Your username is either too short or too long! */ /** Your username is either too short or too long! */
INVALID_NAME_LENGTH("name_len"), INVALID_NAME_LENGTH("on_join_validation.name_length"),
/** Your username contains illegal characters. Allowed chars: REG_EX */ /** Your username contains illegal characters. Allowed chars: %valid_chars */
INVALID_NAME_CHARACTERS("regex", "REG_EX"), INVALID_NAME_CHARACTERS("on_join_validation.characters_in_name", "%valid_chars"),
/** Please add your email to your account with the command: /email add <yourEmail> <confirmEmail> */ /** Please add your email to your account with the command: /email add <yourEmail> <confirmEmail> */
ADD_EMAIL_MESSAGE("add_email"), ADD_EMAIL_MESSAGE("email.add_email_request"),
/** Forgot your password? Please use the command: /email recovery <yourEmail> */ /** Forgot your password? Please use the command: /email recovery <yourEmail> */
FORGOT_PASSWORD_MESSAGE("recovery_email"), FORGOT_PASSWORD_MESSAGE("recovery.forgot_password_hint"),
/** To login you have to solve a captcha code, please use the command: /captcha <theCaptcha> */ /** To login you have to solve a captcha code, please use the command: /captcha %captcha_code */
USAGE_CAPTCHA("usage_captcha", "<theCaptcha>"), USAGE_CAPTCHA("captcha.usage_captcha", "%captcha_code"),
/** Wrong captcha, please type "/captcha THE_CAPTCHA" into the chat! */ /** Wrong captcha, please type "/captcha %captcha_code" into the chat! */
CAPTCHA_WRONG_ERROR("wrong_captcha", "THE_CAPTCHA"), CAPTCHA_WRONG_ERROR("captcha.wrong_captcha", "%captcha_code"),
/** Captcha code solved correctly! */ /** Captcha code solved correctly! */
CAPTCHA_SUCCESS("valid_captcha"), CAPTCHA_SUCCESS("captcha.valid_captcha"),
/** To register you have to solve a captcha code first, please use the command: /captcha &lt;theCaptcha&gt; */ /** To register you have to solve a captcha code first, please use the command: /captcha %captcha_code */
CAPTCHA_FOR_REGISTRATION_REQUIRED("captcha_for_registration", "<theCaptcha>"), CAPTCHA_FOR_REGISTRATION_REQUIRED("captcha.captcha_for_registration", "%captcha_code"),
/** Valid captcha! You may now register with /register */ /** Valid captcha! You may now register with /register */
REGISTER_CAPTCHA_SUCCESS("register_captcha_valid"), REGISTER_CAPTCHA_SUCCESS("captcha.register_captcha_valid"),
/** A VIP player has joined the server when it was full! */ /** A VIP player has joined the server when it was full! */
KICK_FOR_VIP("kick_forvip"), KICK_FOR_VIP("error.kick_for_vip"),
/** The server is full, try again later! */ /** The server is full, try again later! */
KICK_FULL_SERVER("kick_fullserver"), KICK_FULL_SERVER("on_join_validation.kick_full_server"),
/** Usage: /email add &lt;email&gt; &lt;confirmEmail&gt; */ /** Usage: /email add &lt;email&gt; &lt;confirmEmail&gt; */
USAGE_ADD_EMAIL("usage_email_add"), USAGE_ADD_EMAIL("email.usage_email_add"),
/** Usage: /email change &lt;oldEmail&gt; &lt;newEmail&gt; */ /** Usage: /email change &lt;oldEmail&gt; &lt;newEmail&gt; */
USAGE_CHANGE_EMAIL("usage_email_change"), USAGE_CHANGE_EMAIL("email.usage_email_change"),
/** Usage: /email recovery &lt;Email&gt; */ /** Usage: /email recovery &lt;Email&gt; */
USAGE_RECOVER_EMAIL("usage_email_recovery"), USAGE_RECOVER_EMAIL("recovery.command_usage"),
/** Invalid new email, try again! */ /** Invalid new email, try again! */
INVALID_NEW_EMAIL("new_email_invalid"), INVALID_NEW_EMAIL("email.new_email_invalid"),
/** Invalid old email, try again! */ /** Invalid old email, try again! */
INVALID_OLD_EMAIL("old_email_invalid"), INVALID_OLD_EMAIL("email.old_email_invalid"),
/** Invalid email address, try again! */ /** Invalid email address, try again! */
INVALID_EMAIL("email_invalid"), INVALID_EMAIL("email.invalid"),
/** Email address successfully added to your account! */ /** Email address successfully added to your account! */
EMAIL_ADDED_SUCCESS("email_added"), EMAIL_ADDED_SUCCESS("email.added"),
/** Please confirm your email address! */ /** Please confirm your email address! */
CONFIRM_EMAIL_MESSAGE("email_confirm"), CONFIRM_EMAIL_MESSAGE("email.request_confirmation"),
/** Email address changed correctly! */ /** Email address changed correctly! */
EMAIL_CHANGED_SUCCESS("email_changed"), EMAIL_CHANGED_SUCCESS("email.changed"),
/** Your current email address is: %email */ /** Your current email address is: %email */
EMAIL_SHOW("email_show", "%email"), EMAIL_SHOW("email.email_show", "%email"),
/** You currently don't have email address associated with this account. */ /** You currently don't have email address associated with this account. */
SHOW_NO_EMAIL("show_no_email"), SHOW_NO_EMAIL("email.no_email_for_account"),
/** Recovery email sent successfully! Please check your email inbox! */ /** Recovery email sent successfully! Please check your email inbox! */
RECOVERY_EMAIL_SENT_MESSAGE("email_send"), RECOVERY_EMAIL_SENT_MESSAGE("recovery.email_sent"),
/** Your country is banned from this server! */ /** Your country is banned from this server! */
COUNTRY_BANNED_ERROR("country_banned"), COUNTRY_BANNED_ERROR("on_join_validation.country_banned"),
/** [AntiBotService] AntiBot enabled due to the huge number of connections! */ /** [AntiBotService] AntiBot enabled due to the huge number of connections! */
ANTIBOT_AUTO_ENABLED_MESSAGE("antibot_auto_enabled"), ANTIBOT_AUTO_ENABLED_MESSAGE("antibot.auto_enabled"),
/** [AntiBotService] AntiBot disabled after %m minutes! */ /** [AntiBotService] AntiBot disabled after %m minutes! */
ANTIBOT_AUTO_DISABLED_MESSAGE("antibot_auto_disabled", "%m"), ANTIBOT_AUTO_DISABLED_MESSAGE("antibot.auto_disabled", "%m"),
/** The email address is already being used */ /** The email address is already being used */
EMAIL_ALREADY_USED_ERROR("email_already_used"), EMAIL_ALREADY_USED_ERROR("email.already_used"),
/** Your secret code is %code. You can scan it from here %url */ /** Your secret code is %code. You can scan it from here %url */
TWO_FACTOR_CREATE("two_factor_create", "%code", "%url"), TWO_FACTOR_CREATE("misc.two_factor_create", "%code", "%url"),
/** You are not the owner of this account. Please choose another name! */ /** You are not the owner of this account. Please choose another name! */
NOT_OWNER_ERROR("not_owner_error"), NOT_OWNER_ERROR("on_join_validation.not_owner_error"),
/** You should join using username %valid, not %invalid. */ /** You should join using username %valid, not %invalid. */
INVALID_NAME_CASE("invalid_name_case", "%valid", "%invalid"), INVALID_NAME_CASE("on_join_validation.invalid_name_case", "%valid", "%invalid"),
/** You have been temporarily banned for failing to log in too many times. */ /** You have been temporarily banned for failing to log in too many times. */
TEMPBAN_MAX_LOGINS("tempban_max_logins"), TEMPBAN_MAX_LOGINS("error.tempban_max_logins"),
/** You own %count accounts: */ /** You own %count accounts: */
ACCOUNTS_OWNED_SELF("accounts_owned_self", "%count"), ACCOUNTS_OWNED_SELF("misc.accounts_owned_self", "%count"),
/** The player %name has %count accounts: */ /** The player %name has %count accounts: */
ACCOUNTS_OWNED_OTHER("accounts_owned_other", "%name", "%count"), ACCOUNTS_OWNED_OTHER("misc.accounts_owned_other", "%name", "%count"),
/** An admin just registered you; please log in again */ /** An admin just registered you; please log in again */
KICK_FOR_ADMIN_REGISTER("kicked_admin_registered"), KICK_FOR_ADMIN_REGISTER("registration.kicked_admin_registered"),
/** Error: not all required settings are set for sending emails. Please contact an admin. */ /** Error: not all required settings are set for sending emails. Please contact an admin. */
INCOMPLETE_EMAIL_SETTINGS("incomplete_email_settings"), INCOMPLETE_EMAIL_SETTINGS("email.incomplete_settings"),
/** The email could not be sent. Please contact an administrator. */ /** The email could not be sent. Please contact an administrator. */
EMAIL_SEND_FAILURE("email_send_failure"), EMAIL_SEND_FAILURE("email.send_failure"),
/** A recovery code to reset your password has been sent to your email. */ /** A recovery code to reset your password has been sent to your email. */
RECOVERY_CODE_SENT("recovery_code_sent"), RECOVERY_CODE_SENT("recovery.code.code_sent"),
/** The recovery code is not correct! You have %count tries remaining. */ /** The recovery code is not correct! You have %count tries remaining. */
INCORRECT_RECOVERY_CODE("recovery_code_incorrect", "%count"), INCORRECT_RECOVERY_CODE("recovery.code.incorrect", "%count"),
/** /**
* You have exceeded the maximum number of attempts to enter the recovery code. * You have exceeded the maximum number of attempts to enter the recovery code.
* Use "/email recovery [email]" to generate a new one. * Use "/email recovery [email]" to generate a new one.
*/ */
RECOVERY_TRIES_EXCEEDED("recovery_tries_exceeded"), RECOVERY_TRIES_EXCEEDED("recovery.code.tries_exceeded"),
/** Recovery code entered correctly! */ /** Recovery code entered correctly! */
RECOVERY_CODE_CORRECT("recovery_code_correct"), RECOVERY_CODE_CORRECT("recovery.code.correct"),
/** Please use the command /email setpassword to change your password immediately. */ /** Please use the command /email setpassword to change your password immediately. */
RECOVERY_CHANGE_PASSWORD("recovery_change_password"), RECOVERY_CHANGE_PASSWORD("recovery.code.change_password"),
/** You cannot change your password using this command anymore. */ /** You cannot change your password using this command anymore. */
CHANGE_PASSWORD_EXPIRED("change_password_expired"), CHANGE_PASSWORD_EXPIRED("email.change_password_expired"),
/** An email was already sent recently. You must wait %time before you can send a new one. */ /** An email was already sent recently. You must wait %time before you can send a new one. */
EMAIL_COOLDOWN_ERROR("email_cooldown_error", "%time"), EMAIL_COOLDOWN_ERROR("email.email_cooldown_error", "%time"),
/** /**
* The command you are trying to execute is sensitive and requires a verification! * The command you are trying to execute is sensitive and requires a verification!
* A verification code has been sent to your email, * A verification code has been sent to your email,
* run the command "/verification [code]" to verify your identity. * run the command "/verification [code]" to verify your identity.
*/ */
VERIFICATION_CODE_REQUIRED("verification_code_required"), VERIFICATION_CODE_REQUIRED("verification.code_required"),
/** Usage: /verification &lt;code&gt; */ /** Usage: /verification &lt;code&gt; */
USAGE_VERIFICATION_CODE("usage_verification_code"), USAGE_VERIFICATION_CODE("verification.command_usage"),
/** Incorrect code, please type "/verification &lt;code&gt;" into the chat! */ /** Incorrect code, please type "/verification &lt;code&gt;" into the chat! */
INCORRECT_VERIFICATION_CODE("incorrect_verification_code"), INCORRECT_VERIFICATION_CODE("verification.incorrect_code"),
/** /**
* Your identity has been verified! * Your identity has been verified!
* You can now execute every sensitive command within the current session! * You can now execute every sensitive command within the current session!
*/ */
VERIFICATION_CODE_VERIFIED("verification_code_verified"), VERIFICATION_CODE_VERIFIED("verification.success"),
/** /**
* You can already execute every sensitive command within the current session! * You can already execute every sensitive command within the current session!
*/ */
VERIFICATION_CODE_ALREADY_VERIFIED("verification_code_already_verified"), VERIFICATION_CODE_ALREADY_VERIFIED("verification.already_verified"),
/** Your code has expired! Execute another sensitive command to get a new code! */ /** Your code has expired! Execute another sensitive command to get a new code! */
VERIFICATION_CODE_EXPIRED("verification_code_expired"), VERIFICATION_CODE_EXPIRED("verification.code_expired"),
/** To verify your identity you need to link an email address with your account! */ /** To verify your identity you need to link an email address with your account! */
VERIFICATION_CODE_EMAIL_NEEDED("verification_code_email_needed"), VERIFICATION_CODE_EMAIL_NEEDED("verification.email_needed"),
/** second */ /** second */
SECOND("second"), SECOND("time.second"),
/** seconds */ /** seconds */
SECONDS("seconds"), SECONDS("time.seconds"),
/** minute */ /** minute */
MINUTE("minute"), MINUTE("time.minute"),
/** minutes */ /** minutes */
MINUTES("minutes"), MINUTES("time.minutes"),
/** hour */ /** hour */
HOUR("hour"), HOUR("time.hour"),
/** hours */ /** hours */
HOURS("hours"), HOURS("time.hours"),
/** day */ /** day */
DAY("day"), DAY("time.day"),
/** days */ /** days */
DAYS("days"); DAYS("time.days");
private String key; private String key;

View File

@ -6,6 +6,8 @@ import fr.xephi.authme.message.MessageKey;
import java.util.Map; import java.util.Map;
import static com.google.common.collect.ImmutableMap.of;
/** /**
* Migrates message files from the old keys (before 5.5) to the new ones. * Migrates message files from the old keys (before 5.5) to the new ones.
* *
@ -13,6 +15,15 @@ import java.util.Map;
*/ */
final class OldMessageKeysMigrater { final class OldMessageKeysMigrater {
private static final Map<MessageKey, Map<String, String>> PLACEHOLDER_REPLACEMENTS =
ImmutableMap.<MessageKey, Map<String, String>>builder()
.put(MessageKey.PASSWORD_CHARACTERS_ERROR, of("REG_EX", "%valid_chars"))
.put(MessageKey.INVALID_NAME_CHARACTERS, of("REG_EX", "%valid_chars"))
.put(MessageKey.USAGE_CAPTCHA, of("<theCaptcha>", "%captcha_code"))
.put(MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, of("<theCaptcha>", "%captcha_code"))
.put(MessageKey.CAPTCHA_WRONG_ERROR, of("THE_CAPTCHA", "%captcha_code"))
.build();
private static final Map<MessageKey, String> KEYS_TO_OLD_PATH = ImmutableMap.<MessageKey, String>builder() private static final Map<MessageKey, String> KEYS_TO_OLD_PATH = ImmutableMap.<MessageKey, String>builder()
.put(MessageKey.DENIED_COMMAND, "denied_command") .put(MessageKey.DENIED_COMMAND, "denied_command")
.put(MessageKey.SAME_IP_ONLINE, "same_ip_online") .put(MessageKey.SAME_IP_ONLINE, "same_ip_online")
@ -122,19 +133,33 @@ final class OldMessageKeysMigrater {
static boolean migrateOldPaths(PropertyResource resource) { static boolean migrateOldPaths(PropertyResource resource) {
boolean wasPropertyMoved = false; boolean wasPropertyMoved = false;
for (Map.Entry<MessageKey, String> migrationEntry : KEYS_TO_OLD_PATH.entrySet()) { for (Map.Entry<MessageKey, String> migrationEntry : KEYS_TO_OLD_PATH.entrySet()) {
wasPropertyMoved |= moveIfApplicable(resource, migrationEntry.getKey().getKey(), migrationEntry.getValue()); wasPropertyMoved |= moveIfApplicable(resource, migrationEntry.getKey(), migrationEntry.getValue());
} }
return wasPropertyMoved; return wasPropertyMoved;
} }
private static boolean moveIfApplicable(PropertyResource resource, String newPath, String oldPath) { private static boolean moveIfApplicable(PropertyResource resource, MessageKey messageKey, String oldPath) {
if (resource.getString(newPath) == null) { if (resource.getString(messageKey.getKey()) == null) {
String textAtOldPath = resource.getString(oldPath); String textAtOldPath = resource.getString(oldPath);
if (textAtOldPath != null) { if (textAtOldPath != null) {
resource.setValue(newPath, textAtOldPath); textAtOldPath = replaceOldPlaceholders(messageKey, textAtOldPath);
resource.setValue(messageKey.getKey(), textAtOldPath);
return true; return true;
} }
} }
return false; return false;
} }
private static String replaceOldPlaceholders(MessageKey key, String text) {
Map<String, String> replacements = PLACEHOLDER_REPLACEMENTS.get(key);
if (replacements == null) {
return text;
}
String newText = text;
for (Map.Entry<String, String> replacement : replacements.entrySet()) {
text = text.replace(replacement.getKey(), replacement.getValue());
}
return newText;
}
} }

View File

@ -1,117 +1,135 @@
# Registration # Registration
reg_msg: '&3Please, register to the server with the command: /register <password> <ConfirmPassword>' registration:
usage_reg: '&cUsage: /register <password> <ConfirmPassword>' register_request: '&3Please, register to the server with the command: /register <password> <ConfirmPassword>'
reg_only: '&4Only registered users can join the server! Please visit http://example.com to register yourself!' command_usage: '&cUsage: /register <password> <ConfirmPassword>'
kicked_admin_registered: 'An admin just registered you; please log in again' reg_only: '&4Only registered users can join the server! Please visit http://example.com to register yourself!'
registered: '&2Successfully registered!' kicked_admin_registered: 'An admin just registered you; please log in again'
reg_disabled: '&cIn-game registration is disabled!' success: '&2Successfully registered!'
user_regged: '&cYou already have registered this username!' disabled: '&cIn-game registration is disabled!'
name_taken: '&cYou already have registered this username!'
# Password errors on registration # Password errors on registration
password_error: '&cPasswords didn''t match, check them again!' password:
password_error_nick: '&cYou can''t use your name as password, please choose another one...' match_error: '&cPasswords didn''t match, check them again!'
password_error_unsafe: '&cThe chosen password isn''t safe, please choose another one...' name_in_password: '&cYou can''t use your name as password, please choose another one...'
password_error_chars: '&4Your password contains illegal characters. Allowed chars: REG_EX' unsafe_password: '&cThe chosen password isn''t safe, please choose another one...'
pass_len: '&cYour password is too short or too long! Please try with another one!' forbidden_characters: '&4Your password contains illegal characters. Allowed chars: %valid_chars'
wrong_length: '&cYour password is too short or too long! Please try with another one!'
# Login # Login
usage_log: '&cUsage: /login <password>' login:
wrong_pwd: '&cWrong password!' command_usage: '&cUsage: /login <password>'
login: '&2Successful login!' wrong_password: '&cWrong password!'
login_msg: '&cPlease, login with the command: /login <password>' success: '&2Successful login!'
timeout: '&4Login timeout exceeded, you have been kicked from the server, please try again!' login_request: '&cPlease, login with the command: /login <password>'
timeout_error: '&4Login timeout exceeded, you have been kicked from the server, please try again!'
# Errors # Errors
unknown_user: '&cThis user isn''t registered!' error:
denied_command: '&cIn order to use this command you must be authenticated!' unregistered_user: '&cThis user isn''t registered!'
denied_chat: '&cIn order to chat you must be authenticated!' denied_command: '&cIn order to use this command you must be authenticated!'
not_logged_in: '&cYou''re not logged in!' denied_chat: '&cIn order to chat you must be authenticated!'
tempban_max_logins: '&cYou have been temporarily banned for failing to log in too many times.' not_logged_in: '&cYou''re not logged in!'
max_reg: '&cYou have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection!' tempban_max_logins: '&cYou have been temporarily banned for failing to log in too many times.'
no_perm: '&4You don''t have the permission to perform this action!' max_registration: '&cYou have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection!'
error: '&4An unexpected error occurred, please contact an administrator!' no_permission: '&4You don''t have the permission to perform this action!'
kick_forvip: '&3A VIP player has joined the server when it was full!' unexpected_error: '&4An unexpected error occurred, please contact an administrator!'
kick_for_vip: '&3A VIP player has joined the server when it was full!'
logged_in: '&cYou''re already logged in!'
# AntiBot # AntiBot
kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' antibot:
antibot_auto_enabled: '&4[AntiBotService] AntiBot enabled due to the huge number of connections!' kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.'
antibot_auto_disabled: '&2[AntiBotService] AntiBot disabled after %m minutes!' auto_enabled: '&4[AntiBotService] AntiBot enabled due to the huge number of connections!'
auto_disabled: '&2[AntiBotService] AntiBot disabled after %m minutes!'
unregister:
success: '&cSuccessfully unregistered!'
command_usage: '&cUsage: /unregister <password>'
# Other messages # Other messages
unregistered: '&cSuccessfully unregistered!' misc:
accounts_owned_self: 'You own %count accounts:' accounts_owned_self: 'You own %count accounts:'
accounts_owned_other: 'The player %name has %count accounts:' accounts_owned_other: 'The player %name has %count accounts:'
two_factor_create: '&2Your secret code is %code. You can scan it from here %url' two_factor_create: '&2Your secret code is %code. You can scan it from here %url'
recovery_code_sent: 'A recovery code to reset your password has been sent to your email.' account_not_activated: '&cYour account isn''t activated yet, please check your emails!'
recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.' password_changed: '&2Password changed successfully!'
recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.' logout: '&2Logged out successfully!'
recovery_code_correct: 'Recovery code entered correctly!' reload: '&2Configuration and database have been reloaded correctly!'
recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.' usage_change_password: '&cUsage: /changepassword <oldPassword> <newPassword>'
vb_nonActiv: '&cYour account isn''t activated yet, please check your emails!'
usage_unreg: '&cUsage: /unregister <password>'
pwd_changed: '&2Password changed successfully!'
logged_in: '&cYou''re already logged in!'
logout: '&2Logged out successfully!'
reload: '&2Configuration and database have been reloaded correctly!'
usage_changepassword: '&cUsage: /changepassword <oldPassword> <newPassword>'
# Session messages # Session messages
invalid_session: '&cYour IP has been changed and your session data has expired!' session:
valid_session: '&2Logged-in due to Session Reconnection.' invalid_session: '&cYour IP has been changed and your session data has expired!'
valid_session: '&2Logged-in due to Session Reconnection.'
# Error messages when joining # Error messages when joining
name_len: '&4Your username is either too short or too long!' on_join_validation:
regex: '&4Your username contains illegal characters. Allowed chars: REG_EX' name_length: '&4Your username is either too short or too long!'
country_banned: '&4Your country is banned from this server!' characters_in_name: '&4Your username contains illegal characters. Allowed chars: %valid_chars'
not_owner_error: 'You are not the owner of this account. Please choose another name!' country_banned: '&4Your country is banned from this server!'
kick_fullserver: '&4The server is full, try again later!' not_owner_error: 'You are not the owner of this account. Please choose another name!'
same_nick: '&4The same username is already playing on the server!' kick_full_server: '&4The server is full, try again later!'
invalid_name_case: 'You should join using username %valid, not %invalid.' same_nick_online: '&4The same username is already playing on the server!'
same_ip_online: 'A player with the same IP is already in game!' invalid_name_case: 'You should join using username %valid, not %invalid.'
same_ip_online: 'A player with the same IP is already in game!'
# Email # Email
usage_email_add: '&cUsage: /email add <email> <confirmEmail>' email:
usage_email_change: '&cUsage: /email change <oldEmail> <newEmail>' usage_email_add: '&cUsage: /email add <email> <confirmEmail>'
usage_email_recovery: '&cUsage: /email recovery <Email>' usage_email_change: '&cUsage: /email change <oldEmail> <newEmail>'
new_email_invalid: '&cInvalid new email, try again!' new_email_invalid: '&cInvalid new email, try again!'
old_email_invalid: '&cInvalid old email, try again!' old_email_invalid: '&cInvalid old email, try again!'
email_invalid: '&cInvalid email address, try again!' invalid: '&cInvalid email address, try again!'
email_added: '&2Email address successfully added to your account!' added: '&2Email address successfully added to your account!'
email_confirm: '&cPlease confirm your email address!' request_confirmation: '&cPlease confirm your email address!'
email_changed: '&2Email address changed correctly!' changed: '&2Email address changed correctly!'
email_send: '&2Recovery email sent successfully! Please check your email inbox!' email_show: '&2Your current email address is: &f%email'
email_show: '&2Your current email address is: &f%email' incomplete_settings: 'Error: not all required settings are set for sending emails. Please contact an admin.'
incomplete_email_settings: 'Error: not all required settings are set for sending emails. Please contact an admin.' already_used: '&4The email address is already being used'
email_already_used: '&4The email address is already being used' send_failure: 'The email could not be sent. Please contact an administrator.'
email_send_failure: 'The email could not be sent. Please contact an administrator.' no_email_for_account: '&2You currently don''t have email address associated with this account.'
show_no_email: '&2You currently don''t have email address associated with this account.' add_email_request: '&3Please add your email to your account with the command: /email add <yourEmail> <confirmEmail>'
add_email: '&3Please add your email to your account with the command: /email add <yourEmail> <confirmEmail>' change_password_expired: 'You cannot change your password using this command anymore.'
recovery_email: '&3Forgot your password? Please use the command: /email recovery <yourEmail>' email_cooldown_error: '&cAn email was already sent recently. You must wait %time before you can send a new one.'
change_password_expired: 'You cannot change your password using this command anymore.'
email_cooldown_error: '&cAn email was already sent recently. You must wait %time before you can send a new one.' # Password recovery by email
recovery:
forgot_password_hint: '&3Forgot your password? Please use the command: /email recovery <yourEmail>'
command_usage: '&cUsage: /email recovery <Email>'
email_sent: '&2Recovery email sent successfully! Please check your email inbox!'
code:
code_sent: 'A recovery code to reset your password has been sent to your email.'
incorrect: 'The recovery code is not correct! You have %count tries remaining.'
tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
correct: 'Recovery code entered correctly!'
change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
# Captcha # Captcha
usage_captcha: '&3To log in you have to solve a captcha code, please use the command: /captcha <theCaptcha>' captcha:
wrong_captcha: '&cWrong captcha, please type "/captcha THE_CAPTCHA" into the chat!' usage_captcha: '&3To log in you have to solve a captcha code, please use the command: /captcha %captcha_code'
valid_captcha: '&2Captcha code solved correctly!' wrong_captcha: '&cWrong captcha, please type "/captcha %captcha_code" into the chat!'
captcha_for_registration: 'To register you have to solve a captcha first, please use the command: /captcha <theCaptcha>' valid_captcha: '&2Captcha code solved correctly!'
register_captcha_valid: '&2Valid captcha! You may now register with /register' captcha_for_registration: 'To register you have to solve a captcha first, please use the command: /captcha %captcha_code'
register_captcha_valid: '&2Valid captcha! You may now register with /register'
# Verification code # Verification code
verification_code_required: '&3This command is sensitive and requires an email verification! Check your inbox and follow the email''s instructions.' verification:
usage_verification_code: '&cUsage: /verification <code>' code_required: '&3This command is sensitive and requires an email verification! Check your inbox and follow the email''s instructions.'
incorrect_verification_code: '&cIncorrect code, please type "/verification <code>" into the chat, using the code you received by email' command_usage: '&cUsage: /verification <code>'
verification_code_verified: '&2Your identity has been verified! You can now execute all commands within the current session!' incorrect_code: '&cIncorrect code, please type "/verification <code>" into the chat, using the code you received by email'
verification_code_already_verified: '&2You can already execute every sensitive command within the current session!' success: '&2Your identity has been verified! You can now execute all commands within the current session!'
verification_code_expired: '&3Your code has expired! Execute another sensitive command to get a new code!' already_verified: '&2You can already execute every sensitive command within the current session!'
verification_code_email_needed: '&3To verify your identity you need to link an email address with your account!!' code_expired: '&3Your code has expired! Execute another sensitive command to get a new code!'
email_needed: '&3To verify your identity you need to link an email address with your account!!'
# Time units # Time units
second: 'second' time:
seconds: 'seconds' second: 'second'
minute: 'minute' seconds: 'seconds'
minutes: 'minutes' minute: 'minute'
hour: 'hour' minutes: 'minutes'
hours: 'hours' hour: 'hour'
day: 'day' hours: 'hours'
days: 'days' day: 'day'
days: 'days'

View File

@ -3,9 +3,12 @@ package fr.xephi.authme.message;
import fr.xephi.authme.util.StringUtils; import fr.xephi.authme.util.StringUtils;
import org.junit.Test; import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
/** /**
@ -29,4 +32,18 @@ public class MessageKeyTest {
} }
} }
} }
@Test
public void shouldHaveWellFormedPlaceholders() {
// given
MessageKey[] messageKeys = MessageKey.values();
// when / then
for (MessageKey messageKey : messageKeys) {
String[] tags = messageKey.getTags();
Arrays.stream(tags)
.forEach(tag -> assertThat("Tag '" + tag + "' corresponds to valid format for key '" + messageKey + "'",
tag, matchesPattern("^%[a-z_]+$")));
}
}
} }