From 043ee902541cbe5a0902a654f0a511ee60cb2e35 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Mon, 13 Jun 2016 21:45:21 +0200 Subject: [PATCH] #423 Make seeownaccounts / seeotheraccounts messages translatable --- .../java/fr/xephi/authme/output/MessageKey.java | 6 +++++- .../authme/process/login/AsynchronousLogin.java | 15 +++++++-------- src/main/resources/messages/messages_de.yml | 2 ++ src/main/resources/messages/messages_en.yml | 2 ++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/fr/xephi/authme/output/MessageKey.java b/src/main/java/fr/xephi/authme/output/MessageKey.java index 7bd27621..670366f5 100644 --- a/src/main/java/fr/xephi/authme/output/MessageKey.java +++ b/src/main/java/fr/xephi/authme/output/MessageKey.java @@ -139,7 +139,11 @@ public enum MessageKey { INVALID_NAME_CASE("invalid_name_case", "%valid", "%invalid"), - TEMPBAN_MAX_LOGINS("tempban_max_logins"); + TEMPBAN_MAX_LOGINS("tempban_max_logins"), + + ACCOUNTS_OWNED_SELF("accounts_owned_self", "%count"), + + ACCOUNTS_OWNED_OTHER("accounts_owned_other", "%name", "%count"); private String key; private String[] tags; diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index 83b453dd..e60851e3 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -252,7 +252,6 @@ public class AsynchronousLogin implements AsynchronousProcess { } } - // TODO #423: allow translation! private void displayOtherAccounts(PlayerAuth auth, Player player) { if (!service.getProperty(RestrictionSettings.DISPLAY_OTHER_ACCOUNTS) || auth == null) { return; @@ -263,18 +262,17 @@ public class AsynchronousLogin implements AsynchronousProcess { return; } - List tmp = new ArrayList(); + List formattedNames = new ArrayList<>(auths.size()); for (String currentName : auths) { Player currentPlayer = bukkitService.getPlayerExact(currentName); if (currentPlayer != null && currentPlayer.isOnline()) { - tmp.add(ChatColor.GREEN + currentName); + formattedNames.add(ChatColor.GREEN + currentName); } else { - tmp.add(currentName); + formattedNames.add(currentName); } } - auths = tmp; - String message = ChatColor.GRAY + StringUtils.join(ChatColor.GRAY + ", ", auths) + "."; + String message = ChatColor.GRAY + StringUtils.join(ChatColor.GRAY + ", ", formattedNames) + "."; if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) { ConsoleLogger.info("The user " + player.getName() + " has " + auths.size() + " accounts:"); @@ -284,10 +282,11 @@ public class AsynchronousLogin implements AsynchronousProcess { for (Player onlinePlayer : bukkitService.getOnlinePlayers()) { if (onlinePlayer.getName().equalsIgnoreCase(player.getName()) && permissionsManager.hasPermission(onlinePlayer, PlayerPermission.SEE_OWN_ACCOUNTS)) { - onlinePlayer.sendMessage("You own " + auths.size() + " accounts:"); + service.send(onlinePlayer, MessageKey.ACCOUNTS_OWNED_SELF, Integer.toString(auths.size())); onlinePlayer.sendMessage(message); } else if (permissionsManager.hasPermission(onlinePlayer, AdminPermission.SEE_OTHER_ACCOUNTS)) { - onlinePlayer.sendMessage("The user " + player.getName() + " has " + auths.size() + " accounts:"); + service.send(onlinePlayer, MessageKey.ACCOUNTS_OWNED_OTHER, + player.getName(), Integer.toString(auths.size())); onlinePlayer.sendMessage(message); } } diff --git a/src/main/resources/messages/messages_de.yml b/src/main/resources/messages/messages_de.yml index 95f578e7..c196f3b0 100644 --- a/src/main/resources/messages/messages_de.yml +++ b/src/main/resources/messages/messages_de.yml @@ -66,3 +66,5 @@ denied_chat: '&cDu musst eingeloggt sein, um chatten zu können!' same_ip_online: 'Ein Spieler mit derselben IP ist bereits online!' denied_command: '&cUm diesen Befehl zu nutzen musst du authentifiziert sein!' tempban_max_logins: '&cDu bist wegen zu vielen fehlgeschlagenen Login-Versuchen temporär gebannt!' +accounts_owned_self: 'Du besitzt %count Accounts:' +accounts_owned_other: 'Der Spieler %name hat %count Accounts:' diff --git a/src/main/resources/messages/messages_en.yml b/src/main/resources/messages/messages_en.yml index aabbae89..f2926eb9 100644 --- a/src/main/resources/messages/messages_en.yml +++ b/src/main/resources/messages/messages_en.yml @@ -66,3 +66,5 @@ two_factor_create: '&2Your secret code is %code. You can scan it from here %url' not_owner_error: 'You are not the owner of this account. Please choose another name!' invalid_name_case: 'You should join using username %valid, not %invalid.' tempban_max_logins: '&cYou have been temporarily banned for failing to log in too many times.' +accounts_owned_self: 'You own %count accounts:' +accounts_owned_other: 'The player %name has %count accounts:'