From 9e76966e0fc46e4bdc61cfe97f14cd8b98290d8c Mon Sep 17 00:00:00 2001 From: MrIvanPlays Date: Fri, 16 Aug 2019 18:19:36 +0300 Subject: [PATCH] #2608,#2684: Add some missing translations to module commands --- .../md_5/bungee/module/cmd/alert/CommandAlert.java | 2 +- .../bungee/module/cmd/alert/CommandAlertRaw.java | 12 ++++++------ .../md_5/bungee/module/cmd/find/CommandFind.java | 8 +++----- .../md_5/bungee/module/cmd/send/CommandSend.java | 11 +++++------ .../bungee/module/cmd/server/CommandServer.java | 4 ++-- .../java/net/md_5/bungee/command/CommandIP.java | 7 +++---- .../java/net/md_5/bungee/command/CommandPerms.java | 5 ++--- proxy/src/main/resources/messages.properties | 14 ++++++++++++++ 8 files changed, 36 insertions(+), 27 deletions(-) diff --git a/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java b/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java index 3618c12f..55d2f7b8 100644 --- a/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java +++ b/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java @@ -19,7 +19,7 @@ public class CommandAlert extends Command { if ( args.length == 0 ) { - sender.sendMessage( ChatColor.RED + "You must supply a message." ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "message_needed" ) ); } else { StringBuilder builder = new StringBuilder(); diff --git a/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlertRaw.java b/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlertRaw.java index 4d4ef1be..7292899d 100644 --- a/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlertRaw.java +++ b/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlertRaw.java @@ -23,7 +23,7 @@ public class CommandAlertRaw extends Command { if ( args.length == 0 ) { - sender.sendMessage( ChatColor.RED + "You must supply a message." ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "message_needed" ) ); } else { String message = Joiner.on( ' ' ).join( args ); @@ -40,15 +40,15 @@ public class CommandAlertRaw extends Command } if ( sender instanceof ProxiedPlayer ) { - sender.sendMessage( new ComponentBuilder( "An error occurred while parsing your message. (Hover for details)" ) - .color( ChatColor.RED ) - .underlined( true ) - .event( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( error.getMessage() ).color( ChatColor.RED ).create() ) ) + sender.sendMessage( new ComponentBuilder( ProxyServer.getInstance().getTranslation( "error_occurred_player" ) ) + .event( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( error.getMessage() ) + .color( ChatColor.RED ) + .create() ) ) .create() ); } else { - sender.sendMessage( new ComponentBuilder( "An error occurred while parsing your message: " ).color( ChatColor.RED ).append( error.getMessage() ).create() ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "error_occurred_console", error.getMessage() ) ); } } } diff --git a/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java b/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java index 9c5bcb81..7ea239ac 100644 --- a/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java +++ b/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java @@ -1,9 +1,7 @@ package net.md_5.bungee.module.cmd.find; -import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.command.PlayerCommand; @@ -20,16 +18,16 @@ public class CommandFind extends PlayerCommand { if ( args.length != 1 ) { - sender.sendMessage( new ComponentBuilder( "Please follow this command by a user name" ).color( ChatColor.RED ).create() ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "username_needed" ) ); } else { ProxiedPlayer player = ProxyServer.getInstance().getPlayer( args[0] ); if ( player == null || player.getServer() == null ) { - sender.sendMessage( new ComponentBuilder( "That user is not online" ).color( ChatColor.RED ).create() ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) ); } else { - sender.sendMessage( new ComponentBuilder( args[0] ).color( ChatColor.GREEN ).append( " is online at " ).append( player.getServer().getInfo().getName() ).create() ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_online_at", player.getName(), player.getServer().getInfo().getName() ) ); } } } diff --git a/module/cmd-send/src/main/java/net/md_5/bungee/module/cmd/send/CommandSend.java b/module/cmd-send/src/main/java/net/md_5/bungee/module/cmd/send/CommandSend.java index d802654e..7129293d 100644 --- a/module/cmd-send/src/main/java/net/md_5/bungee/module/cmd/send/CommandSend.java +++ b/module/cmd-send/src/main/java/net/md_5/bungee/module/cmd/send/CommandSend.java @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableSet; import java.util.HashSet; import java.util.Locale; import java.util.Set; -import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; @@ -26,7 +25,7 @@ public class CommandSend extends Command implements TabExecutor { if ( args.length != 2 ) { - sender.sendMessage( ChatColor.RED + "Not enough arguments, usage: /send " ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "send_cmd_usage" ) ); return; } ServerInfo target = ProxyServer.getInstance().getServerInfo( args[1] ); @@ -46,7 +45,7 @@ public class CommandSend extends Command implements TabExecutor { if ( !( sender instanceof ProxiedPlayer ) ) { - sender.sendMessage( ChatColor.RED + "Only in game players can use this command" ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "player_only" ) ); return; } ProxiedPlayer player = (ProxiedPlayer) sender; @@ -69,13 +68,13 @@ public class CommandSend extends Command implements TabExecutor ProxiedPlayer player = ProxyServer.getInstance().getPlayer( args[0] ); if ( player == null ) { - sender.sendMessage( ChatColor.RED + "That player is not online" ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) ); return; } summon( player, target, sender ); } } - sender.sendMessage( ChatColor.GREEN + "Successfully summoned player(s)" ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "successfully_summoned" ) ); } private void summon(ProxiedPlayer player, ServerInfo target, CommandSender sender) @@ -83,7 +82,7 @@ public class CommandSend extends Command implements TabExecutor if ( player.getServer() != null && !player.getServer().getInfo().equals( target ) ) { player.connect( target, ServerConnectEvent.Reason.COMMAND ); - player.sendMessage( ChatColor.GOLD + "Summoned to " + target.getName() + " by " + sender.getName() ); + player.sendMessage( ProxyServer.getInstance().getTranslation( "you_got_summoned", target.getName(), sender.getName() ) ); } } diff --git a/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java b/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java index 9693701d..8bd24609 100644 --- a/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java +++ b/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java @@ -40,7 +40,7 @@ public class CommandServer extends Command implements TabExecutor sender.sendMessage( ProxyServer.getInstance().getTranslation( "current_server", ( (ProxiedPlayer) sender ).getServer().getInfo().getName() ) ); } - ComponentBuilder serverList = new ComponentBuilder( "" ).append( TextComponent.fromLegacyText( ProxyServer.getInstance().getTranslation( "server_list" ) ) ); + ComponentBuilder serverList = new ComponentBuilder( "" ).appendLegacy( ProxyServer.getInstance().getTranslation( "server_list" ) ); boolean first = true; for ( ServerInfo server : servers.values() ) { @@ -50,7 +50,7 @@ public class CommandServer extends Command implements TabExecutor int count = server.getPlayers().size(); serverTextComponent.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, - new ComponentBuilder( count + ( count == 1 ? " player" : " players" ) + "\n" ).append( "Click to connect to the server" ).italic( true ).create() ) + new ComponentBuilder( count + ( count == 1 ? " player" : " players" ) + "\n" ).appendLegacy( ProxyServer.getInstance().getTranslation( "click_to_connect" ) ).create() ) ); serverTextComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) ); serverList.append( serverTextComponent ); diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandIP.java b/proxy/src/main/java/net/md_5/bungee/command/CommandIP.java index d5d64033..8fd4975b 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandIP.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandIP.java @@ -1,6 +1,5 @@ package net.md_5.bungee.command; -import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -18,16 +17,16 @@ public class CommandIP extends PlayerCommand { if ( args.length < 1 ) { - sender.sendMessage( ChatColor.RED + "Please follow this command by a user name" ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "username_needed" ) ); return; } ProxiedPlayer user = ProxyServer.getInstance().getPlayer( args[0] ); if ( user == null ) { - sender.sendMessage( ChatColor.RED + "That user is not online" ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) ); } else { - sender.sendMessage( ChatColor.BLUE + "IP of " + args[0] + " is " + user.getAddress() ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_ip", args[0], user.getAddress() ) ); } } } diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java b/proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java index 610825ca..18422669 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java @@ -3,7 +3,6 @@ package net.md_5.bungee.command; import java.util.HashSet; import java.util.Set; import net.md_5.bungee.Util; -import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.plugin.Command; @@ -24,11 +23,11 @@ public class CommandPerms extends Command { permissions.addAll( ProxyServer.getInstance().getConfigurationAdapter().getPermissions( group ) ); } - sender.sendMessage( ChatColor.GOLD + "You have the following groups: " + Util.csv( sender.getGroups() ) ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_perms_groups", Util.csv( sender.getGroups() ) ) ); for ( String permission : permissions ) { - sender.sendMessage( ChatColor.BLUE + "- " + permission ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_perms_permission", permission ) ); } } } diff --git a/proxy/src/main/resources/messages.properties b/proxy/src/main/resources/messages.properties index dfb58c12..6e3ef0a4 100644 --- a/proxy/src/main/resources/messages.properties +++ b/proxy/src/main/resources/messages.properties @@ -24,3 +24,17 @@ name_too_long=Cannot have username longer than 16 characters name_invalid=Username contains invalid characters. ping_cannot_connect=\u00a7c[Bungee] Can't connect to server. offline_mode_player=Not authenticated with Minecraft.net +message_needed=\u00a7cYou must supply a message. +error_occurred_player=\u00a7cAn error occurred while parsing your message. (Hover for details) +error_occurred_console=\u00a7cAn error occurred while parsing your message: {0} +click_to_connect=Click to connect to the server +username_needed=\u00a7cPlease follow this command by a user name. +user_not_online=\u00a7cThat user is not online. +user_online_at=\u00a7a{0} \u00a7ris online at {1} +send_cmd_usage=\u00a7cNot enough arguments, usage: /send +player_only=\u00a7cOnly in game players can use this command +successfully_summoned=\u00a7aSuccessfully summoned player(s) +you_got_summoned=\u00a76Summoned to {0} by {1} +command_perms_groups=\u00a76You have the following groups: {0} +command_perms_permission=\u00a79- {0} +command_ip=\u00a79IP of {0} is {1}