kr8gz / PlayerStatistics

Adds a command to your Fabric server that gives players insights into everyone's statistics.
https://modrinth.com/mod/playerstatistics
MIT License
4 stars 1 forks source link

JSON-formatted, RCON supported results #2

Open MJRamon opened 5 months ago

MJRamon commented 5 months ago

For server owners, it's a common practice to get server data using RCON: for gathering and managing statistics or to display on web-site. Ideally in JSON format.

Would be great to have this option - can it be done? I'm still interested in 1.20.1 version specifically.

kr8gz commented 5 months ago

I haven't heard of RCON before... would it be too much of a hassle if I created a Java API, which you can use to develop an extension that does specifically what you want? Either way, this is going to have to wait until I'm back from my holidays 🙂

MJRamon commented 5 months ago

I haven't heard of RCON before... would it be too much of a hassle if I created a Java API, which you can use to develop an extension that does specifically what you want? Either way, this is going to have to wait until I'm back from my holidays 🙂

RCON is a built-in functionality in Minecraft, that allows remotely execute commands. You do not need to do for it nothing additional - just return result as JSON.

    private static final Gson GSON = new Gson();

//...
{
  var res = new Player(profile.getName(), profile.getId().toString());
  ctx.getSource().sendFeedback(() -> Text.literal(GSON.toJson(res)), false);
}

//...

private record Player(String playerName, String uuid) {}
kr8gz commented 5 months ago

Ah, that would be a lot simpler of course. I will think about how to do this (also I hope this isn't needed urgently)

kr8gz commented 3 months ago

If I understand this correctly, all you need is a command that sends a message containing the JSON data?