diff --git a/build.gradle b/build.gradle index 0c18a8c..32d60a7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { - id "architectury-plugin" version "2.0.64" - id "forgified-fabric-loom" version "0.6.53" apply false + id "architectury-plugin" + id "forgified-fabric-loom" apply false id 'maven-publish' id 'com.matthewprenger.cursegradle' } @@ -19,6 +19,10 @@ subprojects { } ext.total_version = "$mod_version+$minecraft_version" + + dependencies { + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" + } } allprojects { diff --git a/changelog.md b/changelog.md index 0b5da33..24f6e88 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ + +## 3.2.0 +- Added a new option `forceCrashScreen` that will prevent cases in which the game closes with no crash log. Instead, the game will crash normally. ### 3.1.9 - Fixed additional crash stack traces appearing when debugModIdentification is false. ### 3.1.8 diff --git a/common/src/main/java/fudge/notenoughcrashes/ModConfig.java b/common/src/main/java/fudge/notenoughcrashes/ModConfig.java index 33258c5..0ce060e 100644 --- a/common/src/main/java/fudge/notenoughcrashes/ModConfig.java +++ b/common/src/main/java/fudge/notenoughcrashes/ModConfig.java @@ -21,6 +21,7 @@ public enum CrashLogUploadType { public boolean disableReturnToMainMenu = false; public boolean deobfuscateStackTrace = true; public boolean debugModIdentification = false; + public boolean forceCrashScreen = false; public static ModConfig instance() { if (instance != null) { diff --git a/common/src/main/java/fudge/notenoughcrashes/NotEnoughCrashes.java b/common/src/main/java/fudge/notenoughcrashes/NotEnoughCrashes.java index 4672749..93f966a 100644 --- a/common/src/main/java/fudge/notenoughcrashes/NotEnoughCrashes.java +++ b/common/src/main/java/fudge/notenoughcrashes/NotEnoughCrashes.java @@ -2,12 +2,14 @@ import fudge.notenoughcrashes.platform.NecPlatform; import fudge.notenoughcrashes.test.TestBlock; +import fudge.notenoughcrashes.utils.SystemExitBlock; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.security.Permission; public class NotEnoughCrashes { @@ -23,7 +25,6 @@ public class NotEnoughCrashes { public static final boolean FILTER_ENTRYPOINT_CATCHER = true; - public static final boolean ENABLE_ENTRYPOINT_CATCHING = !NecPlatform.instance().isDevelopmentEnvironment() || DEBUG_ENTRYPOINT; public static void ensureDirectoryExists() throws IOException { @@ -31,6 +32,7 @@ public static void ensureDirectoryExists() throws IOException { } public static void initialize() { + if (ModConfig.instance().forceCrashScreen) SystemExitBlock.forbidSystemExitCall(); ModConfig.instance(); if (DEBUG_GAMELOOP) TestBlock.init(); @@ -39,5 +41,4 @@ public static void initialize() { } - } diff --git a/common/src/main/java/fudge/notenoughcrashes/test/TestBlock.java b/common/src/main/java/fudge/notenoughcrashes/test/TestBlock.java index c1c1682..d7288cb 100644 --- a/common/src/main/java/fudge/notenoughcrashes/test/TestBlock.java +++ b/common/src/main/java/fudge/notenoughcrashes/test/TestBlock.java @@ -25,12 +25,16 @@ public TestBlock() { @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { +// System.exit(0); try { + throw new RuntimeException("something NPED!", new NullPointerException("THIS NPED!")); } catch (Throwable e) { e.addSuppressed(new NullPointerException("SUPRESSED!")); throw e; } + +// return null; } public static void init() { diff --git a/common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlock.java b/common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlock.java new file mode 100644 index 0000000..77c8fd4 --- /dev/null +++ b/common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlock.java @@ -0,0 +1,22 @@ +package fudge.notenoughcrashes.utils; + +import java.security.Permission; + +public class SystemExitBlock { + + public static void forbidSystemExitCall() { + final SecurityManager securityManager = new SecurityManager() { + public void checkPermission( Permission permission ) { + if( permission.getName().startsWith("exitVM") ) { + throw new SystemExitBlockedException("An attempt was made to forcefully close the game with no stack trace (see stack trace)." + + " Not Enough Crashes made the game simply crash instead since the forceCrashScreen option is enabled.") ; + } + } + } ; + System.setSecurityManager( securityManager ) ; + } + + private static void enableSystemExitCall() { + System.setSecurityManager( null ) ; + } +} diff --git a/common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlockedException.java b/common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlockedException.java new file mode 100644 index 0000000..b41e49e --- /dev/null +++ b/common/src/main/java/fudge/notenoughcrashes/utils/SystemExitBlockedException.java @@ -0,0 +1,8 @@ +package fudge.notenoughcrashes.utils; + +class SystemExitBlockedException extends SecurityException { + public SystemExitBlockedException(String s) { + super(s); + } +} + diff --git a/fabric/build.gradle b/fabric/build.gradle index fd6c33c..278f714 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -3,28 +3,29 @@ plugins { } configurations { -shadow + shadowCommon } architectury { platformSetupLoomIde() + fabric() } dependencies { - minecraft("com.mojang:minecraft:${rootProject.minecraft_version}") +// minecraft("com.mojang:minecraft:${rootProject.minecraft_version}") mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2") - modCompile("net.fabricmc:fabric-loader:${rootProject.loader_version}") - modCompile("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}") +// modCompile("net.fabricmc:fabric-loader:${rootProject.loader_version}") + modApi ("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}") // Remove the next line if you don't want to depend on the API // modCompile("me.shedaniel:architectury:${rootProject.architectury_version}:fabric") - compileOnly(project(path: ":common")) { + implementation(project(path: ":common")) { transitive = false } - runtimeOnly(project(path: ":common", configuration: "transformDevelopmentFabric")) { + developmentFabric(project(path: ":common")) { transitive = false } - shadow(project(path: ":common", configuration: "transformProductionFabric")) { + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive = false } } @@ -39,16 +40,30 @@ processResources { } shadowJar { - configurations = [project.configurations.shadow] - classifier "shadow" + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" } remapJar { - dependsOn(shadowJar) - input.set(shadowJar.archivePath) + input.set shadowJar.archiveFile + dependsOn shadowJar classifier "fabric" } +jar { + classifier "dev" +} + +java { + withSourcesJar() +} + +sourcesJar { + def commonSources = project(":common").remapSourcesJar + dependsOn commonSources + from zipTree(commonSources.output) +} + curseforge { apiKey = project.hasProperty("curseforge_api_key") ? project.curseforge_api_key : "" project { diff --git a/forge/build.gradle b/forge/build.gradle index 828bd33..33a5681 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -5,11 +5,12 @@ plugins { } configurations { - shadow + shadowCommon } architectury { platformSetupLoomIde() + forge() } loom { @@ -18,7 +19,7 @@ loom { } dependencies { - minecraft("com.mojang:minecraft:${rootProject.minecraft_version}") +// minecraft("com.mojang:minecraft:${rootProject.minecraft_version}") mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2") forge("net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}") // modRuntime(files("testmods/modid-1.0.jar")) @@ -28,10 +29,10 @@ dependencies { compileOnly(project(path: ":common")) { transitive = false } - runtimeOnly(project(path: ":common", configuration: "transformDevelopmentForge")) { + developmentForge(project(path: ":common")) { transitive = false } - shadow(project(path: ":common", configuration: "transformProductionForge")) { + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } } @@ -47,13 +48,13 @@ processResources { shadowJar { exclude "fabric.mod.json" - configurations = [project.configurations.shadow] - classifier "shadow" + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" } remapJar { - dependsOn(shadowJar) - input.set(shadowJar.archivePath) + input.set shadowJar.archiveFile + dependsOn shadowJar classifier "forge" } jar { @@ -64,6 +65,20 @@ jar { } } +jar { + classifier "dev" +} + +java { + withSourcesJar() +} + +sourcesJar { + def commonSources = project(":common").remapSourcesJar + dependsOn commonSources + from zipTree(commonSources.output) +} + curseforge { apiKey = project.hasProperty("curseforge_api_key") ? project.curseforge_api_key : "" project { diff --git a/gradle.properties b/gradle.properties index cf30b52..ea2b057 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,10 +2,12 @@ org.gradle.jvmargs=-Xmx2048M archives_base_name=notenoughcrashes -mod_version=3.1.8 +mod_version=3.2.0 maven_group=fudge.notenoughcrashes -architectury_version=1.4.91 +architectury_version=1.8.131 +architectury_plugin_version=3.0-SNAPSHOT +forgeloom_version=0.6-SNAPSHOT forge_version=36.0.1 diff --git a/logs/debug.log b/logs/debug.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/latest.log b/logs/latest.log new file mode 100644 index 0000000..e69de29 diff --git a/settings.gradle b/settings.gradle index 30fb5fc..5a84597 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,13 +2,15 @@ pluginManagement { repositories { jcenter() maven { url "https://maven.fabricmc.net/" } - maven { url "https://dl.bintray.com/shedaniel/cloth" } + maven { url "https://maven.shedaniel.me/"} maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() } plugins { id 'com.matthewprenger.cursegradle' version cursegradle_version + id "architectury-plugin" version architectury_plugin_version + id "forgified-fabric-loom" version forgeloom_version } }