Skip to content

Instantly share code, notes, and snippets.

@Snow-Pyon
Last active January 20, 2018 10:30
Show Gist options
  • Save Snow-Pyon/6b6e78e2381fa845977513746b8e33b7 to your computer and use it in GitHub Desktop.
Save Snow-Pyon/6b6e78e2381fa845977513746b8e33b7 to your computer and use it in GitHub Desktop.
function toSkriptColor(color: text) :: text:
if {_color} contains "_":
replace all "_" with " " in {_color}
return {_color}
else if {_color} isn't "black", "white", "yellow" or "gold":
return "light %{_color}%"
else:
return {_color}
function toReadableText(json: jsonobject) :: text:
put json {_json} in listvar {_json::*}
loop tree of {_json::extra::*}:
if branch contains "color":
set {_color} to toSkriptColor("%loop-value%")
set {_color} to "<%{_color}%>"
else if branch contains "text":
if {_color} isn't set:
set {_color} to ""
add "%{_color}%%loop-value%" to {_full-text::*}
return join {_full-text::*} by ""
#This is just to make sure it wont crash the server
on command:
if command command's main command is "skript":
set {_arguments::*} to arguments split by " "
if {_arguments::1} is "reload":
set {script-reloading} to true
wait 1 second
clear {script-reloading}
on packet event play_server_chat:
{script-reloading} is set
set {_message} to toReadableText("chatcomponent" pjson 0 of event-packet)
if {_message} parsed as "%text%: %text% \(%text%.sk, line %number%: %text%'\)" is set:
set {_receivers::*} to all ops and console
remove player from {_receivers::*}
send "<light red>Global Error<grey>: <reset>%{_message}%" to {_receivers::*}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment