[SOLVED] Problems with JSON Raw on stuff related commands (tellraw) on mineos_console.js


I am trying to set a crontab with a tellraw command.

Well, If I use a “simple” tellraw, I dont have problems:
/usr/games/minecraft/mineos_console.js -s server stuff 'tellraw @a "Hello"'

If I use a “complex” tellraw, I dont have problems:
/usr/games/minecraft/mineos_console.js -s server stuff 'tellraw @a {"text":"!!!!","bold":true,"obfuscated":true,"color":"gold"}'

But I have problems if I use a “complex” tellraw with special characters like " " (whitespaces) or “\” bars.
/usr/games/minecraft/mineos_console.js -s server stuff 'tellraw @a {"text":"I dont work","bold":true,"obfuscated":true,"color":"gold"}'

All of them works on Minecraft and if i execute screen command manually It works too:
screen -s mc-UnionLU -p 0 -X stuff 'tellraw @a {"text":"I dont work","bold":true,"obfuscated":true,"color":"gold"} '

What I can do to write spaces on this kind of commands?



The command is not correct i think.
You need to use “]” at the end.
I dont exacly know where, but i recommend you use a tellraw generator. There are alot of generators online.

Use a generator, then try again.

Thanks for reply,

Firstly, Every command are correct. I have tried all of them on a local server or making my own screen command and all of them work perfectly.

You need to use “]” at the end.

You need this if you begin with “[” and you need begin with “[” when you JSON have more than one element (a list). My examples have only one object.

Secondly, I found this bug using a generator but I have simplified these commands for a easier understanding.

This is a bug about how mine_console.js stuff command parse strings or something like this.

As I’m sure you’ve already seen in mineos.js, MineOS uses pretty much the same arguments you’re trying in your test (or you used this as your reference).

However, it’s to be expected that when you add backslashes that things will not execute as expected if you don’t properly indicate where you want a backslash. A \ is a special character, known as an escape character, and to ensure that the command actually gets executed, mineos.js appends \012, which is the \n newline character.

Any \'s you add would then tell screen to parse the next few characters differently, which isn’t likely what you’re expecting.

So for example:

screen -S mc-ff -p 0 -X eval 'stuff "say whitespace works!\012"'
nodejs mineos_console.js -s ff stuff 'say whitespace works!!'


[21:52:46] [Server thread/INFO]: [Server] whitespace works!
[21:52:56] [Server thread/INFO]: [Server] whitespace works!!

And further:

screen -S mc-ff -p 0 -X eval 'stuff "say backslashes work (\\)\012"'
nodejs mineos_console.js -s ff stuff 'say \\ these work!!'


[21:54:02] [Server thread/INFO]: [Server] backslashes work (\)
[21:54:28] [Server thread/INFO]: [Server] \ these work!!

So we do know that whitespace should work just fine, and backslashes should as well, provided you do the complete escape sequence.

Unfortunately, I don’t have a Minecraft client with me (here at work), so I can’t log in as myself to tellraw myself, but it looks like you likely just need to escape your double quotes like this: \"", because your actual quotes are prematurely ending the ‘stuff’ command.

screen -S mc-ff -p 0 -X eval 'stuff "say backslashes \""work\""\012"'
[22:01:13] [Server thread/INFO]: [Server] backslashes "work"

That said, it might take a bit to find out why escaping works so peculiarly with mineos_console.js, since the escape sequences have to go through so many translations. Not sure where the issue lies, because double quote is \042, but here’s the underlying behavior:

 nodejs mineos_console.js -s ff stuff 'say 041 attempt: \041'
 nodejs mineos_console.js -s ff stuff 'say 042 attempt: \042'
 nodejs mineos_console.js -s ff stuff 'say 043 attempt: \043'


[22:10:44] [Server thread/INFO]: [Server] 041 attempt: !
[22:10:52] [Server thread/INFO]: [Server] 043 attempt: # 

No idea why \042 is treated specially, but it is, and I’m not deliberately pruning it out. In fact, it just doesn’t work with screen. It looks like it’s a parsing issue with bash/screen.

mc@mineos games/minecraft$ screen -S mc-ff -p 0 -X eval 'stuff "say this works \012"'
mc@mineos games/minecraft$ screen -S mc-ff -p 0 -X eval 'stuff "say this doesnt \042 \012"'

SO THE ACTUAL ANSWER IS: We need to escape the backslash, so that the quote can pass normally:

nodejs mineos_console.js -s ff stuff 'say 042 attempt: \\"yup\\"'
[22:33:14] [Server thread/INFO]: [Server] 042 attempt: "yup"

Woah! Thank you so much for your reply!

/usr/games/minecraft/mineos_console.js -s server stuff 'tellraw @a {\\"text\\":\\"I dont work\\",\\"bold\\":true,\\"obfuscated\\":true,\\"color\\":\\"gold\\"}'

Adding “\” before doblequote works great!

I tried addiing “” but not “\”!

Thank you so much!