aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spark-bukkit/build.gradle3
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitServerConfigProvider.java2
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java7
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java1
-rw-r--r--spark-bungeecord/build.gradle3
-rw-r--r--spark-common/build.gradle12
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java12
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java4
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java4
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/ThreadDumper.java24
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java24
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java75
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/Compression.java60
-rwxr-xr-xspark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.sobin0 -> 308800 bytes
-rw-r--r--spark-fabric/build.gradle3
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/mixin/MinecraftClientAccessor.java (renamed from spark-common/src/main/java/me/lucko/spark/common/util/AbstractHttpClient.java)28
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java10
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java9
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java7
-rw-r--r--spark-fabric/src/main/resources/spark.mixins.json3
-rw-r--r--spark-forge/build.gradle3
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java9
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java9
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java7
-rw-r--r--spark-forge/src/main/resources/META-INF/accesstransformer.cfg1
-rw-r--r--spark-minestom/build.gradle3
-rw-r--r--spark-nukkit/build.gradle3
-rw-r--r--spark-sponge7/build.gradle3
-rw-r--r--spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java7
-rw-r--r--spark-sponge8/build.gradle3
-rw-r--r--spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java30
-rw-r--r--spark-velocity/build.gradle3
-rw-r--r--spark-velocity4/build.gradle3
-rw-r--r--spark-waterdog/build.gradle3
34 files changed, 181 insertions, 197 deletions
diff --git a/spark-bukkit/build.gradle b/spark-bukkit/build.gradle
index 7144291..917fb55 100644
--- a/spark-bukkit/build.gradle
+++ b/spark-bukkit/build.gradle
@@ -31,12 +31,9 @@ processResources {
shadowJar {
archiveName = "spark-${project.pluginVersion}-bukkit.jar"
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitServerConfigProvider.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitServerConfigProvider.java
index 4c587fb..d095bed 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitServerConfigProvider.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitServerConfigProvider.java
@@ -152,6 +152,8 @@ public class BukkitServerConfigProvider extends AbstractServerConfigProvider {
.add("level-seed")
.add("world-settings.*.feature-seeds")
.add("world-settings.*.seed-*")
+ .add("feature-seeds")
+ .add("seed-*")
.addAll(getTimingsHiddenConfigs())
.addAll(getSystemPropertyList("spark.serverconfigs.hiddenpaths"));
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java
index fddd66b..5737d3d 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java
@@ -50,14 +50,16 @@ import java.util.stream.Stream;
public class BukkitSparkPlugin extends JavaPlugin implements SparkPlugin {
private BukkitAudiences audienceFactory;
+ private ThreadDumper gameThreadDumper;
+
private SparkPlatform platform;
private CommandExecutor tpsCommand = null;
- private final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread();
@Override
public void onEnable() {
this.audienceFactory = BukkitAudiences.create(this);
+ this.gameThreadDumper = new ThreadDumper.Specific(Thread.currentThread());
this.platform = new SparkPlatform(this);
this.platform.enable();
@@ -102,7 +104,6 @@ public class BukkitSparkPlugin extends JavaPlugin implements SparkPlugin {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- this.threadDumper.ensureSetup();
this.platform.executeCommand(new BukkitCommandSender(sender, this.audienceFactory), args);
return true;
}
@@ -152,7 +153,7 @@ public class BukkitSparkPlugin extends JavaPlugin implements SparkPlugin {
@Override
public ThreadDumper getDefaultThreadDumper() {
- return this.threadDumper.get();
+ return this.gameThreadDumper;
}
@Override
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java
index f34899b..5d50eeb 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java
@@ -31,7 +31,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
public class BukkitWorldInfoProvider implements WorldInfoProvider {
diff --git a/spark-bungeecord/build.gradle b/spark-bungeecord/build.gradle
index 1e92621..d96d589 100644
--- a/spark-bungeecord/build.gradle
+++ b/spark-bungeecord/build.gradle
@@ -21,12 +21,9 @@ processResources {
shadowJar {
archiveName = "spark-${project.pluginVersion}-bungeecord.jar"
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-common/build.gradle b/spark-common/build.gradle
index bc493f3..ce09d51 100644
--- a/spark-common/build.gradle
+++ b/spark-common/build.gradle
@@ -8,13 +8,10 @@ license {
dependencies {
api project(':spark-api')
- implementation 'com.github.jvm-profiling-tools:async-profiler:v2.7'
+ implementation 'com.github.jvm-profiling-tools:async-profiler:v2.8.1'
implementation 'org.ow2.asm:asm:9.1'
implementation 'com.google.protobuf:protobuf-javalite:3.15.6'
- implementation 'com.squareup.okhttp3:okhttp:3.14.1'
- implementation 'com.squareup.okio:okio:1.17.3'
implementation 'net.bytebuddy:byte-buddy-agent:1.11.0'
- implementation 'org.tukaani:xz:1.8'
api('net.kyori:adventure-api:4.11.0') {
exclude(module: 'adventure-bom')
exclude(module: 'checker-qual')
@@ -37,13 +34,6 @@ dependencies {
compileOnly 'org.checkerframework:checker-qual:3.8.0'
}
-processResources {
- from(sourceSets.main.resources.srcDirs) {
- include 'spark/linux/libasyncProfiler.so'
- include 'spark/macosx/libasyncProfiler.so'
- }
-}
-
protobuf {
protoc {
if (System.getProperty("os.name") == "Mac OS X" && System.getProperty("os.arch") == "aarch64") {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
index 0ef4556..f92abf3 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
@@ -54,8 +54,6 @@ import me.lucko.spark.common.util.TemporaryFiles;
import net.kyori.adventure.text.event.ClickEvent;
-import okhttp3.OkHttpClient;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -93,7 +91,6 @@ public class SparkPlatform {
private final SparkPlugin plugin;
private final Configuration configuration;
private final String viewerUrl;
- private final OkHttpClient httpClient;
private final BytebinClient bytebinClient;
private final boolean disableResponseBroadcast;
private final List<CommandModule> commandModules;
@@ -116,9 +113,7 @@ public class SparkPlatform {
this.viewerUrl = this.configuration.getString("viewerUrl", "https://spark.lucko.me/");
String bytebinUrl = this.configuration.getString("bytebinUrl", "https://bytebin.lucko.me/");
-
- this.httpClient = new OkHttpClient();
- this.bytebinClient = new BytebinClient(this.httpClient, bytebinUrl, "spark-plugin");
+ this.bytebinClient = new BytebinClient(bytebinUrl, "spark-plugin");
this.disableResponseBroadcast = this.configuration.getBoolean("disableResponseBroadcast", false);
@@ -198,11 +193,6 @@ public class SparkPlatform {
SparkApi.unregister();
TemporaryFiles.deleteTemporaryFiles();
-
- // shutdown okhttp
- // see: https://github.com/square/okhttp/issues/4029
- this.httpClient.dispatcher().executorService().shutdown();
- this.httpClient.connectionPool().evictAll();
}
public SparkPlugin getPlugin() {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java
index 1030f35..5bd62a8 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java
@@ -36,8 +36,6 @@ import me.lucko.spark.proto.SparkHeapProtos;
import net.kyori.adventure.text.event.ClickEvent;
-import okhttp3.MediaType;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -54,7 +52,7 @@ import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
import static net.kyori.adventure.text.format.NamedTextColor.RED;
public class HeapAnalysisModule implements CommandModule {
- private static final MediaType SPARK_HEAP_MEDIA_TYPE = MediaType.parse("application/x-spark-heap");
+ private static final String SPARK_HEAP_MEDIA_TYPE = "application/x-spark-heap";
@Override
public void registerCommands(Consumer<Command> consumer) {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java
index fd5cd67..0a80c31 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java
@@ -44,8 +44,6 @@ import me.lucko.spark.proto.SparkSamplerProtos;
import net.kyori.adventure.text.event.ClickEvent;
-import okhttp3.MediaType;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -66,7 +64,7 @@ import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
import static net.kyori.adventure.text.format.NamedTextColor.RED;
public class SamplerModule implements CommandModule {
- private static final MediaType SPARK_SAMPLER_MEDIA_TYPE = MediaType.parse("application/x-spark-sampler");
+ private static final String SPARK_SAMPLER_MEDIA_TYPE = "application/x-spark-sampler";
/** The sampler instance currently running, if any */
private Sampler activeSampler = null;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/ThreadDumper.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/ThreadDumper.java
index 9d54f50..fd0c413 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/ThreadDumper.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/ThreadDumper.java
@@ -76,17 +76,29 @@ public interface ThreadDumper {
* the game (server/client) thread.
*/
final class GameThread implements Supplier<ThreadDumper> {
+ private Supplier<Thread> threadSupplier;
private Specific dumper = null;
+ public GameThread() {
+
+ }
+
+ public GameThread(Supplier<Thread> threadSupplier) {
+ this.threadSupplier = threadSupplier;
+ }
+
@Override
public ThreadDumper get() {
+ if (this.dumper == null) {
+ setThread(this.threadSupplier.get());
+ this.threadSupplier = null;
+ }
+
return Objects.requireNonNull(this.dumper, "dumper");
}
- public void ensureSetup() {
- if (this.dumper == null) {
- this.dumper = new Specific(new long[]{Thread.currentThread().getId()});
- }
+ public void setThread(Thread thread) {
+ this.dumper = new Specific(new long[]{thread.getId()});
}
}
@@ -98,6 +110,10 @@ public interface ThreadDumper {
private Set<Thread> threads;
private Set<String> threadNamesLowerCase;
+ public Specific(Thread thread) {
+ this.ids = new long[]{thread.getId()};
+ }
+
public Specific(long[] ids) {
this.ids = ids;
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java
index d642a53..ef2c035 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java
@@ -29,13 +29,16 @@ import me.lucko.spark.common.util.TemporaryFiles;
import one.profiler.AsyncProfiler;
import one.profiler.Events;
+import java.io.BufferedReader;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Locale;
import java.util.logging.Level;
+import java.util.stream.Collectors;
/**
* Provides a bridge between spark and async-profiler.
@@ -108,8 +111,13 @@ public enum AsyncProfilerAccess {
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT).replace(" ", "");
String arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT);
+ if (os.equals("linux") && arch.equals("amd64") && isLinuxMusl()) {
+ arch = "amd64-musl";
+ }
+
Table<String, String, String> supported = ImmutableTable.<String, String, String>builder()
.put("linux", "amd64", "linux/amd64")
+ .put("linux", "amd64-musl", "linux/amd64-musl")
.put("linux", "aarch64", "linux/aarch64")
.put("macosx", "amd64", "macos")
.put("macosx", "aarch64", "macos")
@@ -190,4 +198,20 @@ public enum AsyncProfilerAccess {
super("A runtime error occurred whilst loading the native library", cause);
}
}
+
+ // Checks if the system is using musl instead of glibc
+ private static boolean isLinuxMusl() {
+ try {
+ InputStream stream = new ProcessBuilder("sh", "-c", "ldd `which ls`")
+ .start()
+ .getInputStream();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+ String output = reader.lines().collect(Collectors.joining());
+ return output.contains("musl"); // shrug
+ } catch (Throwable e) {
+ // ignore
+ return false;
+ }
+ }
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java b/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
index c2ca1b1..e69b94e 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
@@ -22,73 +22,66 @@ package me.lucko.spark.common.util;
import com.google.protobuf.AbstractMessageLite;
-import okhttp3.MediaType;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import okhttp3.Response;
-
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
import java.util.zip.GZIPOutputStream;
/**
* Utility for posting content to bytebin.
*/
-public class BytebinClient extends AbstractHttpClient {
+public class BytebinClient {
/** The bytebin URL */
private final String url;
/** The client user agent */
private final String userAgent;
- /**
- * Creates a new bytebin instance
- *
- * @param url the bytebin url
- * @param userAgent the client user agent string
- */
- public BytebinClient(OkHttpClient okHttpClient, String url, String userAgent) {
- super(okHttpClient);
+ public BytebinClient(String url, String userAgent) {
this.url = url + (url.endsWith("/") ? "" : "/");
this.userAgent = userAgent;
}
- /**
- * POSTs GZIP compressed content to bytebin.
- *
- * @param buf the compressed content
- * @param contentType the type of the content
- * @return the key of the resultant content
- * @throws IOException if an error occurs
- */
- public Content postContent(byte[] buf, MediaType contentType) throws IOException {
- RequestBody body = RequestBody.create(contentType, buf);
+ private Content postContent(String contentType, Consumer<OutputStream> consumer) throws IOException {
+ URL url = new URL(this.url + "post");
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ try {
+ connection.setConnectTimeout((int) TimeUnit.SECONDS.toMillis(10));
+ connection.setReadTimeout((int) TimeUnit.SECONDS.toMillis(10));
+
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("Content-Type", contentType);
+ connection.setRequestProperty("User-Agent", this.userAgent);
+ connection.setRequestProperty("Content-Encoding", "gzip");
- Request.Builder requestBuilder = new Request.Builder()
- .url(this.url + "post")
- .header("User-Agent", this.userAgent)
- .header("Content-Encoding", "gzip");
+ connection.connect();
+ try (OutputStream output = connection.getOutputStream()) {
+ consumer.accept(output);
+ }
- Request request = requestBuilder.post(body).build();
- try (Response response = makeHttpRequest(request)) {
- String key = response.header("Location");
+ String key = connection.getHeaderField("Location");
if (key == null) {
throw new IllegalStateException("Key not returned");
}
return new Content(key);
+ } finally {
+ connection.getInputStream().close();
+ connection.disconnect();
}
}
- public Content postContent(AbstractMessageLite<?, ?> proto, MediaType contentType) throws IOException {
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- try (OutputStream out = new GZIPOutputStream(byteOut)) {
- proto.writeTo(out);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return postContent(byteOut.toByteArray(), contentType);
+ public Content postContent(AbstractMessageLite<?, ?> proto, String contentType) throws IOException {
+ return postContent(contentType, outputStream -> {
+ try (OutputStream out = new GZIPOutputStream(outputStream)) {
+ proto.writeTo(out);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
}
public static final class Content {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/Compression.java b/spark-common/src/main/java/me/lucko/spark/common/util/Compression.java
index 9295c25..c8100e1 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/util/Compression.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/util/Compression.java
@@ -20,10 +20,6 @@
package me.lucko.spark.common.util;
-import org.tukaani.xz.LZMA2Options;
-import org.tukaani.xz.LZMAOutputStream;
-import org.tukaani.xz.XZOutputStream;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -46,35 +42,35 @@ public enum Compression {
}
return compressedFile;
}
- },
- XZ {
- @Override
- public Path compress(Path file, LongConsumer progressHandler) throws IOException {
- Path compressedFile = file.getParent().resolve(file.getFileName().toString() + ".xz");
- try (InputStream in = Files.newInputStream(file)) {
- try (OutputStream out = Files.newOutputStream(compressedFile)) {
- try (XZOutputStream compressionOut = new XZOutputStream(out, new LZMA2Options())) {
- copy(in, compressionOut, progressHandler);
- }
- }
- }
- return compressedFile;
- }
- },
- LZMA {
- @Override
- public Path compress(Path file, LongConsumer progressHandler) throws IOException {
- Path compressedFile = file.getParent().resolve(file.getFileName().toString() + ".lzma");
- try (InputStream in = Files.newInputStream(file)) {
- try (OutputStream out = Files.newOutputStream(compressedFile)) {
- try (LZMAOutputStream compressionOut = new LZMAOutputStream(out, new LZMA2Options(), true)) {
- copy(in, compressionOut, progressHandler);
- }
- }
- }
- return compressedFile;
- }
};
+ // XZ {
+ // @Override
+ // public Path compress(Path file, LongConsumer progressHandler) throws IOException {
+ // Path compressedFile = file.getParent().resolve(file.getFileName().toString() + ".xz");
+ // try (InputStream in = Files.newInputStream(file)) {
+ // try (OutputStream out = Files.newOutputStream(compressedFile)) {
+ // try (XZOutputStream compressionOut = new XZOutputStream(out, new LZMA2Options())) {
+ // copy(in, compressionOut, progressHandler);
+ // }
+ // }
+ // }
+ // return compressedFile;
+ // }
+ // },
+ // LZMA {
+ // @Override
+ // public Path compress(Path file, LongConsumer progressHandler) throws IOException {
+ // Path compressedFile = file.getParent().resolve(file.getFileName().toString() + ".lzma");
+ // try (InputStream in = Files.newInputStream(file)) {
+ // try (OutputStream out = Files.newOutputStream(compressedFile)) {
+ // try (LZMAOutputStream compressionOut = new LZMAOutputStream(out, new LZMA2Options(), true)) {
+ // copy(in, compressionOut, progressHandler);
+ // }
+ // }
+ // }
+ // return compressedFile;
+ // }
+ // };
public abstract Path compress(Path file, LongConsumer progressHandler) throws IOException;
diff --git a/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so b/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so
new file mode 100755
index 0000000..0a08f7c
--- /dev/null
+++ b/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so
Binary files differ
diff --git a/spark-fabric/build.gradle b/spark-fabric/build.gradle
index 31008bb..35b7a86 100644
--- a/spark-fabric/build.gradle
+++ b/spark-fabric/build.gradle
@@ -70,12 +70,9 @@ shadowJar {
archiveFileName = "spark-fabric-${project.pluginVersion}-dev.jar"
configurations = [project.configurations.shade]
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/AbstractHttpClient.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/mixin/MinecraftClientAccessor.java
index 8ece3d4..7a4fb78 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/util/AbstractHttpClient.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/mixin/MinecraftClientAccessor.java
@@ -18,29 +18,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package me.lucko.spark.common.util;
+package me.lucko.spark.fabric.mixin;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.Response;
+import net.minecraft.client.MinecraftClient;
-import java.io.IOException;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
-public class AbstractHttpClient {
+@Mixin(MinecraftClient.class)
+public interface MinecraftClientAccessor {
- /** The http client */
- protected final OkHttpClient okHttp;
+ @Accessor
+ Thread getThread();
- public AbstractHttpClient(OkHttpClient okHttp) {
- this.okHttp = okHttp;
- }
-
- protected Response makeHttpRequest(Request request) throws IOException {
- Response response = this.okHttp.newCall(request).execute();
- if (!response.isSuccessful()) {
- response.close();
- throw new RuntimeException("Request was unsuccessful: " + response.code() + " - " + response.message());
- }
- return response;
- }
}
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java
index 1876658..0ef6620 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java
@@ -30,6 +30,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.platform.world.WorldInfoProvider;
+import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.tick.TickHook;
import me.lucko.spark.common.tick.TickReporter;
import me.lucko.spark.fabric.FabricCommandSender;
@@ -38,6 +39,7 @@ import me.lucko.spark.fabric.FabricSparkMod;
import me.lucko.spark.fabric.FabricTickHook;
import me.lucko.spark.fabric.FabricTickReporter;
import me.lucko.spark.fabric.FabricWorldInfoProvider;
+import me.lucko.spark.fabric.mixin.MinecraftClientAccessor;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
@@ -57,10 +59,12 @@ public class FabricClientSparkPlugin extends FabricSparkPlugin implements Comman
}
private final MinecraftClient minecraft;
+ private final ThreadDumper.GameThread gameThreadDumper;
public FabricClientSparkPlugin(FabricSparkMod mod, MinecraftClient minecraft) {
super(mod);
this.minecraft = minecraft;
+ this.gameThreadDumper = new ThreadDumper.GameThread(() -> ((MinecraftClientAccessor) minecraft).getThread());
}
@Override
@@ -89,7 +93,6 @@ public class FabricClientSparkPlugin extends FabricSparkPlugin implements Comman
return 0;
}
- this.threadDumper.ensureSetup();
this.platform.executeCommand(new FabricCommandSender(context.getSource().getEntity(), this), args);
return Command.SINGLE_SUCCESS;
}
@@ -120,6 +123,11 @@ public class FabricClientSparkPlugin extends FabricSparkPlugin implements Comman
}
@Override
+ public ThreadDumper getDefaultThreadDumper() {
+ return this.gameThreadDumper.get();
+ }
+
+ @Override
public TickHook createTickHook() {
return new FabricTickHook.Client();
}
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java
index bb1d68c..f840f5e 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java
@@ -33,6 +33,7 @@ import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.platform.serverconfig.ServerConfigProvider;
import me.lucko.spark.common.platform.world.WorldInfoProvider;
+import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.tick.TickHook;
import me.lucko.spark.common.tick.TickReporter;
import me.lucko.spark.fabric.FabricCommandSender;
@@ -63,10 +64,12 @@ public class FabricServerSparkPlugin extends FabricSparkPlugin implements Comman
}
private final MinecraftServer server;
+ private final ThreadDumper gameThreadDumper;
public FabricServerSparkPlugin(FabricSparkMod mod, MinecraftServer server) {
super(mod);
this.server = server;
+ this.gameThreadDumper = new ThreadDumper.Specific(server.getThread());
}
@Override
@@ -97,7 +100,6 @@ public class FabricServerSparkPlugin extends FabricSparkPlugin implements Comman
return 0;
}
- this.threadDumper.ensureSetup();
CommandOutput source = context.getSource().getEntity() != null ? context.getSource().getEntity() : context.getSource().getServer();
this.platform.executeCommand(new FabricCommandSender(source, this), args);
return Command.SINGLE_SUCCESS;
@@ -136,6 +138,11 @@ public class FabricServerSparkPlugin extends FabricSparkPlugin implements Comman
}
@Override
+ public ThreadDumper getDefaultThreadDumper() {
+ return this.gameThreadDumper;
+ }
+
+ @Override
public TickHook createTickHook() {
return new FabricTickHook.Server();
}
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java
index b1392d4..3126f28 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java
@@ -34,7 +34,6 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.SparkPlugin;
import me.lucko.spark.common.command.sender.CommandSender;
-import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.util.ClassSourceLookup;
import me.lucko.spark.common.util.SparkThreadFactory;
import me.lucko.spark.fabric.FabricClassSourceLookup;
@@ -59,7 +58,6 @@ public abstract class FabricSparkPlugin implements SparkPlugin {
protected final ScheduledExecutorService scheduler;
protected SparkPlatform platform;
- protected final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread();
protected FabricSparkPlugin(FabricSparkMod mod) {
this.mod = mod;
@@ -108,11 +106,6 @@ public abstract class FabricSparkPlugin implements SparkPlugin {
}
@Override
- public ThreadDumper getDefaultThreadDumper() {
- return this.threadDumper.get();
- }
-
- @Override
public ClassSourceLookup createClassSourceLookup() {
return new FabricClassSourceLookup();
}
diff --git a/spark-fabric/src/main/resources/spark.mixins.json b/spark-fabric/src/main/resources/spark.mixins.json
index 09587fe..e75b34f 100644
--- a/spark-fabric/src/main/resources/spark.mixins.json
+++ b/spark-fabric/src/main/resources/spark.mixins.json
@@ -5,7 +5,8 @@
"mixins": [],
"client": [
"ClientEntityManagerAccessor",
- "ClientWorldAccessor"
+ "ClientWorldAccessor",
+ "MinecraftClientAccessor"
],
"server": [
"ServerEntityManagerAccessor",
diff --git a/spark-forge/build.gradle b/spark-forge/build.gradle
index 3f46b95..46ac08c 100644
--- a/spark-forge/build.gradle
+++ b/spark-forge/build.gradle
@@ -52,12 +52,9 @@ shadowJar {
archiveName = "spark-${project.pluginVersion}-forge.jar"
configurations = [project.configurations.shade]
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java
index 04c8785..a4c6bd1 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java
@@ -29,6 +29,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.platform.world.WorldInfoProvider;
+import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.tick.TickHook;
import me.lucko.spark.common.tick.TickReporter;
import me.lucko.spark.forge.ForgeCommandSender;
@@ -58,10 +59,12 @@ public class ForgeClientSparkPlugin extends ForgeSparkPlugin implements Command<
}
private final Minecraft minecraft;
+ private final ThreadDumper gameThreadDumper;
public ForgeClientSparkPlugin(ForgeSparkMod mod, Minecraft minecraft) {
super(mod);
this.minecraft = minecraft;
+ this.gameThreadDumper = new ThreadDumper.Specific(minecraft.gameThread);
}
@Override
@@ -84,7 +87,6 @@ public class ForgeClientSparkPlugin extends ForgeSparkPlugin implements Command<
return 0;
}
- this.threadDumper.ensureSetup();
this.platform.executeCommand(new ForgeCommandSender(context.getSource().getEntity(), this), args);
return Command.SINGLE_SUCCESS;
}
@@ -115,6 +117,11 @@ public class ForgeClientSparkPlugin extends ForgeSparkPlugin implements Command<
}
@Override
+ public ThreadDumper getDefaultThreadDumper() {
+ return this.gameThreadDumper;
+ }
+
+ @Override
public TickHook createTickHook() {
return new ForgeTickHook(TickEvent.Type.CLIENT);
}
diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
index f4a51e0..1aeb2b1 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
@@ -33,6 +33,7 @@ import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.platform.serverconfig.ServerConfigProvider;
import me.lucko.spark.common.platform.world.WorldInfoProvider;
+import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.tick.TickHook;
import me.lucko.spark.common.tick.TickReporter;
import me.lucko.spark.forge.ForgeCommandSender;
@@ -75,11 +76,13 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<
}
private final MinecraftServer server;
+ private final ThreadDumper gameThreadDumper;
private Map<String, PermissionNode<Boolean>> registeredPermissions = Collections.emptyMap();
public ForgeServerSparkPlugin(ForgeSparkMod mod, MinecraftServer server) {
super(mod);
this.server = server;
+ this.gameThreadDumper = new ThreadDumper.Specific(server.getRunningThread());
}
@Override
@@ -146,7 +149,6 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<
return 0;
}
- this.threadDumper.ensureSetup();
CommandSource source = context.getSource().getEntity() != null ? context.getSource().getEntity() : context.getSource().getServer();
this.platform.executeCommand(new ForgeCommandSender(source, this), args);
return Command.SINGLE_SUCCESS;
@@ -193,6 +195,11 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<
}
@Override
+ public ThreadDumper getDefaultThreadDumper() {
+ return this.gameThreadDumper;
+ }
+
+ @Override
public TickHook createTickHook() {
return new ForgeTickHook(TickEvent.Type.SERVER);
}
diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java
index f257e34..36a7ce8 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java
@@ -34,7 +34,6 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.SparkPlugin;
import me.lucko.spark.common.command.sender.CommandSender;
-import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.util.ClassSourceLookup;
import me.lucko.spark.common.util.SparkThreadFactory;
import me.lucko.spark.forge.ForgeClassSourceLookup;
@@ -59,7 +58,6 @@ public abstract class ForgeSparkPlugin implements SparkPlugin {
protected final ScheduledExecutorService scheduler;
protected SparkPlatform platform;
- protected final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread();
protected ForgeSparkPlugin(ForgeSparkMod mod) {
this.mod = mod;
@@ -108,11 +106,6 @@ public abstract class ForgeSparkPlugin implements SparkPlugin {
}
@Override
- public ThreadDumper getDefaultThreadDumper() {
- return this.threadDumper.get();
- }
-
- @Override
public ClassSourceLookup createClassSourceLookup() {
return new ForgeClassSourceLookup();
}
diff --git a/spark-forge/src/main/resources/META-INF/accesstransformer.cfg b/spark-forge/src/main/resources/META-INF/accesstransformer.cfg
index 1e418b8..39e9c1a 100644
--- a/spark-forge/src/main/resources/META-INF/accesstransformer.cfg
+++ b/spark-forge/src/main/resources/META-INF/accesstransformer.cfg
@@ -2,3 +2,4 @@ public net.minecraft.server.level.ServerLevel f_143244_ # entityManager
public net.minecraft.world.level.entity.PersistentEntitySectionManager f_157495_ # sectionStorage
public net.minecraft.client.multiplayer.ClientLevel f_171631_ # entityStorage
public net.minecraft.world.level.entity.TransientEntitySectionManager f_157638_ # sectionStorage
+public net.minecraft.client.Minecraft f_91018_ # gameThread \ No newline at end of file
diff --git a/spark-minestom/build.gradle b/spark-minestom/build.gradle
index 26cdc2c..04e5f25 100644
--- a/spark-minestom/build.gradle
+++ b/spark-minestom/build.gradle
@@ -30,11 +30,8 @@ shadowJar {
exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$'))
}
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure.text.feature.pagination', 'me.lucko.spark.lib.adventure.pagination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-nukkit/build.gradle b/spark-nukkit/build.gradle
index 2e1ad55..b15009a 100644
--- a/spark-nukkit/build.gradle
+++ b/spark-nukkit/build.gradle
@@ -25,11 +25,8 @@ processResources {
shadowJar {
archiveName = "spark-${project.pluginVersion}-nukkit.jar"
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
diff --git a/spark-sponge7/build.gradle b/spark-sponge7/build.gradle
index b6f8273..b06d3bd 100644
--- a/spark-sponge7/build.gradle
+++ b/spark-sponge7/build.gradle
@@ -22,12 +22,9 @@ blossom {
shadowJar {
archiveFileName = "spark-${project.pluginVersion}-sponge7.jar"
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java
index 324e242..e6c9a04 100644
--- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java
+++ b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7SparkPlugin.java
@@ -73,9 +73,9 @@ public class Sponge7SparkPlugin implements SparkPlugin {
private final Path configDirectory;
private final SpongeExecutorService asyncExecutor;
private final SpongeExecutorService syncExecutor;
+ private final ThreadDumper.GameThread gameThreadDumper = new ThreadDumper.GameThread();
private SparkPlatform platform;
- private final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread();
@Inject
public Sponge7SparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory, @AsynchronousExecutor SpongeExecutorService asyncExecutor, @SynchronousExecutor SpongeExecutorService syncExecutor) {
@@ -85,6 +85,8 @@ public class Sponge7SparkPlugin implements SparkPlugin {
this.configDirectory = configDirectory;
this.asyncExecutor = asyncExecutor;
this.syncExecutor = syncExecutor;
+
+ this.syncExecutor.execute(() -> this.gameThreadDumper.setThread(Thread.currentThread()));
}
@Listener
@@ -151,7 +153,7 @@ public class Sponge7SparkPlugin implements SparkPlugin {
@Override
public ThreadDumper getDefaultThreadDumper() {
- return this.threadDumper.get();
+ return this.gameThreadDumper.get();
}
@Override
@@ -201,7 +203,6 @@ public class Sponge7SparkPlugin implements SparkPlugin {
@Override
public CommandResult process(CommandSource source, String arguments) {
- this.plugin.threadDumper.ensureSetup();
this.plugin.platform.executeCommand(new Sponge7CommandSender(source), arguments.split(" "));
return CommandResult.empty();
}
diff --git a/spark-sponge8/build.gradle b/spark-sponge8/build.gradle
index 314ab18..202c308 100644
--- a/spark-sponge8/build.gradle
+++ b/spark-sponge8/build.gradle
@@ -28,11 +28,8 @@ shadowJar {
exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$'))
}
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure.text.feature.pagination', 'me.lucko.spark.lib.adventure.pagination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java
index 68e47e3..83b2ec2 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java
+++ b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java
@@ -20,6 +20,7 @@
package me.lucko.spark.sponge;
+import com.google.common.base.Suppliers;
import com.google.inject.Inject;
import me.lucko.spark.common.SparkPlatform;
@@ -56,6 +57,7 @@ import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
+import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -68,10 +70,10 @@ public class Sponge8SparkPlugin implements SparkPlugin {
private final Game game;
private final Path configDirectory;
private final ExecutorService asyncExecutor;
- private final ExecutorService syncExecutor;
+ private final Supplier<ExecutorService> syncExecutor;
+ private final ThreadDumper.GameThread gameThreadDumper = new ThreadDumper.GameThread();
private SparkPlatform platform;
- private final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread();
@Inject
public Sponge8SparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory) {
@@ -80,14 +82,15 @@ public class Sponge8SparkPlugin implements SparkPlugin {
this.game = game;
this.configDirectory = configDirectory;
this.asyncExecutor = game.asyncScheduler().executor(pluginContainer);
-
- if (game.isServerAvailable()) {
- this.syncExecutor = game.server().scheduler().executor(pluginContainer);
- } else if (game.isClientAvailable()) {
- this.syncExecutor = game.client().scheduler().executor(pluginContainer);
- } else {
- throw new IllegalStateException("Server and client both unavailable");
- }
+ this.syncExecutor = Suppliers.memoize(() -> {
+ if (this.game.isServerAvailable()) {
+ return this.game.server().scheduler().executor(this.pluginContainer);
+ } else if (this.game.isClientAvailable()) {
+ return this.game.client().scheduler().executor(this.pluginContainer);
+ } else {
+ throw new IllegalStateException("Server and client both unavailable");
+ }
+ });
}
@@ -98,6 +101,8 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Listener
public void onEnable(StartedEngineEvent<Server> event) {
+ executeSync(() -> this.gameThreadDumper.setThread(Thread.currentThread()));
+
this.platform = new SparkPlatform(this);
this.platform.enable();
}
@@ -141,7 +146,7 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public void executeSync(Runnable task) {
- this.syncExecutor.execute(task);
+ this.syncExecutor.get().execute(task);
}
@Override
@@ -159,7 +164,7 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public ThreadDumper getDefaultThreadDumper() {
- return this.threadDumper.get();
+ return this.gameThreadDumper.get();
}
@Override
@@ -204,7 +209,6 @@ public class Sponge8SparkPlugin implements SparkPlugin {
@Override
public CommandResult process(CommandCause cause, ArgumentReader.Mutable arguments) {
- this.plugin.threadDumper.ensureSetup();
this.plugin.platform.executeCommand(new Sponge8CommandSender(cause), arguments.input().split(" "));
return CommandResult.success();
}
diff --git a/spark-velocity/build.gradle b/spark-velocity/build.gradle
index b2e938b..275d3df 100644
--- a/spark-velocity/build.gradle
+++ b/spark-velocity/build.gradle
@@ -26,11 +26,8 @@ shadowJar {
exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$'))
}
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure.text.feature.pagination', 'me.lucko.spark.lib.adventure.pagination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-velocity4/build.gradle b/spark-velocity4/build.gradle
index 5bef80b..1f8e8ee 100644
--- a/spark-velocity4/build.gradle
+++ b/spark-velocity4/build.gradle
@@ -31,11 +31,8 @@ shadowJar {
exclude(dependency('net.kyori:^(?!adventure-text-feature-pagination).+$'))
}
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure.text.feature.pagination', 'me.lucko.spark.lib.adventure.pagination'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'
relocate 'one.profiler', 'me.lucko.spark.lib.asyncprofiler'
diff --git a/spark-waterdog/build.gradle b/spark-waterdog/build.gradle
index c11e3fb..d0c7de7 100644
--- a/spark-waterdog/build.gradle
+++ b/spark-waterdog/build.gradle
@@ -30,11 +30,8 @@ processResources {
shadowJar {
archiveName = "spark-${project.pluginVersion}-waterdog.jar"
- relocate 'okio', 'me.lucko.spark.lib.okio'
- relocate 'okhttp3', 'me.lucko.spark.lib.okhttp3'
relocate 'net.kyori.adventure', 'me.lucko.spark.lib.adventure'
relocate 'net.kyori.examination', 'me.lucko.spark.lib.adventure.examination'
- relocate 'org.tukaani.xz', 'me.lucko.spark.lib.xz'
relocate 'net.bytebuddy', 'me.lucko.spark.lib.bytebuddy'
relocate 'com.google.protobuf', 'me.lucko.spark.lib.protobuf'
relocate 'org.objectweb.asm', 'me.lucko.spark.lib.asm'