Posted October 24, 20214 yr I was wondering how I could add/format color to a TextComponent in the following code: event.getPlayer().sendMessage(new TextComponent("Red colored, blue, and this is bold!"),event.getPlayer().getUUID()); I'm new to this version and it's a bit confusing. Any help would be appreciated. Thanks.
October 24, 20214 yr 1 minute ago, Parent said: I was wondering how I could add/format color to a TextComponent in the following code: event.getPlayer().sendMessage(new TextComponent("Red colored, blue, and this is bold!"),event.getPlayer().getUUID()); I'm new to this version and it's a bit confusing. Any help would be appreciated. Thanks. Did you try with vanilla color codes? For example, putting &4 in front of the "Red" will make the string red. You can also try using § instead of &.
October 24, 20214 yr Author 2 minutes ago, uSkizzik said: Did you try with vanilla color codes? For example, putting &4 in front of the "Red" will make the string red. You can also try using § instead of &. Never thought that would be so simple. Spend a whole hour trying to figure it out. Thanks a lot.
October 24, 20214 yr If you want the more future proof in-code solution that doesn't require an arbitrary hardcoded string interpolation, .withStyle(ChatFormatting.GOLD) this call on the `TextComponent` will color it. You can use any ChatFormatting enum constant, including ones that are added after the fact, and you don't have to consult some table on the internet to find what you want.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.