From a3129bc834bf22b89f7ac545a960b89361b03459 Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 27 Mar 2021 18:51:20 +0000 Subject: Execute commands async --- .../java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java | 1 + .../java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java | 1 + .../src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'spark-fabric/src/main/java') 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 eec7b73..c7efb4e 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 @@ -105,6 +105,7 @@ public class FabricClientSparkPlugin extends FabricSparkPlugin implements Sugges return false; } + this.threadDumper.ensureSetup(); this.platform.executeCommand(new FabricCommandSender(this.minecraft.player, this), args); this.minecraft.inGameHud.getChatHud().addToMessageHistory(chat); return true; 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 b8f94f5..7e88a24 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 @@ -81,6 +81,7 @@ public class FabricServerSparkPlugin extends FabricSparkPlugin implements Comman return 0; } + this.threadDumper.ensureSetup(); CommandOutput source = context.getSource().getEntity() != null ? context.getSource().getEntity() : context.getSource().getMinecraftServer(); this.platform.executeCommand(new FabricCommandSender(source, this), args); return Command.SINGLE_SUCCESS; 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 3454365..59610b1 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 @@ -44,6 +44,7 @@ public abstract class FabricSparkPlugin implements SparkPlugin { private final FabricSparkMod mod; protected final ScheduledExecutorService scheduler; protected final SparkPlatform platform; + protected final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread(); protected FabricSparkPlugin(FabricSparkMod mod) { this.mod = mod; @@ -85,7 +86,7 @@ public abstract class FabricSparkPlugin implements SparkPlugin { @Override public ThreadDumper getDefaultThreadDumper() { - return new ThreadDumper.Specific(new long[]{Thread.currentThread().getId()}); + return this.threadDumper.get(); } protected static void registerCommands(CommandDispatcher dispatcher, Command executor, SuggestionProvider suggestor, String... aliases) { -- cgit