Display Item in chat

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Kush

Member
Jan 29, 2017
29
2
3
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:

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
 
Status
Not open for further replies.