ItemChat - Allows you to display your item in chat


#1

This is a discussion topic for the Ore project, ItemChat. View the full project on Ore for downloads and more information.


ItemChat

ItemChat is a Sponge plugin which allows you to display your currently-held item in chat.

To use, simply write {item} as part of any chat message or command. It will be replaced with the name of the item you are holding, and if users hover over it, they can see the full item tooltip. If the item has a custom display name, it will be shown in the message instead of the item type.

If you want to use a different slot than your hand, simply type $num after item, where num is the slot number. For instance, I could write {item $3} to get the third hotbar slot.

You can also display items that don’t actually exist! Simply write the NBT tag after item, as you would in a /give command. For example, {item {id:"minecraft:redstone",display:{Name:"Weird Dust"}}} would display redstone with a custom name of Weird Dust. Nonexistent items are colored differently from regular items.

If your nonexistent item NBT is too long to type in chat, you can write it in a book. Add #! after item to pull the NBT from the book you’re holding. You can also write a slot number after #! if you want, to use a book from that hotbar slot. For example, {item #!3} would pull NBT from a book in hotbar slot 3.

You can also assign custom text to it. For instance, if I were to type {item Apple}, it would output [Apple] regardless of what the actual item name is. However, it will be colored differently, so users without F3+H on will be able to tell the difference. This custom name goes after slot numbers and before NBT tags.

As a bonus, not only does the tooltip appear to each player in their native language, but so does the item name in chat if custom text isn’t used and the item doesn’t have a custom display name.

If you add @expander after item, where expander is the name of an expander, then the item name in chat will be replaced with the output of the expander. Expanders are a way to make {item} useful in different contexts from chat. For instance, I could type {item@nbt} to say the item’s NBT data. The other default expanders are:
nbt+tag, which is like nbt except the tag tag is used,
name which expands into the item’s custom name,
id which expands into the item’s ID,
type which expands into the auto-translated name of the item type,
count which expands into the item quantity, data which expands into the item’s data value,
/give which expands into the rest of the /give command after the player name, and
/summon which expands into the rest of the /summon command (for dropped items) after the coordinates.

If you are not holding anything, or the $ slot number does not contain anything, or the #! slot number does not contain a book, or you’re using an invalid expander, then the {item} message will just appear normally. If you want to make a valid {item} appear in raw form, use $, as in ${item}. If this should recurse, just add more $s - one will be subtracted each time it’s evaluated.

Configuration

max-expander-size-chat: The number of characters that an expander in chat can be (to avoid spamming. imagine someone picking up an AE drive and typing {item@nbt}).

Permissions

itemchat.arbitrary_nbt: Allows use of the arbitrary NBT feature. Given to everyone by default.
itemchat.bypass_expander_size: Allows bypassing max-expander-size-chat.

Plugin interop

Plugins can leverage the addItem function in order to process {item} in places besides commands and chat. Additionally, plugins can add their own expanders.

Changelog

1.0: Initial release.
1.1: Added hotbar slots, NBT, and books.
1.2: Added a permission for NBT.
1.3: Updated to API 7.
1.4: Added expanders, the ability to escape {item}, and the ability to use {item} in commands.

Metrics

This plugin uses bStats to collect metrics. A list of all metrics collected can be found here. This data is unobtrusive, lightweight, and completely anonymized, so there is no reason whatsoever to disable it. However, if you wish to do so anyway, simply set enabled to false in config/bStats/config.conf.


#2

Interesting to see another plugin written in Kotlin! Also Kludge looks nice :wink: (Nice use of operators)


#3

No need of typing a command, great job sir !


#4

Thanks! I gave it a shot and it's so much more easy to use than Java. My only wish is that they would be able to take yet another leaf from C#'s book and allow for operator functions for explicit or implicit casting.


#5

A new version has been released for ItemChat, it is available for download here.


1.1.0

New additions:

  • Slot numbers
    • {item $3} shows the item in slot 3! Use with any hotbar slot number.

  • Custom NBT

    • {item {id:"minecraft:redstone"}} shows a single redstone item! Use with NBT in the regular /give format (see here) (the tag tag is optional).

    • {item #!} shows whatever item is represented by the NBT written in the book I'm holding!

    • {item #!3} shows whatever item is represented by the NBT written in the book in hotbar slot 3! Use with any hotbar slot number.


#6

Why did you set {item $3} and not {item 3} ?


#7

You just wrote the same thing twice.


#8

Um, this is what happens when you change your sentence :frowning:

There is a sneaky $ that need to get edited.


#9

Because what if you need to name the item 3?


#10

That's an exceptionnal case, I never heard about an item named 1, 2, 3 or 9 but I understand the $ now.


#11

The idea is that it's a marker character, saying 'this is special'. Since the name is a catch-all where any characters work, I need a way to mark the other stuff (there may be more arguments down the line) as not being part of the name. Better to have marker characters than blacklist anything that could make up those arguments.


#12

Is it possible to add some permissions for the different functions?
For example, a permission for using {item}, a permission for using {item $3}, a permission for using {item {id:"minecraft:redstone",display:{Name:"Weird Dust"}}}, etc.


#13

Is there a way for this plugin to support items with lore on item?


#14

Not sure what you mean. The two things I can think of that you mean (lore on an item that you are displaying and lore in the NBT), this plugin already does.


#15

Sorry I haven't replied. I usually don't put permissions in my plugins except for admin stuff, because I don't like rank separation over silliness like whether you can use an arbitrary slot or whether you have to use your hand for displaying an item. I might add a permission to the entirety of the 'arbitrary NBT' feature, though.


#16

Thank you :grinning:


#17

This seems nice Pie, How about some screenshots in order to show it off?


#18

A new version has been released for ItemChat, it is available for download here.


Added a permission - itemchat.arbitrary_nbt, enabled by default, allowing use of the 'arbitrary NBT' feature, both for chat and books.


#19

A new version has been released for ItemChat, it is available for download here.


  • Fixed a bug with arbitrary NBT and damage values.

#20

Is there a way to use it with plugins like SimpleChat or UltimateChat ?