From 3b78e97ad83c993fa1975ab79e9582f0d418274a Mon Sep 17 00:00:00 2001 From: cpw Date: Sun, 10 Jun 2018 21:36:50 -0400 Subject: [PATCH] =?UTF-8?q?Fidgeting=20while=20the=20world=20burns=20?= =?UTF-8?q?=F0=9F=94=A5=F0=9F=94=A5=F0=9F=94=A5=F0=9F=94=A5=F0=9F=94=A5?= =?UTF-8?q?=F0=9F=94=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fml/DefaultModContainers.java | 2 +- .../fml/client/SplashProgress.java | 1 - .../fml/common/ModContainer.java | 2 +- .../FMLJavaModLanguageProvider.java | 13 ++++---- .../fml/javafmlmod/FMLModContainer.java | 10 +++--- .../IModFileInfo.java | 2 +- .../moddiscovery => language}/IModInfo.java | 4 +-- .../IModLanguageProvider.java | 8 ++--- .../ModFileScanData.java} | 31 ++++++------------- .../loading/FMLDevClientLaunchProvider.java | 2 +- .../fml/loading/LanguageLoadingProvider.java | 1 + .../minecraftforge/fml/loading/ModList.java | 2 -- .../minecraftforge/fml/loading/ModSorter.java | 3 +- .../moddiscovery/BackgroundScanHandler.java | 7 ++--- .../moddiscovery/InvalidModFileException.java | 2 ++ .../loading/moddiscovery/ModAnnotation.java | 5 +++ .../loading/moddiscovery/ModClassVisitor.java | 10 +++--- .../fml/loading/moddiscovery/ModFile.java | 21 +++++++------ .../fml/loading/moddiscovery/ModFileInfo.java | 2 ++ .../loading/moddiscovery/ModFileParser.java | 1 + .../fml/loading/moddiscovery/ModInfo.java | 5 +-- .../fml/loading/moddiscovery/Scanner.java | 15 +++------ ...ftforge.fml.language.IModLanguageProvider} | 0 .../minecraftforge/fml/test/ModsTomlTest.java | 2 +- 24 files changed, 72 insertions(+), 79 deletions(-) rename src/main/java/net/minecraftforge/fml/{loading/moddiscovery => language}/IModFileInfo.java (95%) rename src/main/java/net/minecraftforge/fml/{loading/moddiscovery => language}/IModInfo.java (95%) rename src/main/java/net/minecraftforge/fml/{loading => language}/IModLanguageProvider.java (83%) rename src/main/java/net/minecraftforge/fml/{loading/moddiscovery/ScanResult.java => language/ModFileScanData.java} (73%) rename src/main/resources/META-INF/services/{net.minecraftforge.fml.loading.IModLanguageProvider => net.minecraftforge.fml.language.IModLanguageProvider} (100%) diff --git a/src/main/java/net/minecraftforge/fml/DefaultModContainers.java b/src/main/java/net/minecraftforge/fml/DefaultModContainers.java index df08d1926..b1a17b9c2 100644 --- a/src/main/java/net/minecraftforge/fml/DefaultModContainers.java +++ b/src/main/java/net/minecraftforge/fml/DefaultModContainers.java @@ -21,7 +21,7 @@ package net.minecraftforge.fml; import com.electronwill.nightconfig.core.path.PathConfig; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.loading.moddiscovery.IModInfo; +import net.minecraftforge.fml.language.IModInfo; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import java.net.URISyntaxException; diff --git a/src/main/java/net/minecraftforge/fml/client/SplashProgress.java b/src/main/java/net/minecraftforge/fml/client/SplashProgress.java index 891949606..f70a4e64e 100644 --- a/src/main/java/net/minecraftforge/fml/client/SplashProgress.java +++ b/src/main/java/net/minecraftforge/fml/client/SplashProgress.java @@ -60,7 +60,6 @@ import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourcePack; import net.minecraft.client.resources.SimpleResource; import net.minecraft.crash.CrashReport; -import net.minecraft.launchwrapper.Launch; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.CrashReportExtender; import net.minecraftforge.fml.common.EnhancedRuntimeException; diff --git a/src/main/java/net/minecraftforge/fml/common/ModContainer.java b/src/main/java/net/minecraftforge/fml/common/ModContainer.java index 3a4cc7b1c..f31c1ad7b 100644 --- a/src/main/java/net/minecraftforge/fml/common/ModContainer.java +++ b/src/main/java/net/minecraftforge/fml/common/ModContainer.java @@ -21,7 +21,7 @@ package net.minecraftforge.fml.common; import net.minecraftforge.fml.LifecycleEventProvider; import net.minecraftforge.fml.ModLoadingStage; -import net.minecraftforge.fml.loading.moddiscovery.IModInfo; +import net.minecraftforge.fml.language.IModInfo; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java index 8c2ce158c..749651cb3 100644 --- a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java +++ b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java @@ -19,11 +19,10 @@ package net.minecraftforge.fml.javafmlmod; -import net.minecraftforge.fml.javafmlmod.FMLModContainer; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.loading.IModLanguageProvider; -import net.minecraftforge.fml.loading.moddiscovery.IModInfo; -import net.minecraftforge.fml.loading.moddiscovery.ScanResult; +import net.minecraftforge.fml.language.IModLanguageProvider; +import net.minecraftforge.fml.language.IModInfo; +import net.minecraftforge.fml.language.ModFileScanData; import org.objectweb.asm.Type; import java.util.Map; @@ -52,9 +51,9 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider } @Override - public ModContainer loadMod(final IModInfo info, final ClassLoader modClassLoader, final ScanResult scanResults) + public ModContainer loadMod(final IModInfo info, final ClassLoader modClassLoader, final ModFileScanData modFileScanResults) { - return new FMLModContainer(info, className, modClassLoader, scanResults); + return new FMLModContainer(info, className, modClassLoader, modFileScanResults); } } @@ -67,7 +66,7 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider } @Override - public Consumer getFileVisitor() { + public Consumer getFileVisitor() { return scanResult -> { final Map modTargetMap = scanResult.getAnnotations().stream() .filter(ad -> ad.getAnnotationType().equals(MODANNOTATION)) diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java index bb2f19c13..7a24b55a4 100644 --- a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java +++ b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java @@ -27,8 +27,8 @@ import net.minecraftforge.fml.ModLoadingStage; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.fml.loading.moddiscovery.IModInfo; -import net.minecraftforge.fml.loading.moddiscovery.ScanResult; +import net.minecraftforge.fml.language.IModInfo; +import net.minecraftforge.fml.language.ModFileScanData; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -43,14 +43,14 @@ import static net.minecraftforge.fml.Logging.LOADING; public class FMLModContainer extends ModContainer { private static final Logger LOGGER = LogManager.getLogger("FML"); - private final ScanResult scanResults; + private final ModFileScanData scanResults; private Object modInstance; private final Class modClass; - public FMLModContainer(IModInfo info, String className, ClassLoader modClassLoader, ScanResult scanResults) + public FMLModContainer(IModInfo info, String className, ClassLoader modClassLoader, ModFileScanData modFileScanResults) { super(info); - this.scanResults = scanResults; + this.scanResults = modFileScanResults; triggerMap.put(ModLoadingStage.BEGIN, this::constructMod); triggerMap.put(ModLoadingStage.PREINIT, this::preinitMod); diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModFileInfo.java b/src/main/java/net/minecraftforge/fml/language/IModFileInfo.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModFileInfo.java rename to src/main/java/net/minecraftforge/fml/language/IModFileInfo.java index 86462683b..67e26c000 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModFileInfo.java +++ b/src/main/java/net/minecraftforge/fml/language/IModFileInfo.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.loading.moddiscovery; +package net.minecraftforge.fml.language; import com.electronwill.nightconfig.core.UnmodifiableConfig; import net.minecraftforge.fml.common.versioning.VersionRange; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModInfo.java b/src/main/java/net/minecraftforge/fml/language/IModInfo.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModInfo.java rename to src/main/java/net/minecraftforge/fml/language/IModInfo.java index b33d2d147..55acc70de 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModInfo.java +++ b/src/main/java/net/minecraftforge/fml/language/IModInfo.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.loading.moddiscovery; +package net.minecraftforge.fml.language; import com.electronwill.nightconfig.core.UnmodifiableConfig; import net.minecraftforge.fml.common.versioning.ArtifactVersion; @@ -61,7 +61,7 @@ public interface IModInfo private final Ordering ordering; private final DependencySide side; - ModVersion(final IModInfo owner, final UnmodifiableConfig config) { + public ModVersion(final IModInfo owner, final UnmodifiableConfig config) { this.owner = owner; this.modId = config.get("modId"); this.versionRange = config.getOptional("versionRange").map(String.class::cast). diff --git a/src/main/java/net/minecraftforge/fml/loading/IModLanguageProvider.java b/src/main/java/net/minecraftforge/fml/language/IModLanguageProvider.java similarity index 83% rename from src/main/java/net/minecraftforge/fml/loading/IModLanguageProvider.java rename to src/main/java/net/minecraftforge/fml/language/IModLanguageProvider.java index a749457a1..ab3ea9d50 100644 --- a/src/main/java/net/minecraftforge/fml/loading/IModLanguageProvider.java +++ b/src/main/java/net/minecraftforge/fml/language/IModLanguageProvider.java @@ -17,11 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.loading; +package net.minecraftforge.fml.language; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.loading.moddiscovery.IModInfo; -import net.minecraftforge.fml.loading.moddiscovery.ScanResult; import java.util.function.Consumer; @@ -35,9 +33,9 @@ public interface IModLanguageProvider { String name(); - Consumer getFileVisitor(); + Consumer getFileVisitor(); interface IModLanguageLoader { - ModContainer loadMod(IModInfo info, ClassLoader modClassLoader, ScanResult scanResults); + ModContainer loadMod(IModInfo info, ClassLoader modClassLoader, ModFileScanData modFileScanResults); } } diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ScanResult.java b/src/main/java/net/minecraftforge/fml/language/ModFileScanData.java similarity index 73% rename from src/main/java/net/minecraftforge/fml/loading/moddiscovery/ScanResult.java rename to src/main/java/net/minecraftforge/fml/language/ModFileScanData.java index de00acddd..b1b457853 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ScanResult.java +++ b/src/main/java/net/minecraftforge/fml/language/ModFileScanData.java @@ -17,40 +17,32 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.loading.moddiscovery; +package net.minecraftforge.fml.language; -import net.minecraftforge.fml.loading.IModLanguageProvider; import org.objectweb.asm.Type; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; -public class ScanResult { - private final ModFile file; - private final List annotations = new ArrayList<>(); - private final List classes = new ArrayList<>(); +public class ModFileScanData +{ + private final List annotations = new ArrayList<>(); + private final List classes = new ArrayList<>(); private Map modTargets; - public ScanResult(final ModFile file) { - this.file = file; + public static Predicate interestingAnnotations() { + return t->true; } - public ModFile getFile() { - return file; - } - - public static boolean interestingAnnotations(final ModAnnotation annotation) { - return true; - } - - public List getClasses() { + public List getClasses() { return classes; } - public List getAnnotations() { + public List getAnnotations() { return annotations; } @@ -105,8 +97,5 @@ public class ScanResult { public Map getAnnotationData() { return annotationData; } - public static ScanResult.AnnotationData fromModAnnotation(final Type clazz, final ModAnnotation annotation) { - return new AnnotationData(annotation.asmType, clazz, annotation.member, annotation.values); - } } } diff --git a/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java b/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java index ece30994d..ca869425c 100644 --- a/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java +++ b/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java @@ -44,7 +44,7 @@ public class FMLDevClientLaunchProvider extends FMLCommonLaunchHandler implement private static final List SKIPPACKAGES = Arrays.asList( "joptsimple.", "org.lwjgl.", "com.mojang.", "com.google.", - "org.apache.commons.", "io.netty.", "net.minecraftforge.fml.loading.", + "org.apache.commons.", "io.netty.", "net.minecraftforge.fml.loading.", "net.minecraftforge.fml.language.", "net.minecraftforge.eventbus.", "it.unimi.dsi.fastutil.", "net.minecraftforge.api.", "paulscode.sound.", "com.ibm.icu.", "sun.", "gnu.trove.", "com.electronwill.nightconfig." ); diff --git a/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java b/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java index 683d600f7..652a1878f 100644 --- a/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java +++ b/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java @@ -23,6 +23,7 @@ import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.fml.common.versioning.ArtifactVersion; import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; import net.minecraftforge.fml.common.versioning.VersionRange; +import net.minecraftforge.fml.language.IModLanguageProvider; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import java.nio.file.Path; diff --git a/src/main/java/net/minecraftforge/fml/loading/ModList.java b/src/main/java/net/minecraftforge/fml/loading/ModList.java index bd3b363d8..acc875365 100644 --- a/src/main/java/net/minecraftforge/fml/loading/ModList.java +++ b/src/main/java/net/minecraftforge/fml/loading/ModList.java @@ -23,8 +23,6 @@ import net.minecraftforge.fml.LifecycleEventProvider; import net.minecraftforge.fml.ModLoadingStage; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler; -import net.minecraftforge.fml.loading.moddiscovery.IModFileInfo; -import net.minecraftforge.fml.loading.moddiscovery.IModInfo; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; diff --git a/src/main/java/net/minecraftforge/fml/loading/ModSorter.java b/src/main/java/net/minecraftforge/fml/loading/ModSorter.java index 643cf674d..69064cb71 100644 --- a/src/main/java/net/minecraftforge/fml/loading/ModSorter.java +++ b/src/main/java/net/minecraftforge/fml/loading/ModSorter.java @@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.DuplicateModsFoundException; import net.minecraftforge.fml.common.MissingModsException; import net.minecraftforge.fml.common.toposort.TopologicalSort; import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.loading.moddiscovery.IModInfo; +import net.minecraftforge.fml.language.IModInfo; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import org.apache.logging.log4j.LogManager; @@ -35,7 +35,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; -import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java index fff8444b9..82c51fcc4 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java @@ -19,7 +19,7 @@ package net.minecraftforge.fml.loading.moddiscovery; -import com.google.common.util.concurrent.MoreExecutors; +import net.minecraftforge.fml.language.ModFileScanData; import net.minecraftforge.fml.loading.ModList; import java.util.ArrayList; @@ -27,7 +27,6 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import static net.minecraftforge.fml.Logging.SCAN; @@ -58,13 +57,13 @@ public class BackgroundScanHandler } allFiles.add(file); pendingFiles.add(file); - final CompletableFuture future = CompletableFuture.supplyAsync(file::compileContent, modContentScanner) + final CompletableFuture future = CompletableFuture.supplyAsync(file::compileContent, modContentScanner) .whenComplete(file::setScanResult) .whenComplete((r,t)-> this.addCompletedFile(file,r,t)); file.setFutureScanResult(future); } - private void addCompletedFile(final ModFile file, final ScanResult scanResult, final Throwable throwable) { + private void addCompletedFile(final ModFile file, final ModFileScanData modFileScanData, final Throwable throwable) { if (throwable != null) { fmlLog.error(SCAN,"An error occurred scanning file {}", file, throwable); } diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java index a0581c728..3e15f7727 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java @@ -19,6 +19,8 @@ package net.minecraftforge.fml.loading.moddiscovery; +import net.minecraftforge.fml.language.IModFileInfo; + public class InvalidModFileException extends RuntimeException { private final IModFileInfo modFileInfo; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java index 8fa21037a..bdd54efb0 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModAnnotation.java @@ -23,6 +23,7 @@ import java.lang.annotation.ElementType; import java.util.ArrayList; import java.util.Map; +import net.minecraftforge.fml.language.ModFileScanData; import org.objectweb.asm.Type; import com.google.common.base.MoreObjects; @@ -31,6 +32,10 @@ import com.google.common.collect.Maps; public class ModAnnotation { + public static ModFileScanData.AnnotationData fromModAnnotation(final Type clazz, final ModAnnotation annotation) { + return new ModFileScanData.AnnotationData(annotation.asmType, clazz, annotation.member, annotation.values); + } + public static class EnumHolder { private final String desc; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java index f86263e2f..8e7065fe0 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModClassVisitor.java @@ -19,6 +19,7 @@ package net.minecraftforge.fml.loading.moddiscovery; +import net.minecraftforge.fml.language.ModFileScanData; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; @@ -74,10 +75,11 @@ public class ModClassVisitor extends ClassVisitor return new ModMethodVisitor(name, desc, annotations); } - public void buildData(final List classes, final List annotations) { - classes.add(new ScanResult.ClassData(this.asmType, this.asmSuperType, this.interfaces)); - final List collect = this.annotations.stream().filter(ScanResult::interestingAnnotations). - map(a -> ScanResult.AnnotationData.fromModAnnotation(this.asmType, a)).collect(Collectors.toList()); + public void buildData(final List classes, final List annotations) { + classes.add(new ModFileScanData.ClassData(this.asmType, this.asmSuperType, this.interfaces)); + final List collect = this.annotations.stream(). + filter(ma->ModFileScanData.interestingAnnotations().test(ma.asmType)). + map(a -> ModAnnotation.fromModAnnotation(this.asmType, a)).collect(Collectors.toList()); annotations.addAll(collect); } diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java index 8bae29334..d36387e21 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java @@ -21,8 +21,11 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.google.common.collect.ImmutableMap; import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.language.IModFileInfo; +import net.minecraftforge.fml.language.IModInfo; +import net.minecraftforge.fml.language.ModFileScanData; import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.fml.loading.IModLanguageProvider; +import net.minecraftforge.fml.language.IModLanguageProvider; import net.minecraftforge.fml.loading.ModLoadingClassLoader; import java.nio.file.Files; @@ -86,8 +89,8 @@ public class ModFile private final IModLocator locator; private IModFileInfo modFileInfo; private Map modInfoMap; - private ScanResult fileScanResult; - private CompletableFuture futureScanResult; + private ModFileScanData fileModFileScanData; + private CompletableFuture futureScanResult; private List coreMods; private Path accessTransformer; @@ -142,19 +145,19 @@ public class ModFile /** * Run in an executor thread to harvest the class and annotation list */ - public ScanResult compileContent() { + public ModFileScanData compileContent() { return new Scanner(this).scan(); } public void scanFile(Consumer pathConsumer) { locator.scanFile(this, pathConsumer); } - public void setFutureScanResult(CompletableFuture future) + public void setFutureScanResult(CompletableFuture future) { this.futureScanResult = future; } - public ScanResult getScanResult() { + public ModFileScanData getScanResult() { if (this.futureScanResult != null) { try { this.futureScanResult.get(); @@ -162,12 +165,12 @@ public class ModFile e.printStackTrace(); } } - return this.fileScanResult; + return this.fileModFileScanData; } - public void setScanResult(final ScanResult scanResult, final Throwable throwable) { + public void setScanResult(final ModFileScanData modFileScanData, final Throwable throwable) { this.futureScanResult = null; - this.fileScanResult = scanResult; + this.fileModFileScanData = modFileScanData; } @Override diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java index 6148b676d..ca3011a9b 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java @@ -21,6 +21,8 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.electronwill.nightconfig.core.UnmodifiableConfig; import net.minecraftforge.fml.common.versioning.VersionRange; +import net.minecraftforge.fml.language.IModFileInfo; +import net.minecraftforge.fml.language.IModInfo; import net.minecraftforge.fml.loading.StringUtils; import java.net.URL; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java index 37847ca18..ff7296722 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java @@ -22,6 +22,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.electronwill.nightconfig.core.path.PathConfig; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import net.minecraftforge.fml.language.IModFileInfo; import java.io.IOException; import java.lang.reflect.Type; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java index 723c838ee..79f00f813 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java @@ -20,10 +20,10 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.electronwill.nightconfig.core.UnmodifiableConfig; +import net.minecraftforge.fml.language.IModInfo; import net.minecraftforge.fml.loading.StringSubstitutor; import net.minecraftforge.fml.common.versioning.ArtifactVersion; import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; -import net.minecraftforge.fml.common.versioning.VersionRange; import java.util.Arrays; import java.util.Collections; @@ -31,7 +31,8 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -public class ModInfo implements IModInfo { +public class ModInfo implements IModInfo +{ private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1"); private final ModFileInfo owningFile; private final String modId; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java index 7001cb2b2..3230bbc0e 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java @@ -19,19 +19,14 @@ package net.minecraftforge.fml.loading.moddiscovery; -import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.fml.loading.IModLanguageProvider; -import net.minecraftforge.fml.loading.LanguageLoadingProvider; +import net.minecraftforge.fml.language.IModLanguageProvider; +import net.minecraftforge.fml.language.ModFileScanData; import org.objectweb.asm.ClassReader; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Set; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import static net.minecraftforge.fml.Logging.LOADING; import static net.minecraftforge.fml.Logging.SCAN; import static net.minecraftforge.fml.Logging.fmlLog; @@ -42,8 +37,8 @@ public class Scanner { this.fileToScan = fileToScan; } - public ScanResult scan() { - ScanResult result = new ScanResult(fileToScan); + public ModFileScanData scan() { + ModFileScanData result = new ModFileScanData(); fileToScan.scanFile(p -> fileVisitor(p, result)); final IModLanguageProvider loader = fileToScan.getLoader(); fmlLog.debug(SCAN, "Scanning {} with language loader {}", fileToScan.getFilePath(), loader.name()); @@ -51,7 +46,7 @@ public class Scanner { return result; } - private void fileVisitor(final Path path, final ScanResult result) { + private void fileVisitor(final Path path, final ModFileScanData result) { try { fmlLog.debug(SCAN,"Scanning {} path {}", fileToScan, path); ModClassVisitor mcv = new ModClassVisitor(); diff --git a/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.IModLanguageProvider b/src/main/resources/META-INF/services/net.minecraftforge.fml.language.IModLanguageProvider similarity index 100% rename from src/main/resources/META-INF/services/net.minecraftforge.fml.loading.IModLanguageProvider rename to src/main/resources/META-INF/services/net.minecraftforge.fml.language.IModLanguageProvider diff --git a/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java b/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java index ae6436e1e..48c47c548 100644 --- a/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java +++ b/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java @@ -1,6 +1,6 @@ package net.minecraftforge.fml.test; -import net.minecraftforge.fml.loading.moddiscovery.IModFileInfo; +import net.minecraftforge.fml.language.IModFileInfo; import net.minecraftforge.fml.loading.moddiscovery.ModFileParser; import org.junit.Test;