Other available versions. Ordered by newest to oldest versions:
Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.
# ChatItem 1.8.2 by D4isDAVID
# Find it on Spigot: https://spigotmc.org/resources/83479/
# Find it on skUnity: https://forums.skunity.com/resources/1168/
# Find it on GitHub Gist: https://gist.github.com/D4isDAVID/57c7740c8eb835851ebee3eb8c6b00bf
# Dependencies:
# - Skript 2.6+ | https://github.com/SkriptLang/Skript/releases
# - SkBee 1.16+ | https://github.com/ShaneBeee/SkBee/releases
options:
item format: &8[&r{name}&7 x{amount}&8]
unstackable item format: &8[&r{name}&8]
on load:
# register keywords to use later
set {chatitem::keywords::hand::*} to "[hand]", "[item]" and "[i]"
set {chatitem::keywords::offhand::*} to "[offhand]"
set {chatitem::keywords::helmet::*} to "[helmet]", "[helm]" and "[head]"
set {chatitem::keywords::chestplate::*} to "[chestplate]" and "[chest]"
set {chatitem::keywords::leggings::*} to "[leggings]" and "[legs]"
set {chatitem::keywords::boots::*} to "[boots]", "[shoes]" and "[feet]"
on chat:
# get player items
set {_items::hand} to player's held item
set {_items::offhand} to player's offhand item
set {_items::helmet} to player's helmet
set {_items::chestplate} to player's chestplate
set {_items::leggings} to player's leggings
set {_items::boots} to player's boots
# search for keywords in message and remove duplicates
loop indices of {chatitem::keywords::*}:
set {_keyword} to {chatitem::keywords::%loop-value%::1}
loop {chatitem::keywords::%loop-value%::*}:
message contains loop-value-2
replace loop-value-2 in message with {_keyword}
message contains {_keyword}
set {_message::*} to split message at {_keyword}
set {_message1} to {_message::1}
delete {_message::1}
set message to "%{_message1}%%{_keyword}%%join {_message::*} with ""%"
{_items::%loop-value%} is set
type of {_items::%loop-value%} is not air
set {_keywords::%loop-value%} to {_keyword}
if {_delim} is not set: # set a delimiter used for later splitting the message
set {_delim} to {_keyword} # make the delimiter something that wouldn't exist in the message
event is not cancelled # don't do anything if the chat event is already cancelled
# cancel the event to send one with hover events later
size of {_keywords::*} > 0
cancel event
# replace keywords with an easily splittable string
set {_message} to message
loop {_keywords::*}:
replace loop-value in {_message} with "%{_delim}%%loop-index%%{_delim}%"
# get the message format for sending it later
wait a tick # wait for other scripts or plugins to set the format
set {_format} to chat format
replace "[message]" in {_format} with message
replace "[player]" in {_format} with player's display name
set {_format::*} to split {_format} at message
# get the message color from the format to use in the message
set {_colors::*} to split {_format::1} at "§"
delete {_colors::1}
set {_color} to ""
loop {_colors::*}:
set {_color} to "%{_color}%§%first character of loop-value%"
# split the message and replace keywords with the item and a hover event
set {_message::*} to split {_message} at {_delim}
set {_ignore} to true # otherwise sending "hand[hand]hand" will show the item thrice
loop {_message::*}:
if {_ignore} is true:
set {_ignore} to false
# add the message color from the format
set {_message::%loop-index%} to "%colored {_color}%%loop-value%"
# get the color of this part of the message, if there is one
set {_colors::*} to split loop-value at "§"
delete {_colors::1}
if size of {_colors::*} > 1:
set {_color} to ""
loop {_colors::*}:
set {_color} to "%{_color}%§%first character of loop-value-2%"
continue
{_keywords::%loop-value%} is set
set {_ignore} to true
set {_item} to {_items::%loop-value%}
set {_name} to name of {_item}
if {_name} is not set:
set {_name} to a translate component from {_item}
set {_amount} to item amount of {_item}
if max stack of {_item} is 1:
set {_itemtext} to "{@unstackable item format}"
else:
set {_itemtext} to "{@item format}"
replace "{name}" with "%{_name}%" in {_itemtext}
replace "{amount}" with "%{_amount}%" in {_itemtext}
set {_itemtext} to a text component of {_itemtext}
set hover event of {_itemtext} to a hover event showing item {_item}
set {_message::%loop-index%} to {_itemtext}
delete {_name}
# finally, send the message
set {_format1} to {_format::1}
delete {_format::1}
send components {_format1}, {_message::*} and "%{_color}%%join {_format::*} with message%" to all players
send {_format} to console