Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with writing quotes in json #90

Closed
Pex666 opened this issue Mar 6, 2024 · 11 comments
Closed

problem with writing quotes in json #90

Pex666 opened this issue Mar 6, 2024 · 11 comments
Labels
3.0.0 bug Something isn't working investigate Solved Solved problems

Comments

@Pex666
Copy link

Pex666 commented Mar 6, 2024

I'm trying to save nbt in one line, but if nbt is too large, then get this (pic)

skript
skjson

SkJson v3.0.3
Skript v2.8.2
SkBee v3.3.0

@cooffeeRequired cooffeeRequired added bug Something isn't working investigate 3.0.0 labels Mar 6, 2024
@cooffeeRequired
Copy link
Owner

Thank you, ill check it now

@cooffeeRequired
Copy link
Owner

Hello there.
Can you provide the code snippet? I cannot replicate that.

@Pex666
Copy link
Author

Pex666 commented Mar 9, 2024

Hello!

command /addtrade:
permission: OP
trigger:
set {_jt} to json from file "/plugins/Skript/scripts/json/trader.json" # this is my json file
set {_slot0} to full nbt compound of slot 0 of player
set {_slot1} to full nbt compound of slot 1 of player
set {_slot2} to full nbt compound of slot 2 of player
set {_n} to 0
loop values "trade::%{_n}%" of {_jt}:
set {_n} to json-key parsed as integer
add 1 to {_n}
set value of json object "trade::0::%{_n}%::0::nbt" in {_jt} to "'%{_slot0}%'"
set value of json object "trade::0::%{_n}%::1::nbt" in {_jt} to "'%{_slot1}%'"
set value of json object "trade::0::%{_n}%::2::nbt" in {_jt} to "'%{_slot2}%'"
write {_jt} to json file "/plugins/Skript/scripts/json/trader.json"

But! you need an already existing json file
fore example: trader.json:

{
"trade": [
{
"1": [
{
"nbt": "{Count:32b,id:"minecraft:arrow"}"
},
{
"nbt": "{Count:8b,id:"minecraft:emerald"}"
},
{
"nbt": "{Count:16b,id:"minecraft:tipped_arrow",tag:{Potion:"minecraft:weakness"}}"
}
]}]}

@cooffeeRequired
Copy link
Owner

Hello!

command /addtrade: permission: OP trigger: set {_jt} to json from file "/plugins/Skript/scripts/json/trader.json" # this is my json file set {_slot0} to full nbt compound of slot 0 of player set {_slot1} to full nbt compound of slot 1 of player set {_slot2} to full nbt compound of slot 2 of player set {_n} to 0 loop values "trade::%{_n}%" of {_jt}: set {_n} to json-key parsed as integer add 1 to {_n} set value of json object "trade::0::%{_n}%::0::nbt" in {_jt} to "'%{_slot0}%'" set value of json object "trade::0::%{_n}%::1::nbt" in {_jt} to "'%{_slot1}%'" set value of json object "trade::0::%{_n}%::2::nbt" in {_jt} to "'%{_slot2}%'" write {_jt} to json file "/plugins/Skript/scripts/json/trader.json"

But! you need an already existing json file fore example: trader.json:

{ "trade": [ { "1": [ { "nbt": "{Count:32b,id:"minecraft:arrow"}" }, { "nbt": "{Count:8b,id:"minecraft:emerald"}" }, { "nbt": "{Count:16b,id:"minecraft:tipped_arrow",tag:{Potion:"minecraft:weakness"}}" } ]}]}

Thank you, can you provide also those itemns? or Skript what will generate those with the nbts?

@Pex666
Copy link
Author

Pex666 commented Mar 9, 2024

Sorry, I didn't understand a little

you need to put items in the slots in the game
enter the command and you get the following Json Object

@Pex666
Copy link
Author

Pex666 commented Mar 9, 2024

just try inserting regular items and then using items with multiple enchantments and custom names

@cooffeeRequired
Copy link
Owner

i mean the items what containts the nbts.

@Pex666
Copy link
Author

Pex666 commented Mar 9, 2024

all items contain nbt, but the more information an item contains, such as enchantments or custom names, custom tags, the more nbt it contains

"6": [
{
"nbt": "{Count:16b,id:"minecraft:diamond"}"
},
{
"nbt": "{Count:64b,id:"minecraft:emerald"}"
},
{
"nbt": "{Count:1b,id:"minecraft:bow",tag:{Damage:0,Enchantments:[{id:"minecraft:flame",lvl:1s},{id:"minecraft:infinity",lvl:1s},{id:"minecraft:power",lvl:3s},{id:"minecraft:unbreaking",lvl:3s}]}}"
}
]

@cooffeeRequired
Copy link
Owner

Thank you

@cooffeeRequired
Copy link
Owner

cooffeeRequired commented Mar 18, 2024

Hello there, Checked that and the result is, the parser will try sanitize them

image

but you actually did it you put the ' here

image

@cooffeeRequired
Copy link
Owner

image

command /addtrade:
    permission: OP
    trigger:
        set {_jt} to json from file "plugins/SkJson/test.json" # this is my json file
        set {_slot0} to full nbt compound of slot 0 of player
        set {_slot1} to full nbt compound of slot 1 of player
        set {_slot2} to full nbt compound of slot 2 of player
        set {_n} to 0

        send {_jt} with pretty print to console

        write {_jt} to json file "plugins/SkJson/trader.json"
        loop values "trade::%{_n}%" of {_jt}:
            send json-key to console
            set value of json object "trade::0::%{_n}%::0::nbt" in {_jt} to {_slot0}
            set value of json object "trade::0::%{_n}%::1::nbt" in {_jt} to {_slot1}
            set value of json object "trade::0::%{_n}%::2::nbt" in {_jt} to {_slot2}
        write {_jt} to json file "plugins/SkJson/trader.json"

works perfectly fine

@cooffeeRequired cooffeeRequired added the Solved Solved problems label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0.0 bug Something isn't working investigate Solved Solved problems
Projects
None yet
Development

No branches or pull requests

2 participants