aboutsummaryrefslogtreecommitdiff
path: root/spark-fabric/src/main/java/me/lucko
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2022-09-19 18:57:02 +0100
committerLuck <git@lucko.me>2022-09-19 20:09:01 +0100
commit7079484d428321c9b3db09394577efda4d591a4e (patch)
tree1e751e3c832d6df00c7e50357be44b85a2fd5df9 /spark-fabric/src/main/java/me/lucko
parent7ef9b6281135ce0a24f3c14c2255d9a2c2eca969 (diff)
downloadspark-7079484d428321c9b3db09394577efda4d591a4e.tar.gz
spark-7079484d428321c9b3db09394577efda4d591a4e.tar.bz2
spark-7079484d428321c9b3db09394577efda4d591a4e.zip
Provide extra metadata about sources in sampler data
Diffstat (limited to 'spark-fabric/src/main/java/me/lucko')
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/FabricClassSourceLookup.java2
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java19
2 files changed, 19 insertions, 2 deletions
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricClassSourceLookup.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricClassSourceLookup.java
index 9ffac18..51834fc 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricClassSourceLookup.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricClassSourceLookup.java
@@ -22,8 +22,8 @@ package me.lucko.spark.fabric;
import com.google.common.collect.ImmutableMap;
+import me.lucko.spark.common.sampler.source.ClassSourceLookup;
import me.lucko.spark.common.util.ClassFinder;
-import me.lucko.spark.common.util.ClassSourceLookup;
import me.lucko.spark.fabric.smap.MixinUtils;
import me.lucko.spark.fabric.smap.SourceMap;
import me.lucko.spark.fabric.smap.SourceMapProvider;
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 3126f28..9a03b4e 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,11 +34,14 @@ 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.util.ClassSourceLookup;
+import me.lucko.spark.common.sampler.source.ClassSourceLookup;
+import me.lucko.spark.common.sampler.source.SourceMetadata;
import me.lucko.spark.common.util.SparkThreadFactory;
import me.lucko.spark.fabric.FabricClassSourceLookup;
import me.lucko.spark.fabric.FabricSparkMod;
+import net.fabricmc.loader.api.FabricLoader;
+import net.fabricmc.loader.api.metadata.Person;
import net.minecraft.server.command.CommandOutput;
import org.apache.logging.log4j.LogManager;
@@ -46,10 +49,12 @@ import org.apache.logging.log4j.Logger;
import java.nio.file.Path;
import java.util.Arrays;
+import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Level;
+import java.util.stream.Collectors;
public abstract class FabricSparkPlugin implements SparkPlugin {
@@ -110,6 +115,18 @@ public abstract class FabricSparkPlugin implements SparkPlugin {
return new FabricClassSourceLookup();
}
+ @Override
+ public Collection<SourceMetadata> getKnownSources() {
+ return SourceMetadata.gather(
+ FabricLoader.getInstance().getAllMods(),
+ mod -> mod.getMetadata().getId(),
+ mod -> mod.getMetadata().getVersion().getFriendlyString(),
+ mod -> mod.getMetadata().getAuthors().stream()
+ .map(Person::getName)
+ .collect(Collectors.joining(", "))
+ );
+ }
+
protected CompletableFuture<Suggestions> generateSuggestions(CommandSender sender, String[] args, SuggestionsBuilder builder) {
SuggestionsBuilder suggestions;