Help with Text

Hi,

I would like to have a colored text and clickable text.

i have this

String url = "";
	    	Pattern pattern = Pattern.compile("www.(\\S+)\\b");
	    	Matcher matcher = pattern.matcher(message);
	    	if (matcher.find())
	    	{
	    	  url = matcher.group(0);
	    	}
	    	Text text = TextSerializers.formattingCode('§').deserialize(message);
	    	try {
				text = Text.builder().onClick(TextActions.openUrl(new URL(url))).build();
			} catch (MalformedURLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    	return text;

But the return is empty

Well you are reassigning text to Text.builder().onClick(TextActions.openUrl(new URL(url))).build(), so it has no string to show. Try something like this:

Text text = TextSerializers.formattingCode('§').deserialize(message).toBuilder().onClick(TextActions.openUrl(new URL(url))).build()
1 Like

the method Onclick don’t exist with TextSerializers

Sorry, I somehow removed the toBuilder() piece, fixed it right as you said that :P, try again with the updated code block.

1 Like

Thx you, it’s work

1 Like