diff --git a/README.md b/README.md
index 24839fc..0ac129f 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ There are 0 players on Hypix
```
## Options
- - refreshRate - The rate that the counter will refresh (1m by default. Note that https://mcapi.us/ has a 5 minute cache.)
+ - refreshRate - The rate that the counter will refresh (1m by default. Note that https://mcstatus.snowdev.com.br/ has a 30 seconds cache.)
- format - Format that the counter will be displayed
- `{max}` - Maximum players
- `{online}` - Online players
@@ -53,5 +53,5 @@ new PlayerCounter({
## License
-Copyright (C) 2017-2020 leonardosnt
+Copyright (C) 2017-2021 leonardosnt
Licensed under the MIT License. See LICENSE file in the project root for full license information.
diff --git a/dist/mc-player-counter.js b/dist/mc-player-counter.js
index d263764..00df7c2 100644
--- a/dist/mc-player-counter.js
+++ b/dist/mc-player-counter.js
@@ -31,11 +31,9 @@ var PlayerCounter = function () {
if (!element) {
throw TypeError('element cannot be null or undefined');
}
-
- var ipAddress = ip.split(':');
- this.ip = ipAddress[0];
- this.port = ipAddress[1] || '25565';
-
+
+ this.ip = ip;
+
this.format = format;
this.element = typeof element === 'string' ? document.querySelector(element) : element;
@@ -51,6 +49,7 @@ var PlayerCounter = function () {
// I'll use XMLHttpRequest because it has a better browser support
// than fetch & Promise.
var request = new XMLHttpRequest();
+
request.onreadystatechange = function () {
if (request.readyState !== 4 || request.status !== 200) return;
@@ -69,14 +68,12 @@ var PlayerCounter = function () {
// Make sure server is online
if (response.online) {
_this.element.innerHTML = _this.format.replace(FORMAT_REGEX, function (_, group) {
- return (
- // Change 'online' to 'now' to keep backward compatibility
- response.players[group === 'online' ? 'now' : group]
- );
+ return (group === 'online' ? response.players_online : response.max_players);
});
}
};
- request.open('GET', 'https://mcapi.us/server/status?ip=' + this.ip + '&port=' + this.port);
+
+ request.open('GET', 'https://mcstatus.snowdev.com.br/api/query/v3/' + this.ip);
request.send();
}
}]);
diff --git a/dist/mc-player-counter.min.js b/dist/mc-player-counter.min.js
index e39e6fa..31c1a88 100644
--- a/dist/mc-player-counter.min.js
+++ b/dist/mc-player-counter.min.js
@@ -4,4 +4,4 @@
* Copyright (C) 2017 leonardosnt
* Licensed under the MIT License. See LICENSE file in the project root for full license information.
*/
-!function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var t=function(){function e(e,t){for(var n=0;n