mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 20:56:45 +01:00
Address deprecated URL instantiation (#4178)
Fixes https://github.com/IntellectualSites/PlotSquared/issues/4166
This commit is contained in:
parent
aae6ea4fee
commit
4fe0c586d9
@ -35,7 +35,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
|
||||
public class UpdateUtility implements Listener {
|
||||
|
||||
@ -59,8 +59,9 @@ public class UpdateUtility implements Listener {
|
||||
public void updateChecker() {
|
||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(this.javaPlugin, () -> {
|
||||
try {
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(
|
||||
HttpsURLConnection connection = (HttpsURLConnection) URI.create(
|
||||
"https://api.spigotmc.org/simple/0.2/index.php?action=getResource&id=77506")
|
||||
.toURL()
|
||||
.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
JsonObject result = new JsonParser()
|
||||
|
@ -84,7 +84,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
@ -210,9 +210,10 @@ public class PlotSquared {
|
||||
try {
|
||||
URL logurl = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation();
|
||||
this.jarFile = new File(
|
||||
new URL(logurl.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file"))
|
||||
.toURI().getPath());
|
||||
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
||||
URI.create(
|
||||
logurl.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file"))
|
||||
.getPath());
|
||||
} catch (URISyntaxException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
this.jarFile = new File(this.platform.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||
if (!this.jarFile.exists()) {
|
||||
|
@ -41,6 +41,7 @@ import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -116,7 +117,7 @@ public class Load extends SubCommand {
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic);
|
||||
url = URI.create(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic).toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
player.sendMessage(TranslatableCaption.of("web.load_failed"));
|
||||
|
@ -40,6 +40,7 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -130,8 +131,7 @@ public class SchematicCmd extends SubCommand {
|
||||
if (location.startsWith("url:")) {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(location.substring(4));
|
||||
URL base = new URL(Settings.Web.URL);
|
||||
URL url = new URL(base, "uploads/" + uuid + ".schematic");
|
||||
URL url = URI.create(Settings.Web.URL + "uploads/" + uuid + ".schematic").toURL();
|
||||
schematic = this.schematicHandler.getSchematic(url);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -83,6 +83,7 @@ import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.Channels;
|
||||
@ -144,7 +145,7 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.Web.URL + "?key=" + uuid + "&type=" + extension);
|
||||
url = URI.create(Settings.Web.URL + "?key=" + uuid + "&type=" + extension).toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
whenDone.run();
|
||||
@ -153,7 +154,7 @@ public abstract class SchematicHandler {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try {
|
||||
String boundary = Long.toHexString(System.currentTimeMillis());
|
||||
URLConnection con = new URL(website).openConnection();
|
||||
URLConnection con = URI.create(website).toURL().openConnection();
|
||||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
|
||||
try (OutputStream output = con.getOutputStream();
|
||||
@ -498,9 +499,10 @@ public abstract class SchematicHandler {
|
||||
public List<String> getSaves(UUID uuid) {
|
||||
String rawJSON;
|
||||
try {
|
||||
String website = Settings.Web.URL + "list.php?" + uuid.toString();
|
||||
URL url = new URL(website);
|
||||
URLConnection connection = new URL(url.toString()).openConnection();
|
||||
URLConnection connection = URI.create(
|
||||
Settings.Web.URL + "list.php?" + uuid.toString())
|
||||
.toURL()
|
||||
.openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
rawJSON = reader.lines().collect(Collectors.joining());
|
||||
|
Loading…
Reference in New Issue
Block a user