Skip to content

Commit

Permalink
3.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfudge committed Feb 8, 2021
1 parent 2490c69 commit c4be043
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### 3.1.7
- Added a new config option: debugModIdentification, that will hopefully help in discovering mods in more cases.
### 3.1.6
- (Forge) Fixed being unable to identify crashing mods that have multiple authors.
### 3.1.5
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/fudge/notenoughcrashes/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum CrashLogUploadType {
public CrashLogUploadType uploadCrashLogTo = CrashLogUploadType.GIST;
public boolean disableReturnToMainMenu = false;
public boolean deobfuscateStackTrace = true;
public boolean debugModIdentification = false;

public static ModConfig instance() {
if (instance != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fudge.notenoughcrashes.stacktrace;

import fudge.notenoughcrashes.ModConfig;
import fudge.notenoughcrashes.NotEnoughCrashes;
import fudge.notenoughcrashes.platform.CommonModMetadata;
import fudge.notenoughcrashes.platform.NecPlatform;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -52,18 +54,29 @@ private static Set<CommonModMetadata> identifyFromThrowable(Throwable e) {
return mods;
}

private static final boolean debugLog = true;

private static void debug(String message) {
if (ModConfig.instance().debugModIdentification) NotEnoughCrashes.LOGGER.info(message);
}

// TODO: get a list of mixin transformers that affected the class and blame those too
private static Set<CommonModMetadata> identifyFromClass(String className, Map<URI, Set<CommonModMetadata>> modMap) {
debug("Analyzing " + className);
// Skip identification for Mixin, one's mod copy of the library is shared with all other mods
if (className.startsWith("org.spongepowered.asm.mixin.")) {
debug("Ignoring class " + className + " for identification because it is a mixin class");
return Collections.emptySet();
}

try {
// Get the URL of the class
Class<?> clazz = Class.forName(className);
CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
if (codeSource == null) return Collections.emptySet(); // Some internal native sun classes
if (codeSource == null) {
debug("Ignoring class " + className + " for identification because the code source could not be found");
return Collections.emptySet(); // Some internal native sun classes
}
URL url = codeSource.getLocation();

if (url == null) {
Expand Down Expand Up @@ -92,6 +105,10 @@ private static Set<CommonModMetadata> identifyFromClass(String className, Map<UR
// Get the mod containing that class
return metadata;
} catch (URISyntaxException | IOException | ClassNotFoundException | NoClassDefFoundError e) {
debug("Ignoring class " + className + " for identification because an error occurred");
if (debugLog) {
e.printStackTrace();
}
return Collections.emptySet(); // we cannot do it
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2048M


archives_base_name=notenoughcrashes
mod_version=3.1.6
mod_version=3.1.7
maven_group=fudge.notenoughcrashes

architectury_version=1.4.91
Expand Down

0 comments on commit c4be043

Please sign in to comment.