Temporary fix for 1.12.2 (working)
First off let me say: Thank you so much. Using RCON is extremely clever and it works pretty well. Installed without Docker, however, but it went smoothly. Was about to attempt this myself, but saw your post here and wanted to try it out first.
I do, however, have this running on an 1.12.2 server (RLCraft). There is no data command in 1.12.2, since it was introduced in 1.13, so I tried to find a way that still worked without additional mods.. and I did. But holy moly is it ugly. The only way to get position of a player without mods, is by calling this command:
/tp <player> ~ ~ ~
Which will return:
Teleported <player> to x, y, z
Because of that, I could simply change the parsePlayerCoords function to use that data instead. So far I have not noticed it having an impact on the player's actual position. I tried running, swimming, sleeping, sailing, and flying. The /tp command doesn't seem to do anything, when the player is teleported to ~ ~ ~. So here is my edit, and you can do with it what you want (alternatively keep this issue open or branch out).
getPlayerCoords = (playerName) => {
return rcon.send(`tp ${playerName} ~ ~ ~`).then(parsePlayerCoords).then(data => {return {name: playerName, x: data.x, y: data.y, z: data.z}});
};
parsePlayerCoords = (playerResult) => {
let regex = "to (.*), (.*), (.*)";
let data = playerResult.match(regex);
return {
x: Number(data[1]),
y: Number(data[2]),
z: Number(data[3])
};
};
Thank you for pointing this out. I haven't done any version testing and thus didn't see this potential problem. I will take this into consideration as I would like to try and keep the interactions as clean as possible, so I may look into detecting the running version and incorporate some backward compatibility.