1
0
mirror of https://github.com/chylex/Java-Checker.git synced 2025-06-11 04:34:03 +02:00

Add a version of Java Checker for shading

This commit is contained in:
chylex 2015-10-12 19:15:59 +02:00
parent 5bdd2d965d
commit abc0d3d959
2 changed files with 34 additions and 1 deletions
build.gradle
src/main/java/chylex/javacheck/report

View File

@ -44,11 +44,18 @@ task java8Jar(type: Jar, dependsOn: "jar"){
archiveName = "Java8Checker"+archiveSuffix
}
task shadeJar(type: Jar, dependsOn: "jar"){
from sourceSets.main.output
archiveName = "JavaCheckerShade"+archiveSuffix
}
jar.enabled = false
reobf{
reobf java7Jar{ classpath -> classpath = configurations.compile }
reobf java8Jar{ classpath -> classpath = configurations.compile }
reobf shadeJar{ classpath -> classpath = configurations.compile }
}
reobf.enabled = false

View File

@ -1,6 +1,7 @@
package chylex.javacheck.report;
import java.awt.Desktop;
import java.awt.Font;
import java.io.File;
import java.util.List;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@ -41,6 +42,19 @@ public final class JavaCheckerReporter{
JOptionPane.showMessageDialog(null,pane,"Outdated Java",JOptionPane.ERROR_MESSAGE);
throw new OutdatedJavaException();
}
else{
try{
Class cmm = findCoreModManager();
List coremods = (List)cmm.getMethod("getLoadedCoremods").invoke(null);
List reparsed = (List)cmm.getMethod("getReparseableCoremods").invoke(null);
String myFile = new File(JavaCheckerReporter.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getName();
coremods.remove(myFile);
reparsed.add(myFile);
}catch(Throwable t){
t.printStackTrace();
}
}
}
private static String getConsoleReport(JavaVersion minVersion){
@ -72,4 +86,16 @@ public final class JavaCheckerReporter{
return null;
}
private static Class findCoreModManager() throws Throwable{
try{
return Class.forName("cpw.mods.fml.relauncher.CoreModManager");
}catch(ClassNotFoundException e){}
try{
return Class.forName("net.minecraftforge.fml.relauncher.CoreModManager");
}catch(ClassNotFoundException e){}
return null;
}
}