From 71ac9b34fabd8c337e475dd2a619cca6bd065b45 Mon Sep 17 00:00:00 2001 From: Outfluencer <48880402+Outfluencer@users.noreply.github.com> Date: Sat, 28 Jan 2023 11:19:45 +1100 Subject: [PATCH] #3425: Make ip command output clickable to copy ip --- .../java/net/md_5/bungee/command/CommandIP.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 1fd5a546..beba1fa7 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,7 +1,10 @@ package net.md_5.bungee.command; +import java.util.Collections; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.connection.ProxiedPlayer; public class CommandIP extends PlayerCommand @@ -26,7 +29,17 @@ public class CommandIP extends PlayerCommand sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) ); } else { - sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_ip", args[0], user.getSocketAddress() ) ); + sender.sendMessage( new ComponentBuilder() + .appendLegacy( ProxyServer.getInstance().getTranslation( "command_ip", user.getName(), user.getSocketAddress() ) ) + .event( new ClickEvent( ClickEvent.Action.COPY_TO_CLIPBOARD, user.getSocketAddress().toString() ) ) + .create() + ); } } + + @Override + public Iterable onTabComplete(CommandSender sender, String[] args) + { + return ( args.length == 1 ) ? super.onTabComplete( sender, args ) : Collections.emptyList(); + } }