#797 Make two messages translatable

This commit is contained in:
ljacqu
2016-07-02 21:49:01 +02:00
parent 9a5c432509
commit 3984208548
8 changed files with 25 additions and 9 deletions
@@ -53,6 +53,16 @@ public class CommandService {
return messages.retrieve(key);
}
/**
* Retrieve a message as a single String by its message key.
*
* @param key The message to retrieve
* @return The message
*/
public String retrieveSingle(MessageKey key) {
return messages.retrieveSingle(key);
}
/**
* Retrieve the given property's value.
*
@@ -79,7 +79,7 @@ public class RegisterAdminCommand implements ExecutableCommand {
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
player.kickPlayer("An admin just registered you, please log in again");
player.kickPlayer(commandService.retrieveSingle(MessageKey.KICK_FOR_ADMIN_REGISTER));
}
});
}
@@ -42,7 +42,7 @@ public class RecoverEmailCommand extends PlayerCommand {
if (!sendMailSsl.hasAllInformation()) {
ConsoleLogger.showError("Mail API is not set");
commandService.send(player, MessageKey.ERROR);
commandService.send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
return;
}
if (dataSource.isAuthAvailable(playerName)) {
@@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
import static fr.xephi.authme.output.MessageKey.INCOMPLETE_EMAIL_SETTINGS;
import static fr.xephi.authme.settings.properties.EmailSettings.RECOVERY_PASSWORD_LENGTH;
import static fr.xephi.authme.settings.properties.RegistrationSettings.ENABLE_CONFIRM_EMAIL;
import static fr.xephi.authme.settings.properties.RegistrationSettings.USE_EMAIL_REGISTRATION;
@@ -68,8 +69,7 @@ public class RegisterCommand extends PlayerCommand {
private void handleEmailRegistration(Player player, List<String> arguments) {
if (!sendMailSsl.hasAllInformation()) {
player.sendMessage("Cannot register: not all required settings are set for sending emails. "
+ "Please contact an administrator");
commandService.send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
ConsoleLogger.showError("Cannot register player '" + player.getName() + "': no email or password is set "
+ "to send emails from. Please adjust your config at " + EmailSettings.MAIL_ACCOUNT.getPath());
return;
@@ -143,7 +143,11 @@ public enum MessageKey {
ACCOUNTS_OWNED_SELF("accounts_owned_self", "%count"),
ACCOUNTS_OWNED_OTHER("accounts_owned_other", "%name", "%count");
ACCOUNTS_OWNED_OTHER("accounts_owned_other", "%name", "%count"),
KICK_FOR_ADMIN_REGISTER("kicked_admin_registered"),
INCOMPLETE_EMAIL_SETTINGS("incomplete_email_settings");
private String key;
private String[] tags;