#423 Make seeownaccounts / seeotheraccounts messages translatable

This commit is contained in:
ljacqu 2016-06-13 21:45:21 +02:00
parent b7015f56c2
commit 043ee90254
4 changed files with 16 additions and 9 deletions

View File

@ -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;

View File

@ -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<String> tmp = new ArrayList<String>();
List<String> 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);
}
}

View File

@ -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:'

View File

@ -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:'