mirror of
https://github.com/chylex/Java-Checker.git
synced 2025-06-04 02:34:08 +02:00
Push Java7Checker
This commit is contained in:
parent
e1809605a1
commit
a698aabeff
69
build.gradle
Normal file
69
build.gradle
Normal file
@ -0,0 +1,69 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = ""
|
||||
group= "chylex.java7check" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "Java7Checker"
|
||||
|
||||
minecraft {
|
||||
version = "1.7.10-10.13.0.1184"
|
||||
assetDir = "eclipse/assets"
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'FMLCorePlugin': 'chylex.java7check.JavaCheckerCoremod'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// you may put jars on which you depend on in ./libs
|
||||
// or you may define them like so..
|
||||
//compile "some.group:artifact:version:classifier"
|
||||
//compile "some.group:artifact:version"
|
||||
|
||||
// real examples
|
||||
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||
|
||||
// for more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
}
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
28
src/main/java/chylex/java7check/JavaCheckerCoremod.java
Normal file
28
src/main/java/chylex/java7check/JavaCheckerCoremod.java
Normal file
@ -0,0 +1,28 @@
|
||||
package chylex.java7check;
|
||||
import java.util.Map;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
public class JavaCheckerCoremod implements IFMLLoadingPlugin{
|
||||
@Override
|
||||
public String[] getASMTransformerClass(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass(){
|
||||
return "chylex.java7check.report.JavaCheckerReporter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String,Object> data){}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package chylex.java7check.report;
|
||||
import java.util.Map;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.apache.commons.lang3.JavaVersion;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import cpw.mods.fml.relauncher.IFMLCallHook;
|
||||
|
||||
public final class JavaCheckerReporter implements IFMLCallHook{
|
||||
@Override
|
||||
public Void call() throws Exception{
|
||||
if (!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7)){
|
||||
FMLRelaunchLog.severe(getConsoleReport());
|
||||
JOptionPane.showMessageDialog(null, "<html>"+getWindowReport()+"</html>","Outdated Java",JOptionPane.ERROR_MESSAGE);
|
||||
throw new OutdatedJavaException();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String,Object> data){}
|
||||
|
||||
static String getConsoleReport(){
|
||||
return new StringBuilder(242).append("\n")
|
||||
.append("\n!! DO NOT REPORT !!\n\n")
|
||||
.append("One of the mods requires Java 1.7 or newer, you are using ").append(SystemUtils.JAVA_VERSION).append(".\n")
|
||||
.append("Visit https://java.com/download/ for the latest version.\n")
|
||||
.append("Please, uninstall the old version first to prevent further issues.")
|
||||
.append("\n\n!! DO NOT REPORT !!\n")
|
||||
.toString();
|
||||
}
|
||||
|
||||
static String getWindowReport(){
|
||||
return new StringBuilder(230)
|
||||
.append("One of the mods requires Java 1.7 or newer, you are using ").append(SystemUtils.JAVA_VERSION).append(".<br>")
|
||||
.append("Visit <span style=\"color:red\">https://java.com/download/</span> for the latest version.<br>")
|
||||
.append("Please, uninstall the old version first to prevent further issues.")
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package chylex.java7check.report;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class OutdatedJavaException extends RuntimeException{
|
||||
public OutdatedJavaException(){
|
||||
setStackTrace(new StackTraceElement[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackTraceElement[] getStackTrace(){
|
||||
return new StackTraceElement[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintStream s){}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintWriter w){}
|
||||
}
|
14
src/main/resources/mcmod.info
Normal file
14
src/main/resources/mcmod.info
Normal file
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"modid": "Java7Checker",
|
||||
"name": "Java 7 Checker",
|
||||
"description": "If you see this description inside Minecraft, then you're fine!",
|
||||
"version": "1.0",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
"authorList": ["chylex"],
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user