aboutsummaryrefslogtreecommitdiff
path: root/spark-forge/src/main/java
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2022-07-12 22:37:59 +0100
committerLuck <git@lucko.me>2022-07-12 22:37:59 +0100
commit73dd214ae66bab483ee8b4f0ed03881466da92e8 (patch)
tree11b433c6b9b15e75249732248c150c35af08c24f /spark-forge/src/main/java
parenta10f966a443d56845a5efb1e65232e6b87eabb96 (diff)
downloadspark-73dd214ae66bab483ee8b4f0ed03881466da92e8.tar.gz
spark-73dd214ae66bab483ee8b4f0ed03881466da92e8.tar.bz2
spark-73dd214ae66bab483ee8b4f0ed03881466da92e8.zip
Improve/fix game thread dumper
Diffstat (limited to 'spark-forge/src/main/java')
-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
3 files changed, 16 insertions, 9 deletions
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();
}