Crash report extended to show ModLauncher FML and Forge data.
Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
parent
4c05c63a04
commit
e17714583f
6 changed files with 82 additions and 35 deletions
|
@ -367,7 +367,7 @@ project(':forge') {
|
|||
installer 'org.ow2.asm:asm:6.2'
|
||||
installer 'org.ow2.asm:asm-commons:6.2'
|
||||
installer 'org.ow2.asm:asm-tree:6.2'
|
||||
installer 'cpw.mods:modlauncher:3.0.+'
|
||||
installer 'cpw.mods:modlauncher:3.1.+'
|
||||
installer 'cpw.mods:grossjava9hacks:1.1.+'
|
||||
installer 'net.minecraftforge:accesstransformers:0.16.+:shadowed'
|
||||
installer 'net.minecraftforge:eventbus:0.10.+:service'
|
||||
|
|
|
@ -44,6 +44,8 @@ import java.net.URL;
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
@ -75,6 +77,7 @@ public class FMLLoader
|
|||
static String forgeVersion;
|
||||
private static String forgeGroup;
|
||||
private static Predicate<String> classLoaderExclusions;
|
||||
private static String launchHandlerName;
|
||||
|
||||
static void onInitialLoad(IEnvironment environment, Set<String> otherServices) throws IncompatibleEnvironmentException
|
||||
{
|
||||
|
@ -166,6 +169,7 @@ public class FMLLoader
|
|||
LOGGER.fatal(CORE, "Incompatible Launch handler found - type {}, cannot continue", launchHandler.get().getClass().getName());
|
||||
throw new RuntimeException("Incompatible launch handler found");
|
||||
}
|
||||
launchHandlerName = launchHandler.get().name();
|
||||
gamePath = environment.getProperty(IEnvironment.Keys.GAMEDIR.get()).orElse(Paths.get(".").toAbsolutePath());
|
||||
|
||||
FMLCommonLaunchHandler commonLaunchHandler = (FMLCommonLaunchHandler)launchHandler.get();
|
||||
|
@ -268,4 +272,16 @@ public class FMLLoader
|
|||
public static String getMcpVersion() {
|
||||
return mcpVersion;
|
||||
}
|
||||
|
||||
public static String getLauncherInfo() {
|
||||
return Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.MLIMPL_VERSION.get()).orElse("MISSING");
|
||||
}
|
||||
|
||||
public static List<Map<String, String>> modLauncherModList() {
|
||||
return Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.MODLIST.get()).orElseGet(Collections::emptyList);
|
||||
}
|
||||
|
||||
public static String launcherHandlerName() {
|
||||
return launchHandlerName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,15 @@ import java.net.URLClassLoader;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.rethrowFunction;
|
||||
|
@ -58,6 +65,10 @@ public class LanguageLoadingProvider
|
|||
languageProviders.forEach(consumer);
|
||||
}
|
||||
|
||||
public <T> Stream<T> applyForEach(final Function<IModLanguageProvider, T> function) {
|
||||
return languageProviders.stream().map(function);
|
||||
}
|
||||
|
||||
private static class ModLanguageWrapper {
|
||||
|
||||
private final IModLanguageProvider modLanguageProvider;
|
||||
|
|
|
@ -26,43 +26,12 @@ import net.minecraftforge.fml.common.ICrashCallable;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class CrashReportExtender
|
||||
{
|
||||
private static List<ICrashCallable> crashCallables = new ArrayList<>();
|
||||
|
||||
static {
|
||||
registerCrashCallable(new ICrashCallable() {
|
||||
@Override
|
||||
public String call()
|
||||
{
|
||||
return "New FML!";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return "FML";
|
||||
}
|
||||
});
|
||||
|
||||
registerCrashCallable(new ICrashCallable()
|
||||
{
|
||||
@Override
|
||||
public String call()
|
||||
{
|
||||
return "Nothing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return "Loaded coremods (and transformers)";
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void enhanceCrashReport(final CrashReport crashReport, final CrashReportCategory category)
|
||||
{
|
||||
for (final ICrashCallable call: crashCallables)
|
||||
|
@ -76,6 +45,18 @@ public class CrashReportExtender
|
|||
crashCallables.add(callable);
|
||||
}
|
||||
|
||||
public static void registerCrashCallable(String headerName, Callable<String> reportGenerator) {
|
||||
registerCrashCallable(new ICrashCallable() {
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return headerName;
|
||||
}
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return reportGenerator.call();
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void addCrashReportHeader(StringBuilder stringbuilder, CrashReport crashReport)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -70,6 +70,20 @@ public class ModList
|
|||
final int loadingThreadCount = FMLConfig.loadingThreadCount();
|
||||
LOGGER.debug(LOADING, "Using {} threads for parallel mod-loading", loadingThreadCount);
|
||||
modLoadingThreadPool = new ForkJoinPool(loadingThreadCount, ModList::newForkJoinWorkerThread, null, false);
|
||||
CrashReportExtender.registerCrashCallable("Mod List", this::crashReport);
|
||||
}
|
||||
|
||||
private String getModContainerState(String modId) {
|
||||
return getModContainerById(modId).map(ModContainer::getCurrentState).map(Object::toString).orElse("NONE");
|
||||
}
|
||||
|
||||
private String fileToLine(ModFile mf) {
|
||||
return mf.getFileName() + " " + mf.getModInfos().get(0).getDisplayName() + " " +
|
||||
mf.getModInfos().stream().map(mi -> mi.getModId() + "@" + mi.getVersion() + " " +
|
||||
getModContainerState(mi.getModId())).collect(Collectors.joining(", ", "{", "}"));
|
||||
}
|
||||
private String crashReport() {
|
||||
return "\n"+applyForEachModFile(this::fileToLine).collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
||||
}
|
||||
|
||||
public static ModList of(List<ModFile> modFiles, List<ModInfo> sortedList)
|
||||
|
@ -187,6 +201,10 @@ public class ModList
|
|||
modFiles.stream().map(ModFileInfo::getFile).forEach(fileConsumer);
|
||||
}
|
||||
|
||||
private <T> Stream<T> applyForEachModFile(Function<ModFile, T> function) {
|
||||
return modFiles.stream().map(ModFileInfo::getFile).map(function);
|
||||
}
|
||||
|
||||
public void forEachModContainer(BiConsumer<String, ModContainer> modContainerConsumer) {
|
||||
indexedMods.forEach(modContainerConsumer);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import net.minecraftforge.forgespi.language.IModInfo;
|
|||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
import net.minecraftforge.registries.ObjectHolderRegistry;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -114,7 +115,27 @@ public class ModLoader
|
|||
this.loadingWarnings = FMLLoader.getLoadingModList().
|
||||
getBrokenFiles().stream().map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE,
|
||||
InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName())).collect(Collectors.toList());
|
||||
LOGGER.info(CORE, "Loading Network data for FML net version: {}", FMLNetworkConstants.NETVERSION);
|
||||
LOGGER.debug(CORE, "Loading Network data for FML net version: {}", FMLNetworkConstants.NETVERSION);
|
||||
CrashReportExtender.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo);
|
||||
CrashReportExtender.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName);
|
||||
CrashReportExtender.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming);
|
||||
CrashReportExtender.registerCrashCallable("ModLauncher services", this::computeModLauncherServiceList);
|
||||
CrashReportExtender.registerCrashCallable("FML", ForgeVersion::getSpec);
|
||||
CrashReportExtender.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion());
|
||||
CrashReportExtender.registerCrashCallable("FML Language Providers", this::computeLanguageList);
|
||||
}
|
||||
|
||||
private String computeLanguageList() {
|
||||
return "\n"+FMLLoader.getLanguageLoadingProvider().applyForEach(lp->lp.name() +"@"+ lp.getClass().getPackage().getImplementationVersion()).collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
||||
}
|
||||
|
||||
private String computeModLauncherServiceList() {
|
||||
final List<Map<String, String>> mods = FMLLoader.modLauncherModList();
|
||||
return "\n"+mods.stream().map(mod->mod.getOrDefault("file","nofile")+
|
||||
" "+mod.getOrDefault("name", "missing")+
|
||||
" "+mod.getOrDefault("type","NOTYPE")+
|
||||
" "+mod.getOrDefault("description", "")).
|
||||
collect(Collectors.joining("\n\t\t","\t\t",""));
|
||||
}
|
||||
|
||||
public static ModLoader get()
|
||||
|
|
Loading…
Reference in a new issue