mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
fix errors for null skins, closes #20
This commit is contained in:
parent
a31282e244
commit
7d47028ff7
@ -124,7 +124,7 @@ exp.get_image_hash = function(uuid, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// handles requests for +uuid+ images with +size+
|
// handles requests for +uuid+ avatars with +size+
|
||||||
// callback contains error, status, image buffer, hash
|
// callback contains error, status, image buffer, hash
|
||||||
// image is the user's face+helm when helm is true, or the face otherwise
|
// image is the user's face+helm when helm is true, or the face otherwise
|
||||||
// for status, see get_image_hash
|
// for status, see get_image_hash
|
||||||
@ -154,20 +154,23 @@ exp.get_avatar = function(uuid, helm, size, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// handles requests for +uuid+ skins
|
||||||
|
// callback contains error, hash, image buffer
|
||||||
exp.get_skin = function(uuid, callback) {
|
exp.get_skin = function(uuid, callback) {
|
||||||
logging.log("\nskin request: " + uuid);
|
logging.log(uuid + " skin request");
|
||||||
exp.get_image_hash(uuid, function(err, status, hash) {
|
exp.get_image_hash(uuid, function(err, status, hash) {
|
||||||
if (hash) {
|
if (hash) {
|
||||||
var skinurl = "http://textures.minecraft.net/texture/" + hash;
|
var skinurl = "http://textures.minecraft.net/texture/" + hash;
|
||||||
networking.get_skin(skinurl, function(err, img) {
|
networking.get_skin(skinurl, function(err, img) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.log("\nerror while downloading skin");
|
logging.error("error while downloading skin");
|
||||||
callback(err, hash, null);
|
callback(err, hash, null);
|
||||||
} else {
|
} else {
|
||||||
logging.log("\nreturning skin");
|
|
||||||
callback(null, hash, img);
|
callback(null, hash, img);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
callback(err, null, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
BIN
public/images/alex_skin.png
Normal file
BIN
public/images/alex_skin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
public/images/steve_skin.png
Normal file
BIN
public/images/steve_skin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@ -4,6 +4,7 @@ var helpers = require("../modules/helpers");
|
|||||||
var config = require("../modules/config");
|
var config = require("../modules/config");
|
||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
var skins = require("../modules/skins");
|
var skins = require("../modules/skins");
|
||||||
|
var lwip = require("lwip");
|
||||||
|
|
||||||
/* GET skin request. */
|
/* GET skin request. */
|
||||||
router.get("/:uuid.:ext?", function(req, res) {
|
router.get("/:uuid.:ext?", function(req, res) {
|
||||||
@ -61,8 +62,10 @@ router.get("/:uuid.:ext?", function(req, res) {
|
|||||||
res.end();
|
res.end();
|
||||||
} else {
|
} else {
|
||||||
def = def || skins.default_skin(uuid);
|
def = def || skins.default_skin(uuid);
|
||||||
skins.resize_img("public/images/" + def + ".png", size, function(err, image) {
|
lwip.open("public/images/" + def + "_skin.png", function(err, image) {
|
||||||
sendimage(http_status, image);
|
image.toBuffer("png", function(err, buffer) {
|
||||||
|
sendimage(http_status, buffer);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user