remove deprecated code and use modern methods/classes/code where applicable
This commit is contained in:
2
.github/ISSUE_TEMPLATE/BUG-REPORT.yml
vendored
2
.github/ISSUE_TEMPLATE/BUG-REPORT.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: Bug report
|
name: Bug report
|
||||||
description: Report problems/issues here
|
description: Report problems/issues here
|
||||||
labels: bug
|
labels: [bug]
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
|
2
.github/ISSUE_TEMPLATE/FEATURE-REQUEST.yml
vendored
2
.github/ISSUE_TEMPLATE/FEATURE-REQUEST.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: Feature request
|
name: Feature request
|
||||||
description: Use this to request new features and/or changes
|
description: Use this to request new features and/or changes
|
||||||
labels: enhancement
|
labels: [enhancement]
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
|
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +1,3 @@
|
|||||||
|
#file: noinspection YAMLSchemaValidation
|
||||||
|
#IntelliJ IDEA interprets this as another issue template so the above line is required
|
||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
|
14
build.gradle
14
build.gradle
@@ -24,7 +24,19 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
relocate('org.bstats', 'io.github.jack1424.realtimeweather')
|
relocate('org.bstats', 'io.github.jack1424.realTimeWeather')
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
manifest {
|
||||||
|
attributes["paperweight-mappings-namespace"] = "mojang"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.shadowJar {
|
||||||
|
manifest {
|
||||||
|
attributes["paperweight-mappings-namespace"] = "mojang"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 21
|
def targetJavaVersion = 21
|
||||||
|
@@ -7,16 +7,18 @@ import org.json.simple.parser.ParseException;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class RequestFunctions {
|
public class RequestFunctions {
|
||||||
public static Object makeRequest(String URLString) throws IOException, HTTPResponseException, ParseException {
|
public static Object makeRequest(String URLString) throws IOException, HTTPResponseException, ParseException, URISyntaxException {
|
||||||
int responseCode = getResponseCode(URLString);
|
int responseCode = getResponseCode(URLString);
|
||||||
if (responseCode > 399)
|
if (responseCode > 399)
|
||||||
throw new HTTPResponseException(responseCode);
|
throw new HTTPResponseException(responseCode);
|
||||||
|
|
||||||
Scanner scanner = new Scanner(new URL(URLString).openStream());
|
Scanner scanner = new Scanner(new URI(URLString).toURL().openStream());
|
||||||
StringBuilder response = new StringBuilder();
|
StringBuilder response = new StringBuilder();
|
||||||
while (scanner.hasNextLine())
|
while (scanner.hasNextLine())
|
||||||
response.append(scanner.nextLine());
|
response.append(scanner.nextLine());
|
||||||
@@ -25,8 +27,8 @@ public class RequestFunctions {
|
|||||||
return new JSONParser().parse(response.toString());
|
return new JSONParser().parse(response.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getResponseCode(String URLString) throws IOException {
|
public static int getResponseCode(String URLString) throws IOException, URISyntaxException {
|
||||||
URL url = new URL(URLString);
|
URL url = new URI(URLString).toURL();
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
con.connect();
|
con.connect();
|
||||||
@@ -34,7 +36,7 @@ public class RequestFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getLatestVersion() throws Exception {
|
public static String getLatestVersion() throws Exception {
|
||||||
return ((JSONObject) ((JSONArray) makeRequest("https://api.modrinth.com/v2/project/WRA6ODcm/version")).get(0)).get("version_number").toString();
|
return ((JSONObject) ((JSONArray) makeRequest("https://api.modrinth.com/v2/project/WRA6ODcm/version")).getFirst()).get("version_number").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HTTPResponseException extends Exception {
|
public static class HTTPResponseException extends Exception {
|
||||||
|
Reference in New Issue
Block a user