Professional Documents
Culture Documents
#
#
#
#
#
#
#
#
#
#
#
json.sk by RezzedUp
--Version: 2.2
Requires: Skript 2.2
--Contributors:
- RezzedUp
- JKGamerxD
General usage:
==> json(<recipient>, <text in json.sk format>, <OPTIONAL: whether or not to
convert color codes>) :: returns nothing
#
#
#
This function handles everything you could ever need regarding json.
Everything is automatic with it, you just need to provide the proper
json.sk notatation and someone to recieve the message!
#
#
--> example #1:
#
set {_to} to "@a"
#
set {_msg} to "&6Hello, this is a &ejson message&6!||ttp:&b&oSup
er duper cool!||cmd:/msg RezzedUp You rock!!!!"
#
json({_to}, {_msg})
#
#
--> example #2:
v [NEW]
#
json("%player%", "&6:D||&5Neat", false)
#
^
#
json.sk won't convert color c
odes if set to false.
#
If no value is set, it will c
onvert color codes by default.
#
# ==> jsonFormat(<text in json.sk format>) :: returns text
#
#
The purpose of this function is to return the formatted peice of jso
n for your own use.
#
You can set up your own /tellraw with it
#
#
--> example:
#
set {_toBeJson} to "I will return a json!||ttp:It's true!"
#
set {_jsonText} to jsonFormat({_toBeJson})
#
execute console command "/tellraw myUserName %{_jsonText}%"
#
#
# JSON.SK NOTATION:
# --> How to create json's!
#
# <always start with normal text>||<3 letter tag>:<text>||<regular text, new j
son cluster>
#
^
#
"||" separates each segment.
#
# json.sk notation follows these rules:
#
1. A cluster of json is formed at each regular text segment.
#
2. There may be only one hoverable and one clickable event per cluster,
otherwise things could get messy.
#
3. Json effects are defined by a 3 letter tag at the very start of a seg
ment, followed directly by a colon.
#
4. "||" should only ever be used to separate each json segment.
#
# Json Effect Tags:
#
ttp:
#
--> Tooltip, hover event
#
cmd:
#
--> Run command, click event
#
sgt:
#
--> Suggest command, click event
#
url:
#
--> Open url, click event
#
ins:
#
--> Adds an "insertion", shift + click event
#
| For more information about the "insertion" attribute, visit
#
| http://www.minecraftforum.net/forums/minecraft-discussion/redston
e-discussion-and/351959#insertion
#
# Example json.sk notation:
#
#
#
"Hello, this is a sample json.||ttp:&bI'm a tooltip for the first cluste
r.||There's no tag, so I've started a new cluster.||cmd:/ping"
#
|______________________________________________________________________
_| |_______________________________________________________|
#
|
|
#
JSON Cluster #1
JSON Cluster #2
#
#
#
The above json.sk notation purely as their segment types:
#
#
"<
regular text
>||<ttp:
tooltip
>||<
regular text, starting a new cluster
>||<cmd:/command>"
options:
debug: false
codes: 0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|k|l|m|n|o|r
#
#
#
#
#
#
if loop-value-2 is {_char}:
set {_skip} to true
if {_skip} is set:
delete {_skip}
else:
set {_new} to "%{_new}%%{_char}%"
return {_new}
#
#
#
#
#
FUNCTION: Replace all `&` color codes with valid JSON color codes.
-> Usage:
Used by json functions to convert color codes.
if {_clusters::%{_i}%::command} is set:
set {_clickable} to "%{_json}%,""clickEvent"":{""action"":""run_comm
and"",""value"":""%{_clusters::%{_i}%::command}%""}"
if {_clusters::%{_i}%::suggest} is set:
set {_clickable} to "%{_json}%,""clickEvent"":{""action"": ""suggest
_command"",""value"": ""%{_clusters::%{_i}%::suggest}%""}"
if {_clusters::%{_i}%::url} is set:
set {_clickable} to "%{_json}%,""clickEvent"":{""action"": ""open_ur
l"",""value"": ""%{_clusters::%{_i}%::url}%""}"
if {_clickable} is set:
set {_json} to "%{_clickable}%}"
delete {_clickable}
else:
set {_json} to "%{_json}%}"
return "[{""text"":""""},%{_json}%]" # \\\""""
#
#
#
#
#