diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/CrashReportAnalyzer.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/CrashReportAnalyzer.java index 624006aaa..25c4e7e71 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/CrashReportAnalyzer.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/CrashReportAnalyzer.java @@ -169,7 +169,8 @@ public final class CrashReportAnalyzer { } private static final Pattern CRASH_REPORT_STACK_TRACE_PATTERN = Pattern.compile("Description: (.*?)[\\n\\r]+(?[\\w\\W\\n\\r]+)A detailed walkthrough of the error"); - private static final Pattern STACK_TRACE_LINE_PATTERN = Pattern.compile("at (?.*?)\\((.*?)\\)"); + private static final Pattern STACK_TRACE_LINE_PATTERN = Pattern.compile("at (?.*?)\\((?.*?)\\)"); + private static final Pattern STACK_TRACE_LINE_MODULE_PATTERN = Pattern.compile("\\{(?.*)}"); private static final Set PACKAGE_KEYWORD_BLACK_LIST = new HashSet<>(Arrays.asList( "net", "minecraft", "item", "block", "player", "tileentity", "events", "common", "client", "entity", "mojang", "main", "gui", "world", "server", "dedicated", // minecraft "renderer", "chunk", "model", "loading", "color", "pipeline", "inventory", "launcher", "physics", "particle", "gen", "registry", "worldgen", "texture", "biomes", "biome", @@ -198,6 +199,20 @@ public final class CrashReportAnalyzer { } result.add(method[i]); } + + Matcher moduleMatcher = STACK_TRACE_LINE_MODULE_PATTERN.matcher(line); + if (moduleMatcher.find()) { + for (String module : moduleMatcher.group("tokens").split(",")) { + String[] split = module.split(":"); + if (split.length >= 2 && "xf".equals(split[0])) { + if (PACKAGE_KEYWORD_BLACK_LIST.contains(split[1])) { + continue; + } + + result.add(split[1]); + } + } + } } } } diff --git a/HMCLCore/src/test/java/org/jackhuang/hmcl/game/CrashReportAnalyzerTest.java b/HMCLCore/src/test/java/org/jackhuang/hmcl/game/CrashReportAnalyzerTest.java index da8cdbc78..db8ae1aa9 100644 --- a/HMCLCore/src/test/java/org/jackhuang/hmcl/game/CrashReportAnalyzerTest.java +++ b/HMCLCore/src/test/java/org/jackhuang/hmcl/game/CrashReportAnalyzerTest.java @@ -419,6 +419,13 @@ public class CrashReportAnalyzerTest { CrashReportAnalyzer.findKeywordsFromCrashReport(loadLog("/crash-report/mod/twilightforest.txt"))); } + @Test + public void optifine() throws IOException { + Assert.assertEquals( + new HashSet<>(Collections.singletonList("OptiFine")), + CrashReportAnalyzer.findKeywordsFromCrashReport(loadLog("/crash-report/mod/twilightforest_optifine_incompatibility.txt"))); + } + @Test public void wizardry() throws IOException { Assert.assertEquals(