Closed rJoshy closed 10 years ago
You should be able to do this by using .then()
to separate the two distinct parts of the message:
new FancyMessage("Hey ").then("Josh").tooltip(YOUR_TOOLTIP_HERE);
Modifiers (applied by .tooltip()
, .color()
, etc) apply only to the text in the most recent message part. Calling .then()
creates a new message part with different modifiers.
Hey, thanks for that, what if the message was "Hey Josh, how is it going". I tried with .replace but that doesn't work. Just a correction, this is in a AsyncPlayerChatEvent. So I'm getting the msg and checking if a online players name is mentioned
Again, you can use .then()
to separate the part that should have a tooltip from the parts that shouldn't:
new FancyMessage("Hey ")
.then("Josh").tooltip(YOUR_TOOLTIP_HERE)
.then(", how is it going");
If you're doing this dynamically for arbitrary chat messages, you'll have to manually split the message string around the detected player name in order to isolate substrings that should and shouldn't have tooltips. Then you can loop over the array of message parts and add a new section to your FancyMessage (via .then()
) for each one, applying tooltips where desired.
It's been a while since the last activity here, so I'm going to assume the problem was solved and close this issue. Can always reopen later if necessary.
Hey,
Is there a way I can only use .tooltip for 1 word in a list of strings/a msg. If i say in chat "Hey Josh", if i put my cursor over Josh, it will only show the tooltip but when i put it over "Hey", it wont show the tooltip.
Thanks, Josh