SayItem - Display an item in chat!

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


SayItem

A Simple Minecraft Plugin to Display an item in chat! Any player with the sayitem.chat permission will automatically have their chat messages scanned and replaced. To display an item simply hold the item in your main hand and include [item] in your chat message. The placeholder will be replaced with the name of the item and on hover will display the tooltip for it. The name, color, and formatting are taken directly from the item, so items with custom names and colors will display just fine!

In addition, SayItem v1.1.0 added the concept of an Indexed Placeholder, [item] will still reference the item currently in the player’s main hand, however [item1] will reference the item in the first slot of the player’s hotbar (if present), [item2] will reference the second slot. In this way, you can reference multiple items in the same message!

Finally if opting the use the /sayitem command there exists a -j flag to enable formatting placeholders as consise JSON. For example if I wanted to display a Poition of Weakness in chat but I did not have one in my inventory I could execute:

/sayitem -j Anyone want a [{"ContentVersion":1,"Count":1,"ItemType":"minecraft:potion","UnsafeDamage":0,"UnsafeData":{"Potion":"minecraft:weakness"}}]?

Don’t know how to format an item in concise JSON? Check out one of my other plugins SerializeMe :smile:

Commands

  • /sayitem [-j] <Text> - Displays Text in chat with all item placeholders replaced. Use the -j flag to enable parsing JSON placeholders

Permissions

  • sayitem.chat
  • sayitem.command.say
  • sayitem.command.flag.say.j

Examples

Basic Command Usage

(Examples of normal chat functionality and indexed placeholders to come!)
Raw Command
Result Text

Support Me

I will never charge money for the use of my plugins, however they do require a significant amount of work to maintain and update. If you’d like to show your support and buy me a cup of tea sometime (I don’t drink that horrid coffee stuff :P) you can do so here

3 Likes

Your split’n’replace of the message sort of completely strips out 100% of any custom formatting.

Edit: I’m not sure how I read how you were doing it without noticing it was in a command and not a listener.

Yeah, that’s why I did it as a command so I could do a split and replace before the chat message is actually sent, that way I could avoid that very issue :stuck_out_tongue:

I am also issuing a heads-up that I was almost done with almost an exact rip-off of this plugin before I noticed this thread.

I take it you doing it as a listener though?

yup :stuck_out_tongue:

Right so your method preserves the color, but the reason I didn’t go down that route is I couldn’t guarantee preserving other forms of text formatting like hover and click actions.

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


Commands are Tedious you Say?

Release v1.1.0

Minecraft 1.11.2 - Tested on spongeforge-1.11.2-2282-6.1.0-BETA-2370

Changes:

  • Completely refactored method of replacing placeholders, props to pie_flavor for devising the original method!
  • Players with the sayitem.chat permission will now have all of their chat messages automatically parsed for item placeholders!
  • Introduced Indexed Placeholders [item] will still reference the item currently in the player’s hand, however [item1] will reference the 1st item slot in the player’s hotbar (if an item is present), [item2] will reference the second slot and so on. In this way, you can reference multiple items in the same message!
  • Added -j flag and sayitem.command.flag.say.j permission to /sayitem command. The -j flag allows you to specify item placeholders in concise JSON format, in this way you can display items that are not even in your inventory, or even have non-player entities like command blocks display items!
    • Ex: /sayitem -j Anyone want [{"ContentVersion":1,"Count":1,"ItemType":"minecraft:potion","UnsafeDamage":0,"UnsafeData":{"Potion":"minecraft:weakness"}}]? will display Anyone want [potion]? in chat with [potion] displaying a potion of weakness on hover.
    • Don’t know how to generate the concise JSON format for an item? Check out one of my other plugins SerializeMe :grinning_face_with_smiling_eyes:

Enjoy!

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


Say Seven!

Release v1.2.0

Minecraft 1.12.2 - Tested on spongeforge-1.12.2-2555-7.1.0-BETA-2815

Changes:

  • Update to Sponge API 7

Enjoy!

2 Likes

Is it possible to get rid of the square brackets around the item? The plugin will become MUCH more versatile.

EDIT: I made a version of your plugin that does not have the square brackets, but it doesn’t summon a cow when I am holding a block renamed “Cow” and type /summon [item] (in square brackets) ~ ~ ~
Could you make a remedy to this please?

One year later I remember to respond to this. Actually 100% of the formatting is preserved.

Yes you are correct, it was.

@AuWiMo Ah, I never intended the placeholder to be used in commands. I can add this functionality, in the meantime I believe pie_flavor’s ItemChat may provide the functionality you are after.

1 Like