Dinnerbone / mcstatus

A Python class for checking the status of an enabled Minecraft server
http://dinnerbone.com/minecraft/tools/status/
1.11k stars 146 forks source link

Is there away to get tps (ticks per second) #137

Closed CSutter5 closed 2 years ago

CSutter5 commented 3 years ago

Im trying to see if there is a why get get tps of the server. Is there a way to get that?

Iapetus-11 commented 3 years ago

Ticks per second would either have to be via RCON if there's a command for it, or via a plugin. There's no way to get TPS (that I know of) via the status protocols which is all that this library supports.

kevinkjt2000 commented 3 years ago

The protocol does support fetching server tick age https://wiki.vg/Protocol#Time_Update

I feel it would be too much for this library to fetch the server's tick age twice to compute the TPS. The status protocol is initiated on the handshake instead of the login protocol (which would be required to get the server's tick age). I don't see simulating a player long enough to receive multiple time updates as a feasible solution; I could be proven wrong on this because I have no experience with implementing my own Minecraft client. I'd also rather avoid handling authentication/login and keep mcstatus simple in that regard.

RCON is a possibility too, and I feel that would be better suited to an actual RCON library which mcstatus is not.

If there is a way to fetch TPS from a plugin without authenticating, I'm open to any PRs that accomplish that as long as existing vanilla behavior continues to function. I'll leave this open as a possible feature request in case someone has an idea that could retrieve this status without authenticating.

CoolCat467 commented 3 years ago

Have a plugin that modifies json sent in the status request packet to add an extra field with TPS in it. Not sure how you'd calculate that server side, but I'm sure it's possible. It would force the server to have such a plugin for use though. Probably beyond the scope of this project though.