Skip to content

Releases: cooffeeRequired/skJson

Small fixes

28 Apr 08:06
Compare
Choose a tag to compare

SkJson 2.8.4 💥

Doc's updated (SkUnity, SkriptHub)

Skript version:

  • 2.7.0 - Beta 1,
  • 2.7.0 - Beta 2,
  • 2.6.4

Changed

  1. small changes was also in the Execute web request
(execute|send|make) [new] (<.+>|%-string%) request to %string% [(:with headers) %-strings/json%] [and with (:body|:data) %-strings/json%]
(execute|send|make) [new] (<.+>|%-string%) request to %string% [with (:body|:data) %-strings/json%] [and (:with headers) %-strings/json%]

Fixed

  1. size of %json% -> json size of %json%, cause old syntax has conflict with vanilla skript
  2. fixed block thread in the async method for sending request's and wriiting to file
  3. mapping and formatting json to/from variable

Added

  1. Added convertation from .yml files to .json
set {_yaml json} to json from yaml file "..../test.yaml"
  1. more properties of request's responses
[SkJson] [(:current|:previous)] request's (2:body|3:code|4:connection headers|[user] (5:headers)|6:url)
[skJson] (2:body|3:code|4:connection headers|[user] (5:headers)|6:url) of [(:current|:previous)] request

image

image

What's Changed

Full Changelog: 2.8.2...2.8.4

Thank everyone for their support for ideas

Sincerely coffeeRequred.

Small fixes

11 Apr 14:26
Compare
Choose a tag to compare

SkJson 2.8.2 💥

Skript version: 2.7.0 - Beta, 2.6.4 supported

Updated examples, added examples for JsonChanger, also Using @NoDoc for Expression which are only auxiliary. also fixed bug which caused that longer strings were not saved to cached json.. also modified debug system.

Fixed

  1. HtmlEscaping & Nested Headers
  2. json %json% is empty
  3. fix url encoded POST data, instead of Query
  4. Encoded json POST data was sended with incorrect HTTP header
  5. Fix url with & no longer translate to color

Now you don't need to use cached in the expressions, now its optional [cached] json [id] %string% is listen

Thank everyone for their support for ideas

Sincerely coffeeRequred.

Full Changelog: 2.8.1...2.8.2

2.8.1

07 Apr 19:41
Compare
Choose a tag to compare

SkJson 2.8.1 💥

Skript version: 2.7.0 - Beta, 2.6.4 supported

Fixed

  1. HtmlEscaping & Nested Headers
  2. json %json% is empty
  3. fix url encoded POST data, instead of Query
  4. Encoded json POST data was sended with incorrect HTTP header

Add syntaxes

json list %string% in %json%
(:keys|:values) of json object [%-string%] in %json%

Examples

#1
set {_json} to json from text "{'A': 'B', 'C': [1,2,3]}"
send json list "C" in {_json}
if json list "C" in {_json} contains 1:
   send true
   
#2
set {_json} to json from text "{'A': 'B', 'C': [1,2,3], 'W': {'some1': 1, 'some2': 2}}"
send values of json object "W" in {_json}

if values of json object "W" contains 1:
   send true

Thank everyone for their support for ideas

Sincerely coffeeRequred.

What's Changed

Full Changelog: 2.8.12...2.8.1

Bug Fixing

26 Mar 09:14
Compare
Choose a tag to compare

image

SkJson 2.8.0-b1 💥

Skript version: 2.7.0 - Beta, 2.6.4 supported

The biggest changes

ADD write %object% to json file %string%

Fix inventoryTitle issue.

Fix not loading on Skript 2.6.4

Fix inventory was stored incorrectly.

Added check directly keys of json

Fix issue #41 (NestedKeys)

Thank everyone for their support for ideas

Sincerely coffeeRequred.

Full Changelog: 2.7.0...2.8.12

skJson 2.8.0 The gameChanging.

17 Mar 20:12
Compare
Choose a tag to compare
Pre-release

image

SkJson 2.8.0 💥

Skript version: 2.7.0 - Beta supported

The biggest changes

Json Changer 🟡

  • ADD : Now using add you will be able to add values only to the json sheet. Here is an example of the syntax. add player's location to json list "pathxys" in {_json}
  • SET : Now with set you will be able to add values to json object or to set, here is an example of syntax set json value "test:A" in {_json} to diamond sword, While A is the value of the key, so always the last element in the string is the definition of the key.
  • REMOVE : Now using remove you will be able to remove using key or using values or using the defined index of the JsonArray case.
    Here are some example syntax.
    1 : remove diamond sword from {_json}
    2 : remove 2nd element from json list "pathxys" in {_json}
    3 : remove player's location from json list "pathxys" in {_json}
    4 : remove "hello" from keys of json object "pathxys" in {_json}
    5 : remove diamond sword from values of json object "pathxys" in {_json} \

Summary: removed append, change and also changed the way adding and removing elements from json works. Since We already have storage addons that have a syntax like skript-yaml, I decided to do this in order to make it as user friendly as possible.


Json Parser 🟡

  • The first and most important mention is that objects obtained from json will be automatically parsed, now you don't need to do any parsed %json%.
    Here's an example of a location object representation.
    Input : set {_json} to json from location(0,0,1, world "world")
    Json
{
    "==": "org.bukkit.Location",
    "world": "world",
    "x":0.0,
    "y":0.0,
    "z":1.0,
    "pitch":0.0,
    "yaw":0.0
}

Output : x: 0, y: 0, z: 1, yaw: 0, pitch: 0 in 'world'

JsonWatcher 🔘

  • What does that mean? Practically it means that you can listen the file (if the file changes, your json loaded in memory changes.)
  • Example syntax
    1 : make jsonwatcher listen to "test"
    2 : stop jsonwatcher listen to "test"
    3 : link json file "plugins/raw/raw.json"
    4 : link json file "plugins/raw/raw.json" and make json watcher listen

Example.

on load:
    link json file "plugins/raw/raw.json" as "test"
    make jsonwatcher listen to "test"

command listenedJson:
    trigger:
        send cached json "test"

JsonRequest (POST|GET) 🔘

  • What does that mean? This means that you no longer need external libraries in this version. skJson will be able to report POST/GET requests.
    1 : execute GET request to "https://dog.ceo/api/breeds/image/random%20Fetch!" with headers '{"json-encode+": "true"}'
    2 : execute POST request to "https://dog.ceo/api/breeds/image/random%20Fetch!" with headers '{"json-encode+": "true"}' and with body '{"user": "%player%"}'
    3 : set {_body} to request's body

Conditions 🔴

  • Json file is listening

    • [cached] json [id] %string% is listen
    • [cached] json [id] %string% is(n't| not) listen
  • Json file is cached

    • cached json %string% is (load|linked)
    • cached json %string% is(n't| not) (load|linked)
  • Json file is empty

    • json file %string% is empty
    • json file %string% is(n't| not) empty
  • Json file exists

    • json [file] %string% [already] exists
    • json [file] %string% [already] does(n't| not) exists
  • Json has value/key

    • %json% has (:value|:key)[s] %objects%
    • %json% does(n't| not) have (:value|:key)[s] %objects%
  • Type of json

    • type of %json% (is|=) (1:primitive|2:[json]object|3:array)
    • type of %json% (is(n't| not)|!=) (1:primitive|2:[json]object|3:array)

Effects 🔵

  • Link json file with defined cache.

    You can works with the cache instead of reopening the file again & again.
    • link [json] file %string% as %string% [(:and make) [json]watcher listen]
  • JsonWatcher - Start listening to file

    You can register listener for json file, and while the file is updated the cache for this file will be also so.
    • make [json]watcher listen to %string%
  • Save cached json to file

    It's allow save cached json back to the file
    • [:async] save cached json %string%
    • [:async] save all cached jsons
  • JsonWatcher - Stop listening to file%

    That will stop listen file for given id
    • stop [json]watcher listen to [id] %string%
  • UnLink or Unload json file

    You can unload the json file.
    • unlink json %string%
  • change json file

    You can change json file.
    • [:async] change (:value|:key) %string% of (%-jsonfile/string%|(:json file) %-string%) to %objects%
  • New json file

    You can create a new json file.
    • [:async] new json file %string% [(:with) (object|content)[s] %-object%]
  • Map json to skript list

    Mapping json to the List and get those values
    • (map|copy) %json/string% to %objects%
  • Execute a http (post|get) request

    You can execute a web request to rest api. with json encoded body/headers
    • execute GET request to %string% [(:with headers) %-string/json%]
    • execute POST request to %string% [:(with headers) %-string/json%] [[and] [with] (:body) %-string/json%]

Expressions 🟢

  • Get cached json

    You can get json from cached internal storage by with a key defined by you
    • cached json %string%
  • All cached jsons

    That will return jsons from your cache.
    • all cached jsons
  • Count of objects/phrases

    You can get the exact number of identical keys or values from the entire json because count of works recursively.
    • (count|number) of (:key|[value]) %object% in %json%
  • Elements/Values of the json

    You can get the main json values, or you can also get the use values for a given object/array you can also get a single value
    loop-value, loop-element, loop-key
    Means : -> entries entries mean the entry for the looped element, for example we have element {"B": false}its entry will be loop-key = B, loop-element = false, loop-value = {B=false} !Warnings: loop-key or loop-element you can use only for entries! LOOP-PATTERNS ->
    loop-value, loop-element, loop-key
    • (value|element) %string% of %object%
    • (values|elements) [%-string%] of %object%
    • entr(y|ies) [%-string%] of %object%
  • Json size of current element

    • %json% size
  • New json

    It's allow create json from any source also from the file
    • json[s] from [text|string] %object%
    • json from [json] file %string%
    • [empty] json(-| )(0:array|1:object)
  • Pretty json

    Allows you to better parse json
    • %json% with pretty print
  • Array or List formatted to JSON.

    It allows you to convert the sheet back to Json! Value changes don't work for nested objects, to change the values of a nested object use Change
    • form[atted json]", "objects"
  • JsonRequest - request body

    • [SkJson] [current] request's body
    • [skJson] body of [current] request

Types 🟠

  • JsonElement

    Represent the json class
  • JsonFile

    Represent the json file class

Functions

  • Object/String path to JsonFile

    Convert path string for e.g. "plugins/raw/raw.json"
    • jsonfile("plugins/raw/raw.json")

Thank everyone for their support for ideas

Sincerely coffeeRequred.

Bug fixing ItemStack, CustomModelData, Encoding, Performance, CleanUP

22 Feb 17:28
Compare
Choose a tag to compare

skJson 2.7.0⚠️

Introduce 🟢

Hello everyone.

  • Fix small bugs #26 #24 #23 #22 #21 #20
  • Merges #27 #28
  • Fixed bundles
  • Cleanup code
  • fix Typos
  • fix issue with null in JsonInventory

Example

{
  "items": [
      {"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate\"}],\"text\":\"\"}","custom-model-data":1}},
      {"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate2\"}],\"text\":\"\"}","custom-model-data":1}},
      {"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate3\"}],\"text\":\"\"}","custom-model-data":1}}

  ],
  "nums": [
    1,
    2,
    3,
    0
  ]
}
command try:
    trigger:
        set {_} to json from file "items/test.json"
        send {_}
        remove json object player's tool from nested object "items" of {_}
        remove json index 1 from nested object "nums" of {_}
        send {_} with pretty print
  • Fixed olders issue contains invalid mapping or invalid converting to the json.
  • Also fixed issue what should remove the meta from the ItemStack, which should not be removed.
  • Also fixed issue with CustomModelData contains id of model was lost from converting to json.
  • Path-Hotlinking will not added because it's necessary use that hotlink instead link file instead.
  • #13 null as new Data (Bug) was fully fixed -> Will apear error when you tried converting null json to the object.
  • #15 fully supported new syntax for remove json from nested object.
  • #18 - Item Conversion. When you put item to the Skript list and then you want retrieve it as json form, you got broken json from BukkitSerilization instead of our json normal representation, Example Bellow

Skript Code

add diamond sword, apple, stone pickaxe to {_map::*}
send {_map::*}'s form

Broken

{
   "types": [
    {
      "isAnything": false,
      "itemForm": false,
      "isAlias": false,
      "plain": false,
      "itemFlags": 2
    }
  ],
  "all": false,
  "amount": -1
}

Fixed

[
    {
        "==": "org.bukkit.inventory.ItemStack",
        "v": 3218,
        "type": "DIAMOND_SWORD"
    },
    {
        "==": "org.bukkit.inventory.ItemStack",
        "v": 3218,
        "type": "APPLE"
    },
    {
        "==": "org.bukkit.inventory.ItemStack",
        "v": 3218,
        "type": "STONE_PICKAXE"
    }
]
  • #19 UTF-8 encoding error, Fixed
  • #20 Item-Data encoding error, Fixed
  • #24 Bundle(Custom model Data) lost, Fixed (Minecraft 1.19+)

PLEASE READ THE NEW SYNTAXE'S! on the Skript hub

Please check SkriptHub or Wikipedia for syntax changes.

❌ If you found any bugs, feel free to post it.

Sincerely, Coffee. 👋

Full Changelog: 2.6.0...2.7.0

FIx removing unparsed object from json array

18 Feb 10:20
Compare
Choose a tag to compare

skJson pre-release 2.7.0⚠️

Introduce 🟢

Hello everyone.

Example

{
  "items": [
      {"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate\"}],\"text\":\"\"}","custom-model-data":1}},
      {"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate2\"}],\"text\":\"\"}","custom-model-data":1}},
      {"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate3\"}],\"text\":\"\"}","custom-model-data":1}}

  ],
  "nums": [
    1,
    2,
    3,
    0
  ]
}
command try:
    trigger:
        set {_} to json from file "items/test.json"
        send {_}
        remove json object player's tool from nested object "items" of {_}
        remove json index 1 from nested object "nums" of {_}
        send {_} with pretty print

Please check SkriptHub or Wikipedia for syntax changes.

❌ If you found any bugs, feel free to post it.

Sincerely, Coffee. 👋

Full Changelog: 2.6.21...pre-release-2.7.0

Item Conversion in JSON (Form of Skript list) Supported!

01 Feb 10:58
Compare
Choose a tag to compare

skJson 2.6.21⚠️

Introduce 🟢

Hello everyone.

New conventors for json.

  • Fix small bugs, #18
  • Cleanup code
  • fix Typos

Fixed.

command try:
    trigger:
        set {_test::*} to diamond sword named "&aA", apple, stone pickaxe
        broadcast {_test::*}'s form with pretty print

        set {_test::item1} to diamond sword named "&aA"
        set {_test::item2} to stone pickaxe
        set {_test::item3} to apple

        broadcast {_test::*}'s form with pretty print
on load:
    execute console command "try"

Please check SkriptHub or Wikipedia for syntax changes.

❌ If you found any bugs, feel free to post it.

Sincerely, Coffee. 👋

Full Changelog: 2.6.2...2.6.21

skJson 2.6.2 Support java 11, Automatic parsing

25 Jan 15:20
Compare
Choose a tag to compare

skJson 2.6.2⚠️

Introduce 🟢

Hello everyone.

New conventors for json.

  • Adding automatic parsing.
  • Cleanup code
  • fix Typos

From

command test:
    trigger:
        set {_loc-json} to json from player's location
        set {_loc} to {_loc-json} parsed as a location
        teleport player to {_loc}

To

command test:
    trigger:
        set {_loc-json} to json from player's location
        teleport player to {_loc-json}

Please check SkriptHub or Wikipedia for syntax changes.

❌ If you found any bugs, feel free to post it.

Sincerely, Coffee. 👋

What's Changed

Full Changelog: 2.6.1...2.6.2

Mapping / Append issues - Fixed.

23 Jan 01:21
Compare
Choose a tag to compare

skJson 2.6.1⚠️

Introduce 🟢

Hello everyone.
Hotfixed issue #11 , also the #13
Also was fixed all mapping / append / write issues.

Please check SkriptHub or Wikipedia for syntax changes.

❌ If you found any bugs, feel free to post it.

Sincerely, Coffee. 👋

Full Changelog: 2.6.0...2.6.1