Skip to content

Commit

Permalink
fix: strict Java 8 release, relocate packages
Browse files Browse the repository at this point in the history
  • Loading branch information
NotGeri committed Feb 19, 2024
1 parent e165884 commit 0af60ec
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ subprojects {

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

processResources {
Expand All @@ -54,6 +55,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
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

0 comments on commit 0af60ec

Please sign in to comment.