Last active
January 20, 2018 10:30
-
-
Save Snow-Pyon/6b6e78e2381fa845977513746b8e33b7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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