[FIX] Remove deprecated 'new URL'

This commit is contained in:
Gravita 2024-03-08 14:46:43 +07:00
parent d686d9a388
commit 494b3227b6
2 changed files with 9 additions and 5 deletions

View File

@ -8,6 +8,8 @@ import pro.gravit.utils.helper.SecurityHelper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.util.Arrays;
@ -29,8 +31,10 @@ public final class Texture extends StreamObject {
// Fetch texture
byte[] texture;
try (InputStream input = IOHelper.newInput(new URL(url))) {
try (InputStream input = IOHelper.newInput(new URI(url).toURL())) {
texture = IOHelper.read(input);
} catch (URISyntaxException e) {
throw new IOException(e);
}
try (ByteArrayInputStream input = new ByteArrayInputStream(texture)) {
IOHelper.readTexture(input, cloak); // Verify texture

View File

@ -95,8 +95,8 @@ public final class IOHelper {
public static URL convertToURL(String url) {
try {
return new URL(url);
} catch (MalformedURLException e) {
return new URI(url).toURL();
} catch (MalformedURLException | URISyntaxException e) {
throw new IllegalArgumentException("Invalid URL", e);
}
}
@ -576,9 +576,9 @@ public final class IOHelper {
public static String verifyURL(String url) {
try {
new URL(url).toURI();
new URI(url);
return url;
} catch (MalformedURLException | URISyntaxException e) {
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid URL", e);
}
}