Uncaught-Exceptions / MCRcon

Use minecraft's new-fangled Rcon
Other
50 stars 12 forks source link

No new line with commands such as help (Can't really be fixed) #4

Open Sean-McConnachie opened 4 years ago

Sean-McConnachie commented 4 years ago

Hi there,

There seems to be a bug that causes there to be no newlines in responses.

E.g. mcr = MCRcon("10.1.1.1", "sekret") mcr.connect() resp = mcr.command("/help") print(resp) mcr.disconnect() gives /advancement (grant|revoke)/ban <targets> [<reason>].... on one line.

salamelek commented 3 years ago

I don't think that's a bug, since it's just a normal string response.. you could get a line-by-line output with something like this: resp = mcr.command("/help")

wanted_resp = ""

wanted_resp_list = resp.split("/") wanted_resp_list.pop(0) for command in wanted_resp_list: wanted_resp += "/" + command + "\n"

print(wanted_resp)

this way, you will get the proper response in "wanted_resp". I am also pretty sure that there is a much quicker way of doing this. Hope this is helpful!

mosguinz commented 3 years ago

The issue seems to apply to any response that should contain a newline. It simply excludes any newline character in the response string entirely.

The fix that @salamelek suggested will only work for help command and others that have a similar response pattern.

For example, sending the whitelist command without any argument will result in the server complaining. Usually, the output will be over two lines like this:

Unknown or incomplete command, see below for error
whitelist<--[HERE]

But the string that we get from the command method does not have a newline:

Unknown or incomplete command, see below for errorwhitelist<--[HERE]
unexceptable commented 3 years ago

Yeah, looking into this I'm unsure if we can really even do anything about this. The raw returned byte data seems to have no idea about where the newlines should be, and we can't really infer anything consistently about where to split sadly. :(

I'm going to label it as won't fix, but not close it so others don't attempt to submit the same issue.

mosguinz commented 3 years ago

Sorry, I forgot to update this issue but as it turns out this is on the server, dating back to 1.4.7. See MC-7569. Non-vanilla servers appear to have the fix for this, such as this mod.

unexceptable commented 3 years ago

Sorry, I forgot to update this issue but as it turns out this is on the server, dating back to 1.4.7. See MC-7569. Non-vanilla servers appear to have the fix for this, such as this mod.

Oh! Perfect. Well then even better reason to keep this issue pinned, since people can find and apply that mod. :)