mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Update SkinProvider.java
Remove duplicate code
This commit is contained in:
parent
203b3b9d46
commit
afab21695a
1 changed files with 2 additions and 9 deletions
|
@ -162,23 +162,16 @@ public class SkinProvider {
|
||||||
|
|
||||||
private static byte[] requestImage(String imageUrl, boolean cape) throws Exception {
|
private static byte[] requestImage(String imageUrl, boolean cape) throws Exception {
|
||||||
BufferedImage image = ImageIO.read(new URL(imageUrl));
|
BufferedImage image = ImageIO.read(new URL(imageUrl));
|
||||||
BufferedImage scale = scale(image);
|
|
||||||
Geyser.getLogger().debug("Downloaded " + imageUrl);
|
Geyser.getLogger().debug("Downloaded " + imageUrl);
|
||||||
|
|
||||||
if (cape && image.getWidth() <= 64) {
|
if (cape) {
|
||||||
|
image = image.getWidth() > 64 ? scale(image) : image;
|
||||||
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
|
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
|
||||||
Graphics g = newImage.createGraphics();
|
Graphics g = newImage.createGraphics();
|
||||||
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
|
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
image = newImage;
|
image = newImage;
|
||||||
}
|
}
|
||||||
else if(cape && image.getWidth() >= 64 && image.getWidth() <= 128) {
|
|
||||||
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
|
|
||||||
Graphics g = newImage.createGraphics();
|
|
||||||
g.drawImage(scale, 0, 0, scale.getWidth(), scale.getHeight(), null);
|
|
||||||
g.dispose();
|
|
||||||
image = newImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(image.getWidth() * 4 + image.getHeight() * 4);
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(image.getWidth() * 4 + image.getHeight() * 4);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue