mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Remove deprecated 'new URL'
This commit is contained in:
parent
d686d9a388
commit
494b3227b6
2 changed files with 9 additions and 5 deletions
|
@ -8,6 +8,8 @@
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -29,8 +31,10 @@ public Texture(String url, boolean cloak, Map<String, String> metadata) throws I
|
||||||
|
|
||||||
// Fetch texture
|
// Fetch texture
|
||||||
byte[] texture;
|
byte[] texture;
|
||||||
try (InputStream input = IOHelper.newInput(new URL(url))) {
|
try (InputStream input = IOHelper.newInput(new URI(url).toURL())) {
|
||||||
texture = IOHelper.read(input);
|
texture = IOHelper.read(input);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
try (ByteArrayInputStream input = new ByteArrayInputStream(texture)) {
|
try (ByteArrayInputStream input = new ByteArrayInputStream(texture)) {
|
||||||
IOHelper.readTexture(input, cloak); // Verify texture
|
IOHelper.readTexture(input, cloak); // Verify texture
|
||||||
|
|
|
@ -95,8 +95,8 @@ public static Manifest getManifest(Class<?> clazz) {
|
||||||
|
|
||||||
public static URL convertToURL(String url) {
|
public static URL convertToURL(String url) {
|
||||||
try {
|
try {
|
||||||
return new URL(url);
|
return new URI(url).toURL();
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
throw new IllegalArgumentException("Invalid URL", e);
|
throw new IllegalArgumentException("Invalid URL", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,9 +576,9 @@ public static BufferedImage verifyTexture(BufferedImage skin, boolean cloak) {
|
||||||
|
|
||||||
public static String verifyURL(String url) {
|
public static String verifyURL(String url) {
|
||||||
try {
|
try {
|
||||||
new URL(url).toURI();
|
new URI(url);
|
||||||
return url;
|
return url;
|
||||||
} catch (MalformedURLException | URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw new IllegalArgumentException("Invalid URL", e);
|
throw new IllegalArgumentException("Invalid URL", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue