Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 8 Support #2

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ subprojects {

// Task to create a single 'fat' JAR including all subprojects
task uberJar(type: ShadowJar) {

// Relocate important dependencies to avoid any collisions at runtime
relocate 'org.yaml.snakeyaml', 'host.bloom.ab.dependencies.snakeyml'
relocate 'com.google.gson', 'host.bloom.ab.dependencies.gson'
relocate 'org.apache.commons', 'host.bloom.ab.dependencies.apache.commons'

// Set the output file name and location
archiveFileName = "${project.ext.pluginName}-${project.ext.pluginVersion}.jar"

Expand Down
4 changes: 4 additions & 0 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ repositories {
}
}

tasks.withType(JavaCompile) {
options.compilerArgs.addAll(['--release', '8'])
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
4 changes: 4 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
tasks.withType(JavaCompile) {
options.compilerArgs.addAll(['--release', '8'])
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
5 changes: 3 additions & 2 deletions common/src/main/java/host/bloom/ab/common/AbstractPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import host.bloom.ab.common.utils.Scheduler;
import host.bloom.ab.common.utils.UpdateChecker;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -34,12 +35,12 @@ enum Platform {
default void afterStartup() {

// Ensure it's on a supported port
List<Integer> supportedPorts = List.of(25565, 25566, 25567);
List<Integer> supportedPorts = Arrays.asList(25565, 25566, 25567);
if (!supportedPorts.contains(this.getPort())) {
throw new RuntimeException("The server is not using a supported port! Please ensure it's using one of the following ports, and restart: " + supportedPorts.stream().map(String::valueOf).collect(Collectors.joining(", ")));
}

this.getABLogger().info("Successfully loaded version: v%s, location: %s!".formatted(this.getVersion(), this.getABConfig().location.getDisplayName()));
this.getABLogger().info("Successfully loaded version: v" + this.getVersion() + ", location: " + this.getABConfig().location.getDisplayName() + "!");

// Check for new updates in the background
UpdateChecker.handle(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import host.bloom.ab.common.commands.sub.ForceStop;
import host.bloom.ab.common.commands.sub.Set;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -65,7 +66,7 @@ public List<String> onTabComplete(Sender sender, String[] args) {
if (!sender.hasPermission("bab.admin")) return Collections.emptyList();

// Return the subcommands
if (args.length <= 1) return commands.keySet().stream().toList();
if (args.length <= 1) return new ArrayList<>(commands.keySet());

// See if it's a command
SubCommand command = commands.get(args[0].toLowerCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -121,7 +122,7 @@ public void run(Sender sender, String[] args) {
@Override
public List<String> getTabCompletion(String[] args) {
if (args.length == 2) {
return List.of("maxjps", "duration", "location");
return Arrays.asList("maxjps", "duration", "location");
}

if (args.length == 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

import host.bloom.ab.common.AbstractPlugin;
import host.bloom.ab.common.utils.GitHubRelease;

import java.io.BufferedReader;
import java.io.IOException;
Expand All @@ -19,13 +11,9 @@
import java.net.URL;
import java.util.stream.Collectors;

import java.util.ArrayList;
import java.util.List;
import java.lang.reflect.Type;

public class UpdateChecker {

static Gson gson = new GsonBuilder().create();
static Gson gson = new GsonBuilder().create();

public static void handle(AbstractPlugin plugin) {
if (!plugin.getABConfig().checkForUpdates) return;
Expand Down
4 changes: 4 additions & 0 deletions velocity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ dependencies {
annotationProcessor velocityJar
}

tasks.withType(JavaCompile) {
options.compilerArgs.addAll(['--release', '8'])
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
2 changes: 2 additions & 0 deletions waterfall/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ dependencies {
compileOnly files('libs/waterfall-1.20-562.jar')
}

// We explicitly skip --release 8 for this, since unsafe would fail

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
Loading