diff --git a/LaunchServer/source/texture/RequestTextureProvider.java b/LaunchServer/source/texture/RequestTextureProvider.java index 2fad417..e7cd173 100644 --- a/LaunchServer/source/texture/RequestTextureProvider.java +++ b/LaunchServer/source/texture/RequestTextureProvider.java @@ -5,7 +5,6 @@ import java.util.UUID; import launcher.client.ClientLauncher; -import launcher.client.PlayerProfile; import launcher.client.PlayerProfile.Texture; import launcher.helper.CommonHelper; import launcher.helper.IOHelper; @@ -37,19 +36,19 @@ @Override public Texture getCloakTexture(UUID uuid, String username) throws IOException { - return getTexture(getTextureURL(cloakURL, uuid, username)); + return getTexture(getTextureURL(cloakURL, uuid, username), true); } @Override public Texture getSkinTexture(UUID uuid, String username) throws IOException { - return getTexture(getTextureURL(skinURL, uuid, username)); + return getTexture(getTextureURL(skinURL, uuid, username), false); } - private static Texture getTexture(String url) throws IOException { + private static Texture getTexture(String url, boolean cloak) throws IOException { LogHelper.debug("Getting texture: '%s'", url); try { - return new Texture(url); - } catch (FileNotFoundException e) { + return new Texture(url, cloak); + } catch (FileNotFoundException ignored) { LogHelper.subDebug("Texture not found :("); return null; // Simply not found } diff --git a/Launcher/source/client/PlayerProfile.java b/Launcher/source/client/PlayerProfile.java index 80d14b8..eb07379 100644 --- a/Launcher/source/client/PlayerProfile.java +++ b/Launcher/source/client/PlayerProfile.java @@ -77,7 +77,7 @@ } @LauncherAPI - public Texture(String url) throws IOException { + public Texture(String url, boolean cloak) throws IOException { this.url = IOHelper.verifyURL(url); // Fetch texture @@ -86,7 +86,7 @@ texture = IOHelper.read(input); } try (ByteArrayInputStream input = new ByteArrayInputStream(texture)) { - IOHelper.readTexture(input); // Verify texture + IOHelper.readTexture(input, cloak); // Verify texture } // Get digest of texture diff --git a/Launcher/source/helper/IOHelper.java b/Launcher/source/helper/IOHelper.java index 8d3fb46..6f362b7 100644 --- a/Launcher/source/helper/IOHelper.java +++ b/Launcher/source/helper/IOHelper.java @@ -221,8 +221,8 @@ } @LauncherAPI - public static boolean isValidTextureBounds(int width, int height) { - return width % 64 == 0 && height * 2 == width && width <= 1024; + public static boolean isValidTextureBounds(int width, int height, boolean cloak) { + return width % 64 == 0 && height << 1 == width && width <= 1024 || cloak && width % 22 == 0 && height % 17 == 0 && width / 22 == height / 17; } @LauncherAPI @@ -407,7 +407,7 @@ } @LauncherAPI - public static BufferedImage readTexture(Object input) throws IOException { + public static BufferedImage readTexture(Object input, boolean cloak) throws IOException { ImageReader reader = ImageIO.getImageReadersByMIMEType("image/png").next(); try { reader.setInput(ImageIO.createImageInputStream(input), false, false); @@ -415,7 +415,7 @@ // Verify texture bounds int width = reader.getWidth(0); int height = reader.getHeight(0); - if (!isValidTextureBounds(width, height)) { + if (!isValidTextureBounds(width, height, cloak)) { throw new IOException(String.format("Invalid texture bounds: %dx%d", width, height)); } @@ -593,8 +593,8 @@ } @LauncherAPI - public static BufferedImage verifyTexture(BufferedImage skin) { - return VerifyHelper.verify(skin, i -> isValidTextureBounds(i.getWidth(), i.getHeight()), + public static BufferedImage verifyTexture(BufferedImage skin, boolean cloak) { + return VerifyHelper.verify(skin, i -> isValidTextureBounds(i.getWidth(), i.getHeight(), cloak), String.format("Invalid texture bounds: %dx%d", skin.getWidth(), skin.getHeight())); }