Skip to content

Commit

Permalink
Update build for Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMicky-FR committed May 9, 2024
1 parent 0b3c6e3 commit 1042bb7
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 444 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
java-version: ${{ matrix.java-version }}

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/actions/wrapper-validation@v3

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3

- name: Build
run: ./gradlew build
Expand All @@ -46,10 +46,3 @@ jobs:
name: AzLink-Legacy
path: universal-legacy/build/libs/AzLink-Legacy-*.jar
overwrite: true

- name: Upload AzLink-Fabric.jar
uses: actions/upload-artifact@v4
with:
name: AzLink-Fabric
path: fabric/build/libs/AzLink-Fabric-*.jar
overwrite: true
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This plugin currently supports the following platforms:
* [Sponge](https://www.spongepowered.org/)
* [Velocity](https://velocitypowered.com/)
* [Nukkit](https://cloudburstmc.org/articles/)
* [FabricMC](https://fabricmc.net/)

## Setup

Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ allprojects {
subprojects {
apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8
java {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
Expand Down Expand Up @@ -52,9 +53,9 @@ private void loadLibrary(String groupId, String artifactId, String version) thro

this.plugin.getLogger().warn("Downloading " + artifactId + " v" + version + "...");

URL url = new URL(String.format(MAVEN_CENTRAL, groupId.replace('.', '/'), artifactId, version, artifactId, version));
String url = String.format(MAVEN_CENTRAL, groupId.replace('.', '/'), artifactId, version, artifactId, version);

try (InputStream in = url.openStream()) {
try (InputStream in = URI.create(url).toURL().openStream()) {
Files.copy(in, jar);
}

Expand Down
5 changes: 2 additions & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ dependencies {
compileOnly 'net.skinsrestorer:skinsrestorer-api:15.0.2'
compileOnly 'com.nickuc.login:nlogin-api:10.3'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
Expand Down Expand Up @@ -104,7 +105,10 @@ private <T> T rawRequest(RequestMethod method, String endpoint, String body, Cla
int status = conn.getResponseCode();

if (status >= 400) {
throw new IOException("Unexpected HTTP error " + status);
String info = status == 401 || status == 403
? ". Try to do again the link command given on the admin panel." : "";

throw new IOException("Unexpected HTTP error " + status + info);
}

if (status >= 300) {
Expand Down Expand Up @@ -132,7 +136,7 @@ private HttpURLConnection prepareConnection(RequestMethod method, String endpoin
String baseUrl = this.plugin.getConfig().getSiteUrl();
String version = this.plugin.getPlatform().getPluginVersion();
String token = this.plugin.getConfig().getSiteKey();
URL url = new URL(baseUrl + "/api" + endpoint);
URL url = URI.create(baseUrl + "/api" + endpoint).toURL();

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setUseCaches(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public enum PlatformType {
BUNGEE("BungeeCord"),
SPONGE("Sponge"),
VELOCITY("Velocity"),
FABRIC("Fabric"),
NUKKIT("Nukkit");

private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.google.gson.JsonObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URL;
import java.util.Objects;

Expand Down Expand Up @@ -46,7 +48,7 @@ private static String parseVersion(String version) {

public void checkUpdates() {
try {
URL url = new URL(RELEASE_URL);
URL url = URI.create(RELEASE_URL).toURL();

try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
JsonObject json = AzLinkPlugin.getGson().fromJson(reader, JsonObject.class);
Expand All @@ -64,8 +66,8 @@ public void checkUpdates() {
this.plugin.getLogger().warn("You can download it on https://azuriom.com/azlink");
}
}
} catch (Exception e) {
// ignore
} catch (IOException e) {
this.plugin.getLogger().warn("Failed to check for updates: " + e.getMessage());
}
}
}
57 changes: 0 additions & 57 deletions fabric/build.gradle

This file was deleted.

152 changes: 0 additions & 152 deletions fabric/src/main/java/com/azuriom/azlink/fabric/AzLinkFabricMod.java

This file was deleted.

Loading

0 comments on commit 1042bb7

Please sign in to comment.