fix: deprecation warnings for URL
This commit is contained in:
@@ -1 +1 @@
|
||||
1445
|
||||
1446
|
||||
@@ -13,6 +13,7 @@ import me.chayapak1.chomens_bot.util.HttpUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -42,7 +43,7 @@ public class TranslateCommand extends Command {
|
||||
|
||||
bot.executorService.submit(() -> {
|
||||
try {
|
||||
final URL url = new URL("https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1");
|
||||
final URL url = new URI("https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1").toURL();
|
||||
|
||||
final String jsonOutput = HttpUtilities.postRequest(
|
||||
url,
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.gson.JsonObject;
|
||||
import me.chayapak1.chomens_bot.Bot;
|
||||
import me.chayapak1.chomens_bot.Main;
|
||||
import me.chayapak1.chomens_bot.command.*;
|
||||
import me.chayapak1.chomens_bot.command.*;
|
||||
import me.chayapak1.chomens_bot.util.ColorUtilities;
|
||||
import me.chayapak1.chomens_bot.util.HttpUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -17,6 +16,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -52,10 +52,10 @@ public class UrbanCommand extends Command {
|
||||
|
||||
bot.executorService.submit(() -> {
|
||||
try {
|
||||
final URL url = new URL(
|
||||
final URL url = new URI(
|
||||
"https://api.urbandictionary.com/v0/define?term=" +
|
||||
URLEncoder.encode(term, StandardCharsets.UTF_8)
|
||||
);
|
||||
).toURL();
|
||||
|
||||
final String jsonOutput = HttpUtilities.getRequest(url);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -46,7 +47,7 @@ public class WikipediaCommand extends Command {
|
||||
try {
|
||||
Component component = Component.empty();
|
||||
|
||||
final URL pageIDUrl = new URL(String.format(pageIDStringURL, URLEncoder.encode(page, StandardCharsets.UTF_8)));
|
||||
final URL pageIDUrl = new URI(String.format(pageIDStringURL, URLEncoder.encode(page, StandardCharsets.UTF_8))).toURL();
|
||||
|
||||
final JsonObject pageIDJsonOutput = gson.fromJson(HttpUtilities.getRequest(pageIDUrl), JsonObject.class);
|
||||
|
||||
@@ -83,7 +84,7 @@ public class WikipediaCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
final URL outputUrl = new URL(String.format(outputStringURL, pageID));
|
||||
final URL outputUrl = new URI(String.format(outputStringURL, pageID)).toURL();
|
||||
|
||||
final JsonObject outputJsonOutput = gson.fromJson(HttpUtilities.getRequest(outputUrl), JsonObject.class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user