drop support for usernames

Mojang has disabled their legacy skins API:
https://twitter.com/MojangSupport/status/964511258601865216

With their API rate limits, it's now practially impossible
for us to support usernames.

Fixes #142. The default parameter allows using:

- UUID
- URL
- MHF_Alex
- MHF_Steve
- Alex
- Steve

Contrary to UUIDs, using alex/steve doesn't redirect
and instead provides the skin from a locally stored file.
This commit is contained in:
jomo
2018-02-16 18:01:41 +01:00
parent a187fb26d4
commit dff58c66e7
11 changed files with 176 additions and 582 deletions

View File

@@ -1,4 +1,4 @@
var valid_user_id = /^([0-9a-f-A-F-]{32,36}|[a-zA-Z0-9_]{1,16})$/; // uuid|username
var valid_user_id = /^[0-9a-f-A-F-]{32,36}$/; // uuid
var xhr = new XMLHttpRequest();
xhr.onload = function() {
@@ -9,24 +9,14 @@ xhr.onload = function() {
status[key] = elem[key];
});
var textures = status["textures.minecraft.net"] !== "green";
var session = status["sessionserver.mojang.com"] !== "green";
var skins = status["skins.minecraft.net"] !== "green";
var error = null;
var textures_err = status["textures.minecraft.net"] !== "green";
var session_err = status["sessionserver.mojang.com"] !== "green";
if (textures || session && skins) {
error = "all";
} else if (skins) {
error = "username";
} else if (session) {
error = "UUID";
}
if (error) {
if (textures_err || session_err) {
var warn = document.createElement("div");
warn.setAttribute("class", "alert alert-warning");
warn.setAttribute("role", "alert");
warn.innerHTML = "<h5>Mojang issues</h5> Mojang's servers are having trouble <i>right now</i>, this may affect <b>" + error + "</b> requests at Crafatar. <small><a href=\"https://help.mojang.com\" target=\"_blank\">check status</a>";
warn.innerHTML = "<h5>Mojang issues</h5> Mojang's servers are having trouble <i>right now</i>, this may affect requests at Crafatar. <small><a href=\"https://help.mojang.com\" target=\"_blank\">check status</a>";
document.querySelector("#alerts").appendChild(warn);
}
};