So I found this code on the forums and i'm wondering how I can display the text component in this code in a chat message, I'v tried a few different things and I can't figure it out.
Here's my chat format I want to add the text component to:
Here's the code I found involving text components:
Here's my chat format I want to add the text component to:
Code:
send formatted "<suggest command:/msg %player% ><tooltip: &8» &e&l%Player%%nl%Points: %{_point}%%nl%Money: %{_money}%%nl%Votes: %{_votes}%>[&a%{_donorank}%] &7%player's display name% &a» &e%message%<reset>" to all players
Here's the code I found involving text components:
Code:
import:
net.md_5.bungee.api.chat.BaseComponent
net.md_5.bungee.api.chat.TextComponent
net.md_5.bungee.api.chat.TranslatableComponent
org.bukkit.Material
on leftclick:
if name of tool of player is not set:
set {_material} to Material.matchMaterial("%vanilla name of tool of player%") #get raw material from item
set {_rawName} to "%vanilla name of tool of player%"
replace every ":" in {_rawName} with "."
if {_material}.isBlock() is true: #if item is block, add "block." prefix, otherwise - "item."
set {_rawName} to "block.%{_rawName}%"
else:
set {_rawName} to "item.%{_rawName}%"
#translatable name would look like this: "block.minecraft.stone"
set {_c} to a new text component "<dark gray>[<reset>"
{_c}.addExtra(new TranslatableComponent({_rawName})) #adding translatabe component to text component of Skellett
{_c}.addExtra(new TextComponent(" <gray>x%number of tool of player%<dark gray>]"))
else: #if item has custom name
set {_c} to a new text component "<dark gray>[<reset>%name of tool of player% <gray>x%number of tool of player%<dark gray>]<reset>"
if item-nbt of tool of player is set: #if item has any nbt data, requires NBeeT
add hover event with action SHOW_ITEM with text "{""id"":""%vanilla name of tool of player%"",""Count"":1,""tag"":%item-nbt of tool of player%}" to text component {_c}
else: #if no nbt data
add hover event with action SHOW_ITEM with text "{""id"":""%vanilla name of tool of player%"",""Count"":1}" to text component {_c}
message text component {_c} to player