Open TheZackCodec opened 4 years ago
How about using the server queries for the player count? There are libs for it available, and even a web based API: https://mcapi.us
@destruc7i0n Fine you got me, I was a little lazy here. I wanted something more internal. A bunch of the APIs do not like more than one query ever minute and most cache for 5-10 minutes and I didn't want stale data. but let me look more into the server queries and i'll making a data-structure to grab that.
At least check out my regex improvements in #54 while I actually implement something more production ready. I have a few other features i want to implement and honestly getting server queries working would make our lives easier
Tested on 2 x 24/7 servers
Does not conflict with pull request #54
Details
Added ability to append the number of users currently in the server to the server username.
Online player count is still tracked and show correctly on other server notifications when SHOW_PLAYER_CONN_STAT is set to false as long as PLAYERCOUNT_IN_SERVERNAME is enabled. This is used for the circumstances where player count is desired to be part of the server username but join and leave notifications are not.
Added escape-string-regexp library to help sanitize variables. Used in the function that selects correct Avatar URL. This also improves the original way of detecting whether the username was the server name because as long as the username has "ServerName - Server" somewhere in it, it picks the server Avatar URL. Allowing future items to be appended on the server username without affecting detection.