Last active
July 24, 2019 12:58
-
-
Save Blueyescat/93b613fe034b9bba7a66e9f93dbd2cfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSkriptColor(color: text) :: text: | |
replace all "_" with " " in {_color} | |
if {_color} is "green", "aqua" or "red": | |
return colored "<light %{_color}%>" | |
else if {_color} is "blue": | |
return "&9" | |
return colored "<%{_color}%>" | |
function jsonComponentToText(jso: jsonobject) :: text: | |
map json "%{_jso}%" to {_json::*} | |
set {_text} to "" | |
loop {_json::extra::*}: | |
loop {_json::extra::%loop-index%::*}: | |
if loop-index-2 is "color": | |
set {_color} to getSkriptColor(loop-value-2) | |
else if loop-index-2 is "text": | |
if {_color} is not set: | |
set {_color} to "" | |
set {_text} to "%{_text}%%{_color}%%loop-value-2%" | |
return {_text} | |
function getJsonComponent(message: text) :: jsonobject: | |
set {_component::text} to {_message} | |
return json of listvar {_component::*} | |
on packet event play_server_chat: | |
set {_component} to "chatcomponent" pjson 0 of event-packet | |
if {_component} is not set: | |
stop | |
# test | |
set {_message} to jsonComponentToText({_component}) | |
replace all "§" with "&" in {_message} | |
set chatcomponent pjson 0 of event-packet to getJsonComponent({_message}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment