How would I go about getting a specific word a player clicked on in the chat and running a command based off of the word that was clicked. For example: pondamo: Hello bob, can I teleport to you? Bob: Sure just click on my name in the chat! pondamo: (clicks on bobs name and is teleported to bob) Thanks for any help!
True I could do that... and thats probably the only way I will be able to do it but how would I get it to where its able to pinpoint the players name and then specifically teleport to that player? This is what I came up with so far but it doesnt exactly work. Code (Text): TextComponent message = new TextComponent(e.getMessage()); message.setClickEvent(new ClickEvent (ClickEvent.Action.RUN_COMMAND, ("/tpa " + message))); player.spigot().sendMessage(message);
Yes but how could I retreive the players name? I need to be able to figure out the word the player is clicking on then have them teleport to the player but I am lost on how I would go about retrieving the specific word the player clicked on
Okay, i think i got your point. If you set the whole message as a one json, it does not click to a word, it clicks to all of the message. You can set json for each word, put them together and send. Better way to do this is checking each word in the message to see if it is a name of a player or not. Then replacing only player names with jsons.