diff --git a/src/main/java/fr/xephi/authme/message/MessageKey.java b/src/main/java/fr/xephi/authme/message/MessageKey.java index 43963dcb8..b6367c5b1 100644 --- a/src/main/java/fr/xephi/authme/message/MessageKey.java +++ b/src/main/java/fr/xephi/authme/message/MessageKey.java @@ -6,298 +6,298 @@ package fr.xephi.authme.message; public enum MessageKey { /** 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! */ - SAME_IP_ONLINE("same_ip_online"), + SAME_IP_ONLINE("on_join_validation.same_ip_online"), /** 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. */ - KICK_ANTIBOT("kick_antibot"), + KICK_ANTIBOT("antibot.kick_antibot"), /** This user isn't registered! */ - UNKNOWN_USER("unknown_user"), + UNKNOWN_USER("error.unregistered_user"), /** You're not logged in! */ - NOT_LOGGED_IN("not_logged_in"), + NOT_LOGGED_IN("error.not_logged_in"), /** Usage: /login <password> */ - USAGE_LOGIN("usage_log"), + USAGE_LOGIN("login.command_usage"), /** Wrong password! */ - WRONG_PASSWORD("wrong_pwd"), + WRONG_PASSWORD("login.wrong_password"), /** Successfully unregistered! */ - UNREGISTERED_SUCCESS("unregistered"), + UNREGISTERED_SUCCESS("unregister.success"), /** In-game registration is disabled! */ - REGISTRATION_DISABLED("reg_disabled"), + REGISTRATION_DISABLED("registration.disabled"), /** Logged-in due to Session Reconnection. */ - SESSION_RECONNECTION("valid_session"), + SESSION_RECONNECTION("session.valid_session"), /** Successful login! */ - LOGIN_SUCCESS("login"), + LOGIN_SUCCESS("login.success"), /** 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! */ - NAME_ALREADY_REGISTERED("user_regged"), + NAME_ALREADY_REGISTERED("registration.name_taken"), /** 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! */ - ERROR("error"), + ERROR("error.unexpected_error"), /** 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> */ - 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! */ - 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("usage_reg"), + USAGE_REGISTER("registration.command_usage"), /** Usage: /unregister <password> */ - USAGE_UNREGISTER("usage_unreg"), + USAGE_UNREGISTER("unregister.command_usage"), /** Password changed successfully! */ - PASSWORD_CHANGED_SUCCESS("pwd_changed"), + PASSWORD_CHANGED_SUCCESS("misc.password_changed"), /** 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... */ - 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... */ - PASSWORD_UNSAFE_ERROR("password_error_unsafe"), + PASSWORD_UNSAFE_ERROR("password.unsafe_password"), - /** Your password contains illegal characters. Allowed chars: REG_EX */ - PASSWORD_CHARACTERS_ERROR("password_error_chars", "REG_EX"), + /** Your password contains illegal characters. Allowed chars: %valid_chars */ + PASSWORD_CHARACTERS_ERROR("password.forbidden_characters", "%valid_chars"), /** 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! */ - MUST_REGISTER_MESSAGE("reg_only"), + MUST_REGISTER_MESSAGE("registration.reg_only"), /** You're already logged in! */ - ALREADY_LOGGED_IN_ERROR("logged_in"), + ALREADY_LOGGED_IN_ERROR("error.logged_in"), /** Logged out successfully! */ - LOGOUT_SUCCESS("logout"), + LOGOUT_SUCCESS("misc.logout"), /** 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! */ - REGISTER_SUCCESS("registered"), + REGISTER_SUCCESS("registration.success"), /** 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! */ - CONFIG_RELOAD_SUCCESS("reload"), + CONFIG_RELOAD_SUCCESS("misc.reload"), /** 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_CHANGE_PASSWORD("usage_changepassword"), + USAGE_CHANGE_PASSWORD("misc.usage_change_password"), /** 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 */ - INVALID_NAME_CHARACTERS("regex", "REG_EX"), + /** Your username contains illegal characters. Allowed chars: %valid_chars */ + 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> */ - ADD_EMAIL_MESSAGE("add_email"), + ADD_EMAIL_MESSAGE("email.add_email_request"), /** 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> */ - USAGE_CAPTCHA("usage_captcha", ""), + /** To login you have to solve a captcha code, please use the command: /captcha %captcha_code */ + USAGE_CAPTCHA("captcha.usage_captcha", "%captcha_code"), - /** Wrong captcha, please type "/captcha THE_CAPTCHA" into the chat! */ - CAPTCHA_WRONG_ERROR("wrong_captcha", "THE_CAPTCHA"), + /** Wrong captcha, please type "/captcha %captcha_code" into the chat! */ + CAPTCHA_WRONG_ERROR("captcha.wrong_captcha", "%captcha_code"), /** 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 <theCaptcha> */ - CAPTCHA_FOR_REGISTRATION_REQUIRED("captcha_for_registration", ""), + /** To register you have to solve a captcha code first, please use the command: /captcha %captcha_code */ + CAPTCHA_FOR_REGISTRATION_REQUIRED("captcha.captcha_for_registration", "%captcha_code"), /** 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! */ - KICK_FOR_VIP("kick_forvip"), + KICK_FOR_VIP("error.kick_for_vip"), /** The server is full, try again later! */ - KICK_FULL_SERVER("kick_fullserver"), + KICK_FULL_SERVER("on_join_validation.kick_full_server"), /** Usage: /email add <email> <confirmEmail> */ - USAGE_ADD_EMAIL("usage_email_add"), + USAGE_ADD_EMAIL("email.usage_email_add"), /** Usage: /email change <oldEmail> <newEmail> */ - USAGE_CHANGE_EMAIL("usage_email_change"), + USAGE_CHANGE_EMAIL("email.usage_email_change"), /** Usage: /email recovery <Email> */ - USAGE_RECOVER_EMAIL("usage_email_recovery"), + USAGE_RECOVER_EMAIL("recovery.command_usage"), /** 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("old_email_invalid"), + INVALID_OLD_EMAIL("email.old_email_invalid"), /** Invalid email address, try again! */ - INVALID_EMAIL("email_invalid"), + INVALID_EMAIL("email.invalid"), /** Email address successfully added to your account! */ - EMAIL_ADDED_SUCCESS("email_added"), + EMAIL_ADDED_SUCCESS("email.added"), /** Please confirm your email address! */ - CONFIRM_EMAIL_MESSAGE("email_confirm"), + CONFIRM_EMAIL_MESSAGE("email.request_confirmation"), /** Email address changed correctly! */ - EMAIL_CHANGED_SUCCESS("email_changed"), + EMAIL_CHANGED_SUCCESS("email.changed"), /** 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. */ - 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_MESSAGE("email_send"), + RECOVERY_EMAIL_SENT_MESSAGE("recovery.email_sent"), /** 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! */ - ANTIBOT_AUTO_ENABLED_MESSAGE("antibot_auto_enabled"), + ANTIBOT_AUTO_ENABLED_MESSAGE("antibot.auto_enabled"), /** [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 */ - 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 */ - 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! */ - NOT_OWNER_ERROR("not_owner_error"), + NOT_OWNER_ERROR("on_join_validation.not_owner_error"), /** 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. */ - TEMPBAN_MAX_LOGINS("tempban_max_logins"), + TEMPBAN_MAX_LOGINS("error.tempban_max_logins"), /** 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: */ - 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 */ - 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. */ - INCOMPLETE_EMAIL_SETTINGS("incomplete_email_settings"), + INCOMPLETE_EMAIL_SETTINGS("email.incomplete_settings"), /** 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. */ - RECOVERY_CODE_SENT("recovery_code_sent"), + RECOVERY_CODE_SENT("recovery.code.code_sent"), /** 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. * 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_CORRECT("recovery_code_correct"), + RECOVERY_CODE_CORRECT("recovery.code.correct"), /** 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. */ - 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. */ - 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! * A verification code has been sent to your email, * run the command "/verification [code]" to verify your identity. */ - VERIFICATION_CODE_REQUIRED("verification_code_required"), + VERIFICATION_CODE_REQUIRED("verification.code_required"), /** Usage: /verification <code> */ - USAGE_VERIFICATION_CODE("usage_verification_code"), + USAGE_VERIFICATION_CODE("verification.command_usage"), /** Incorrect code, please type "/verification <code>" into the chat! */ - INCORRECT_VERIFICATION_CODE("incorrect_verification_code"), + INCORRECT_VERIFICATION_CODE("verification.incorrect_code"), /** * Your identity has been verified! * 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! */ - 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! */ - 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! */ - VERIFICATION_CODE_EMAIL_NEEDED("verification_code_email_needed"), + VERIFICATION_CODE_EMAIL_NEEDED("verification.email_needed"), /** second */ - SECOND("second"), + SECOND("time.second"), /** seconds */ - SECONDS("seconds"), + SECONDS("time.seconds"), /** minute */ - MINUTE("minute"), + MINUTE("time.minute"), /** minutes */ - MINUTES("minutes"), + MINUTES("time.minutes"), /** hour */ - HOUR("hour"), + HOUR("time.hour"), /** hours */ - HOURS("hours"), + HOURS("time.hours"), /** day */ - DAY("day"), + DAY("time.day"), /** days */ - DAYS("days"); + DAYS("time.days"); private String key; diff --git a/src/main/java/fr/xephi/authme/message/updater/OldMessageKeysMigrater.java b/src/main/java/fr/xephi/authme/message/updater/OldMessageKeysMigrater.java index 002b299d9..d43b58afc 100644 --- a/src/main/java/fr/xephi/authme/message/updater/OldMessageKeysMigrater.java +++ b/src/main/java/fr/xephi/authme/message/updater/OldMessageKeysMigrater.java @@ -6,6 +6,8 @@ import fr.xephi.authme.message.MessageKey; 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. * @@ -13,6 +15,15 @@ import java.util.Map; */ final class OldMessageKeysMigrater { + private static final Map> PLACEHOLDER_REPLACEMENTS = + ImmutableMap.>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("", "%captcha_code")) + .put(MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, of("", "%captcha_code")) + .put(MessageKey.CAPTCHA_WRONG_ERROR, of("THE_CAPTCHA", "%captcha_code")) + .build(); + private static final Map KEYS_TO_OLD_PATH = ImmutableMap.builder() .put(MessageKey.DENIED_COMMAND, "denied_command") .put(MessageKey.SAME_IP_ONLINE, "same_ip_online") @@ -122,19 +133,33 @@ final class OldMessageKeysMigrater { static boolean migrateOldPaths(PropertyResource resource) { boolean wasPropertyMoved = false; for (Map.Entry migrationEntry : KEYS_TO_OLD_PATH.entrySet()) { - wasPropertyMoved |= moveIfApplicable(resource, migrationEntry.getKey().getKey(), migrationEntry.getValue()); + wasPropertyMoved |= moveIfApplicable(resource, migrationEntry.getKey(), migrationEntry.getValue()); } return wasPropertyMoved; } - private static boolean moveIfApplicable(PropertyResource resource, String newPath, String oldPath) { - if (resource.getString(newPath) == null) { + private static boolean moveIfApplicable(PropertyResource resource, MessageKey messageKey, String oldPath) { + if (resource.getString(messageKey.getKey()) == null) { String textAtOldPath = resource.getString(oldPath); if (textAtOldPath != null) { - resource.setValue(newPath, textAtOldPath); + textAtOldPath = replaceOldPlaceholders(messageKey, textAtOldPath); + resource.setValue(messageKey.getKey(), textAtOldPath); return true; } } return false; } + + private static String replaceOldPlaceholders(MessageKey key, String text) { + Map replacements = PLACEHOLDER_REPLACEMENTS.get(key); + if (replacements == null) { + return text; + } + + String newText = text; + for (Map.Entry replacement : replacements.entrySet()) { + text = text.replace(replacement.getKey(), replacement.getValue()); + } + return newText; + } } diff --git a/src/main/resources/messages/messages_en.yml b/src/main/resources/messages/messages_en.yml index 383ec9a80..f2aa1d44a 100644 --- a/src/main/resources/messages/messages_en.yml +++ b/src/main/resources/messages/messages_en.yml @@ -1,117 +1,135 @@ # Registration -reg_msg: '&3Please, register to the server with the command: /register ' -usage_reg: '&cUsage: /register ' -reg_only: '&4Only registered users can join the server! Please visit http://example.com to register yourself!' -kicked_admin_registered: 'An admin just registered you; please log in again' -registered: '&2Successfully registered!' -reg_disabled: '&cIn-game registration is disabled!' -user_regged: '&cYou already have registered this username!' +registration: + register_request: '&3Please, register to the server with the command: /register ' + command_usage: '&cUsage: /register ' + reg_only: '&4Only registered users can join the server! Please visit http://example.com to register yourself!' + kicked_admin_registered: 'An admin just registered you; please log in again' + success: '&2Successfully registered!' + disabled: '&cIn-game registration is disabled!' + name_taken: '&cYou already have registered this username!' # Password errors on registration -password_error: '&cPasswords didn''t match, check them again!' -password_error_nick: '&cYou can''t use your name as password, please choose another one...' -password_error_unsafe: '&cThe chosen password isn''t safe, please choose another one...' -password_error_chars: '&4Your password contains illegal characters. Allowed chars: REG_EX' -pass_len: '&cYour password is too short or too long! Please try with another one!' +password: + match_error: '&cPasswords didn''t match, check them again!' + name_in_password: '&cYou can''t use your name as password, please choose another one...' + unsafe_password: '&cThe chosen password isn''t safe, please choose 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 -usage_log: '&cUsage: /login ' -wrong_pwd: '&cWrong password!' -login: '&2Successful login!' -login_msg: '&cPlease, login with the command: /login ' -timeout: '&4Login timeout exceeded, you have been kicked from the server, please try again!' +login: + command_usage: '&cUsage: /login ' + wrong_password: '&cWrong password!' + success: '&2Successful login!' + login_request: '&cPlease, login with the command: /login ' + timeout_error: '&4Login timeout exceeded, you have been kicked from the server, please try again!' # Errors -unknown_user: '&cThis user isn''t registered!' -denied_command: '&cIn order to use this command you must be authenticated!' -denied_chat: '&cIn order to chat you must be authenticated!' -not_logged_in: '&cYou''re not logged in!' -tempban_max_logins: '&cYou have been temporarily banned for failing to log in too many times.' -max_reg: '&cYou have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection!' -no_perm: '&4You don''t have the permission to perform this action!' -error: '&4An unexpected error occurred, please contact an administrator!' -kick_forvip: '&3A VIP player has joined the server when it was full!' +error: + unregistered_user: '&cThis user isn''t registered!' + denied_command: '&cIn order to use this command you must be authenticated!' + denied_chat: '&cIn order to chat you must be authenticated!' + not_logged_in: '&cYou''re not logged in!' + tempban_max_logins: '&cYou have been temporarily banned for failing to log in too many times.' + max_registration: '&cYou have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection!' + no_permission: '&4You don''t have the permission to perform this action!' + 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 -kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' -antibot_auto_enabled: '&4[AntiBotService] AntiBot enabled due to the huge number of connections!' -antibot_auto_disabled: '&2[AntiBotService] AntiBot disabled after %m minutes!' +antibot: + kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' + 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 ' # Other messages -unregistered: '&cSuccessfully unregistered!' -accounts_owned_self: 'You own %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' -recovery_code_sent: 'A recovery code to reset your password has been sent to your email.' -recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.' -recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.' -recovery_code_correct: 'Recovery code entered correctly!' -recovery_change_password: 'Please use the command /email setpassword to change your password immediately.' -vb_nonActiv: '&cYour account isn''t activated yet, please check your emails!' -usage_unreg: '&cUsage: /unregister ' -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 ' +misc: + accounts_owned_self: 'You own %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' + account_not_activated: '&cYour account isn''t activated yet, please check your emails!' + password_changed: '&2Password changed successfully!' + logout: '&2Logged out successfully!' + reload: '&2Configuration and database have been reloaded correctly!' + usage_change_password: '&cUsage: /changepassword ' # Session messages -invalid_session: '&cYour IP has been changed and your session data has expired!' -valid_session: '&2Logged-in due to Session Reconnection.' +session: + 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 -name_len: '&4Your username is either too short or too long!' -regex: '&4Your username contains illegal characters. Allowed chars: REG_EX' -country_banned: '&4Your country is banned from this server!' -not_owner_error: 'You are not the owner of this account. Please choose another name!' -kick_fullserver: '&4The server is full, try again later!' -same_nick: '&4The same username is already playing on the server!' -invalid_name_case: 'You should join using username %valid, not %invalid.' -same_ip_online: 'A player with the same IP is already in game!' +on_join_validation: + name_length: '&4Your username is either too short or too long!' + characters_in_name: '&4Your username contains illegal characters. Allowed chars: %valid_chars' + country_banned: '&4Your country is banned from this server!' + not_owner_error: 'You are not the owner of this account. Please choose another name!' + kick_full_server: '&4The server is full, try again later!' + same_nick_online: '&4The same username is already playing on the server!' + 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 -usage_email_add: '&cUsage: /email add ' -usage_email_change: '&cUsage: /email change ' -usage_email_recovery: '&cUsage: /email recovery ' -new_email_invalid: '&cInvalid new email, try again!' -old_email_invalid: '&cInvalid old email, try again!' -email_invalid: '&cInvalid email address, try again!' -email_added: '&2Email address successfully added to your account!' -email_confirm: '&cPlease confirm your email address!' -email_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' -incomplete_email_settings: 'Error: not all required settings are set for sending emails. Please contact an admin.' -email_already_used: '&4The email address is already being used' -email_send_failure: 'The email could not be sent. Please contact an administrator.' -show_no_email: '&2You currently don''t have email address associated with this account.' -add_email: '&3Please add your email to your account with the command: /email add ' -recovery_email: '&3Forgot your password? Please use the command: /email recovery ' -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.' +email: + usage_email_add: '&cUsage: /email add ' + usage_email_change: '&cUsage: /email change ' + new_email_invalid: '&cInvalid new email, try again!' + old_email_invalid: '&cInvalid old email, try again!' + invalid: '&cInvalid email address, try again!' + added: '&2Email address successfully added to your account!' + request_confirmation: '&cPlease confirm your email address!' + changed: '&2Email address changed correctly!' + 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.' + already_used: '&4The email address is already being used' + 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.' + add_email_request: '&3Please add your email to your account with the command: /email add ' + 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 ' + command_usage: '&cUsage: /email recovery ' + 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 to change your password immediately.' # Captcha -usage_captcha: '&3To log in you have to solve a captcha code, please use the command: /captcha ' -wrong_captcha: '&cWrong captcha, please type "/captcha THE_CAPTCHA" into the chat!' -valid_captcha: '&2Captcha code solved correctly!' -captcha_for_registration: 'To register you have to solve a captcha first, please use the command: /captcha ' -register_captcha_valid: '&2Valid captcha! You may now register with /register' +captcha: + usage_captcha: '&3To log in you have to solve a captcha code, please use the command: /captcha %captcha_code' + wrong_captcha: '&cWrong captcha, please type "/captcha %captcha_code" into the chat!' + valid_captcha: '&2Captcha code solved correctly!' + 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_required: '&3This command is sensitive and requires an email verification! Check your inbox and follow the email''s instructions.' -usage_verification_code: '&cUsage: /verification ' -incorrect_verification_code: '&cIncorrect code, please type "/verification " into the chat, using the code you received by email' -verification_code_verified: '&2Your identity has been verified! You can now execute all commands within the current session!' -verification_code_already_verified: '&2You can already execute every sensitive command within the current session!' -verification_code_expired: '&3Your code has expired! Execute another sensitive command to get a new code!' -verification_code_email_needed: '&3To verify your identity you need to link an email address with your account!!' +verification: + code_required: '&3This command is sensitive and requires an email verification! Check your inbox and follow the email''s instructions.' + command_usage: '&cUsage: /verification ' + incorrect_code: '&cIncorrect code, please type "/verification " into the chat, using the code you received by email' + success: '&2Your identity has been verified! You can now execute all commands within the current session!' + already_verified: '&2You can already execute every sensitive command within the current session!' + 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 -second: 'second' -seconds: 'seconds' -minute: 'minute' -minutes: 'minutes' -hour: 'hour' -hours: 'hours' -day: 'day' -days: 'days' +time: + second: 'second' + seconds: 'seconds' + minute: 'minute' + minutes: 'minutes' + hour: 'hour' + hours: 'hours' + day: 'day' + days: 'days' diff --git a/src/test/java/fr/xephi/authme/message/MessageKeyTest.java b/src/test/java/fr/xephi/authme/message/MessageKeyTest.java index 3eb9f96ed..b28116341 100644 --- a/src/test/java/fr/xephi/authme/message/MessageKeyTest.java +++ b/src/test/java/fr/xephi/authme/message/MessageKeyTest.java @@ -3,9 +3,12 @@ package fr.xephi.authme.message; import fr.xephi.authme.util.StringUtils; import org.junit.Test; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.Assert.assertThat; 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_]+$"))); + } + } }