Fix problem with duplicate mods caused by duplicate classes found during scan.

File Scan results are now sets.

Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
cpw 2019-02-27 23:34:23 -05:00
parent dd7e7fc122
commit 7f1ea578d6
No known key found for this signature in database
GPG key ID: 8EB3DF749553B1B7
4 changed files with 10 additions and 3 deletions

View file

@ -291,7 +291,7 @@ project(':forge') {
installer 'cpw.mods:modlauncher:0.11.+' installer 'cpw.mods:modlauncher:0.11.+'
installer 'net.minecraftforge:accesstransformers:0.15.+:shadowed' installer 'net.minecraftforge:accesstransformers:0.15.+:shadowed'
installer 'net.minecraftforge:eventbus:0.8.+:service' installer 'net.minecraftforge:eventbus:0.8.+:service'
installer 'net.minecraftforge:forgespi:0.8.+' installer 'net.minecraftforge:forgespi:0.10.+'
installer 'net.minecraftforge:coremods:0.4.+' installer 'net.minecraftforge:coremods:0.4.+'
installer 'net.minecraftforge:unsafe:0.2.+' installer 'net.minecraftforge:unsafe:0.2.+'
installer 'com.electronwill.night-config:core:3.4.2' installer 'com.electronwill.night-config:core:3.4.2'

View file

@ -75,7 +75,7 @@ public class ModClassVisitor extends ClassVisitor
return new ModMethodVisitor(name, desc, annotations); return new ModMethodVisitor(name, desc, annotations);
} }
public void buildData(final List<ModFileScanData.ClassData> classes, final List<ModFileScanData.AnnotationData> annotations) { public void buildData(final Set<ModFileScanData.ClassData> classes, final Set<ModFileScanData.AnnotationData> annotations) {
classes.add(new ModFileScanData.ClassData(this.asmType, this.asmSuperType, this.interfaces)); classes.add(new ModFileScanData.ClassData(this.asmType, this.asmSuperType, this.interfaces));
final List<ModFileScanData.AnnotationData> collect = this.annotations.stream(). final List<ModFileScanData.AnnotationData> collect = this.annotations.stream().
filter(ma->ModFileScanData.interestingAnnotations().test(ma.asmType)). filter(ma->ModFileScanData.interestingAnnotations().test(ma.asmType)).

View file

@ -57,6 +57,7 @@ public class ModFile
private final String jarVersion; private final String jarVersion;
private Map<String, Object> fileProperties; private Map<String, Object> fileProperties;
private IModLanguageProvider loader; private IModLanguageProvider loader;
private Throwable scanError;
public void setFileProperties(Map<String, Object> fileProperties) public void setFileProperties(Map<String, Object> fileProperties)
{ {
@ -159,12 +160,18 @@ public class ModFile
e.printStackTrace(); e.printStackTrace();
} }
} }
if (this.scanError != null) {
throw new RuntimeException(this.scanError);
}
return this.fileModFileScanData; return this.fileModFileScanData;
} }
public void setScanResult(final ModFileScanData modFileScanData, final Throwable throwable) { public void setScanResult(final ModFileScanData modFileScanData, final Throwable throwable) {
this.futureScanResult = null; this.futureScanResult = null;
this.fileModFileScanData = modFileScanData; this.fileModFileScanData = modFileScanData;
if (throwable != null) {
this.scanError = throwable;
}
} }
@Override @Override

View file

@ -95,7 +95,7 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider
.filter(ad -> ad.getAnnotationType().equals(MODANNOTATION)) .filter(ad -> ad.getAnnotationType().equals(MODANNOTATION))
.peek(ad -> LOGGER.debug(SCAN, "Found @Mod class {} with id {}", ad.getClassType().getClassName(), ad.getAnnotationData().get("value"))) .peek(ad -> LOGGER.debug(SCAN, "Found @Mod class {} with id {}", ad.getClassType().getClassName(), ad.getAnnotationData().get("value")))
.map(ad -> new FMLModTarget(ad.getClassType().getClassName(), (String)ad.getAnnotationData().get("value"))) .map(ad -> new FMLModTarget(ad.getClassType().getClassName(), (String)ad.getAnnotationData().get("value")))
.collect(Collectors.toMap(FMLModTarget::getModId, Function.identity())); .collect(Collectors.toMap(FMLModTarget::getModId, Function.identity(), (a,b)->a));
scanResult.addLanguageLoader(modTargetMap); scanResult.addLanguageLoader(modTargetMap);
}; };
} }