Oxalist

Untitled

Dec 8th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. function getJSON(item: item, name: text, message: text) :: text:
  2. set {_nbt} to "%nbt of {_item}%"
  3. if {_nbt} is "{}":
  4. set {_nbt} to ""
  5. else:
  6. set {_nbt} to ", tag: %{_nbt}%"
  7. replace all "'" with "" in {_nbt}
  8. replace all """" with "" in {_nbt}
  9. replace all "%{_message}%" with "&eΒ»&r %{_name}% &eΒ«&r" in {_message}
  10. #set {_message} to convert text {_message} to unicode
  11. set {_json} to "{""text"": ""%{_message}%"", ""hoverEvent"": {""action"": ""show_item"", ""value"": ""{id: %minecraft id of {_item}%, Damage: %data of {_item}%%{_nbt}%}""}}"
  12. return {_json}
  13.  
  14. on chat:
  15. if message contains "[hand]", "[offhand]", "[helmet]", "[chestplate]", "[leggings]", "[boots]" or "[slot:]":
  16. if message contains "[hand]":
  17. add player's current hotbar slot to {_items::*}
  18. add "[hand]" to {_keywords::*}
  19. if message contains "[offhand]":
  20. if "%bukkit version%" doesn't contain "1.8":
  21. add 40 to {_items::*}
  22. add "[offhand]" to {_keywords::*}
  23. if message contains "[helmet]":
  24. add 39 to {_items::*}
  25. add "[helmet]" to {_keywords::*}
  26. if message contains "[chestplate]":
  27. add 38 to {_items::*}
  28. add "[chestplate]" to {_keywords::*}
  29. if message contains "[leggings]":
  30. add 37 to {_items::*}
  31. add "[leggings]" to {_keywords::*}
  32. if message contains "[boots]":
  33. add 36 to {_items::*}
  34. add "[boots]" to {_keywords::*}
  35. if size of {_keywords::*} > 0:
  36. cancel event
  37. loop {_keywords::*}:
  38. set {_keyword} to loop-value
  39. set {_rawMessages::*} to message split at "%{_keyword}%"
  40. set {_temp} to {_rawMessages::1}
  41. delete {_rawMessages::1}
  42. set {_rawMessage} to "%{_temp}%%{_keyword}%%join {_rawMessages::*} with """"%"
  43. set message to {_rawMessage}
  44. loop {_keywords::*}:
  45. set {_index} to "{I2C}:{%loop-index%}:{I2C}"
  46. replace all loop-value with {_index} in message
  47. set {_rawMessages::*} to message split at "{I2C}"
  48. loop {_rawMessages::*}:
  49. if "%loop-value%" doesn't contain ":{1}:", ":{2}:", ":{3}:", ":{4}:", ":{5}:" or ":{6}:":
  50. set {_rawMessages::%loop-index%} to "{""text"": ""%loop-value%""}"
  51. set {_rawMessage} to join {_rawMessages::*} with ", "
  52. loop {_items::*}:
  53. delete {_name}
  54. set {_slot} to loop-value
  55. set {_item} to slot {_slot} of player's inventory
  56. if {_item} is not air:
  57. set {_name} to name of slot {_slot} of player's inventory
  58. if {_name} is not set:
  59. set {_name} to "%minecraft id of {_item}%"
  60. replace all "minecraft:" with "" in {_name}
  61. replace all "_" with " " in {_name}
  62. set {_name} to 1st char in each word of {_name} to caps
  63. set {_json} to getJSON({_item}, {_name}, {_keywords::%loop-index%})
  64. replace all ":{%loop-index%}:" with {_json} in {_rawMessage}
  65. else:
  66. replace all ":{%loop-index%}:" with "{""text"": ""%{_keywords::%loop-index%}%""}" in {_rawMessage}
  67. set {_message::*} to message format split at "%%2$s"
  68. replace all "%%1$s" with player's display name in {_message::1}
  69. set {_message::1} to convert string {_message::1} to unicode
  70. execute console command "tellraw @a [{""text"": ""%{_message::1}%""}, %{_rawMessage}%]"
Add Comment
Please, Sign In to add comment