diff --git a/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java b/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java index 79d0bb216e..02a4627674 100644 --- a/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java +++ b/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java @@ -7,6 +7,10 @@ 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.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; @@ -27,6 +31,7 @@ public CommandList() public void execute(CommandSender sender, String[] args) { boolean hideEmptyServers = ( args.length == 0 ) || !args[0].equalsIgnoreCase( "all" ); + boolean moduleLoaded = ProxyServer.getInstance().getPluginManager().getPlugin( "cmd_server" ) != null; for ( ServerInfo server : ProxyServer.getInstance().getServers().values() ) { @@ -48,7 +53,18 @@ public void execute(CommandSender sender, String[] args) } Collections.sort( players, String.CASE_INSENSITIVE_ORDER ); - sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), players.size(), String.join( ChatColor.RESET + ", ", players ) ) ); + BaseComponent baseComponent = new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), players.size(), String.join( ChatColor.RESET + ", ", players ) ) ).build(); + + if ( moduleLoaded ) + { + baseComponent.setHoverEvent( new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "click_to_connect" ) ).create() ) + ); + baseComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) ); + } + + sender.sendMessage( baseComponent ); } sender.sendMessage( ProxyServer.getInstance().getTranslation( "total_players", ProxyServer.getInstance().getOnlineCount() ) );