D4_

ChatItem.sk Code

D4_
Sep 4th, 2020 (edited)
150
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #------------------
  2. # ChatItem
  3. # - Version 1.7.1
  4. # - Created by D4isDAVID
  5. #------------------
  6. # Dependencies:
  7. # - Minecraft 1.9+
  8. # - Skript 2.5.3+
  9. # - SkBee 1.10.1+
  10. #------------------
  11. # Config
  12. options:
  13.     # itemName - how the item name will look like in chat. default: &8[&r{name}&r &7x{amount}&8]&r
  14.     # {name} is the item name and {amount} is the amount of the item
  15.     itemName: &8[&r{name}&r &7x{amount}&8]&r
  16. #------------------
  17.  
  18. on chat:
  19.     set {_slotList::hand} to index of player's hotbar slot
  20.     set {_keywordList::hand::*} to "[hand]", "[item]" and "[i]"
  21.     set {_slotList::offhand} to 40
  22.     set {_keywordList::offhand::*} to "[offhand]"
  23.     set {_slotList::helmet} to 39
  24.     set {_keywordList::helmet::*} to "[helmet]", "[helm]", "[cap]" and "[head]"
  25.     set {_slotList::chestplate} to 38
  26.     set {_keywordList::chestplate::*} to "[chestplate]", "[tunic]" and "[chest]"
  27.     set {_slotList::leggings} to 37
  28.     set {_keywordList::leggings::*} to "[leggings]", "[pants]" and "[legs]"
  29.     set {_slotList::boots} to 36
  30.     set {_keywordList::boots::*} to "[boots]", "[feet]"
  31.     loop indices of {_keywordList::*}:
  32.         loop {_keywordList::%loop-value%::*}:
  33.             message contains loop-value-2
  34.             add {_slotList::%loop-value-1%} to {_items::*}
  35.             add loop-value-2 to {_keywords::*}
  36.             exit 1 loop
  37.     if size of {_keywords::*} > 0:
  38.         cancel event
  39.         set {_message} to message
  40.         loop {_keywords::*}:
  41.             loop indices of {_keywordList::*}:
  42.                 {_keywordList::%loop-value-2%::*} contains loop-value-1
  43.                 loop {_keywordList::%loop-value-2%::*}:
  44.                     loop-value-3 is not loop-value-1
  45.                     replace all loop-value-3 with "" in {_message}
  46.             set {_messages::*} to {_message} split at "%loop-value%"
  47.             set {_temp} to {_messages::1}
  48.             delete {_messages::1}
  49.             set {_message} to "%{_temp}%%loop-value%%join {_messages::*} with """"%"
  50.             replace all loop-value with "{CIplaceholder}:{%loop-index%}:{CIplaceholder}" in {_message}
  51.         set {_messages::*} to {_message} split at "{CIplaceholder}"
  52.         loop {_messages::*}:
  53.             set {_messages::%loop-index%} to a new text component of "%loop-value%"
  54.             "%loop-value%" is ":{1}:", ":{2}:", ":{3}:", ":{4}:", ":{5}:" or ":{6}:"
  55.             set {_itemIndex} to subtext of "%loop-value%" from characters 3 to 3
  56.             set {_itemIndexes::%{_itemIndex}%} to loop-index
  57.         loop {_items::*}:
  58.             delete {_name}
  59.             set {_item} to loop-value
  60.             if {_item} is a number:
  61.                 set {_item} to slot {_item} of player's inventory
  62.             if {_item} is not set:
  63.                 set {_messages::%{_itemIndexes::%loop-index%}%} to a new text component of "%{_keywords::%loop-index%}%"
  64.             else if {_item} is not air:
  65.                 set {_name} to name of {_item}
  66.                 if {_name} is not set:
  67.                     set {_name} to a new translate component from {_item}
  68.                 set {_amount} to amount of {_item} in player's inventory
  69.                 set {_itemName} to "{@itemName}"
  70.                 replace "{name}" with "%{_name}%"  in {_itemName}
  71.                 replace "{amount}" with "%{_amount}%" in {_itemName}
  72.                 set {_itemName} to a new text component of "%{_itemName}%"
  73.                 set hover event of {_itemName} to a new hover event showing {_item}
  74.                 set {_messages::%{_itemIndexes::%loop-index%}%} to {_itemName}
  75.             else:
  76.                 set {_messages::%{_itemIndexes::%loop-index%}%} to a new text component of "%{_keywords::%loop-index%}%"
  77.         set {_messageFormat::*} to message format split at "[message]"
  78.         replace "[player]" with player's display name in {_messageFormat::1}
  79.         if message format contains message:
  80.             set {_messageFormat::*} to message format split at message
  81.         set {_temp} to a new text component of "%{_messageFormat::1}%"
  82.         delete {_messageFormat::1}
  83.         loop all players:
  84.             send components {_temp}, {_messages::*} and {_messageFormat::*} to loop-player
  85.         send components {_temp}, {_messages::*} and {_messageFormat::*} to console
RAW Paste Data