Copy text from chat

Discussion in 'Plugin Development' started by StephenTheHero, Feb 16, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    StephenTheHero

    Hey guys,

    Is their anyway I can make it so when you click a line of text you received from the server that text gets copied to your clipboard, or is this not possible? I'm really puzzled on how I can do this.

    Even if its just like when you click a link it displays a pop-up saying "Yes" "Copy to Clipboard" and "No"
     
  2. Offline

    Skionz

  3. Offline

    teej107

  4. You can use the Tellraw commands. But that would only work on player messages (PlayerChatEvent).. Just read through here (http://minecraft.gamepedia.com/Tellraw#Raw_JSON_text).
    example:
    Code:Java
    1.  
    2. String tellraw = "{text:\""+theMessage+"\",clickEvent:{action:\"suggest_command\",value:\""+theMessage+"\"}}";
    3.  

    and to send it to the player, use:
    Code:java
    1.  
    2. IChatBaseComponent comp = ChatSerializer.a(tellraw);
    3. PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
    4. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
    5.  

    You would need to cancel the PlayerChatEvent, and send the packet to all online players
     
  5. Offline

    teej107

    @FisheyLP Or you can just have the console run the tellraw command to avoid digging into NMS code.
     
Thread Status:
Not open for further replies.

Share This Page