mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 04:32:15 +00:00
Add a java version detection and nag system for users on Java 7 or below.
Added detection of mods that rely on Java 8 and a graceful error screen. The nag screen will be shown once a day. It can be disabled by editing the forge.cfg. However it is HIGHLY recomended that user update to Java 8.
This commit is contained in:
1 parent
4d27393c91
commit
d8249b7886
15 files changed
+416
-18
No files matched your search
@@ -32,6 +32,7 @@ public class DummyModContainer implements ModContainer
|
||||
private ModMetadata md;
|
||||
private ArtifactVersion processedVersion;
|
||||
private String label;
|
||||
private int classVersion;
|
||||
|
||||
public DummyModContainer(ModMetadata md)
|
||||
{
|
||||
@@ -213,4 +214,16 @@ public class DummyModContainer implements ModContainer
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassVersion(int classVersion)
|
||||
{
|
||||
this.classVersion = classVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClassVersion()
|
||||
{
|
||||
return this.classVersion;
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ public class FMLModContainer implements ModContainer
|
||||
private Map<String, String> customModProperties;
|
||||
private ModCandidate candidate;
|
||||
private URL updateJSONUrl;
|
||||
private int classVersion;
|
||||
|
||||
public FMLModContainer(String className, ModCandidate container, Map<String, Object> modDescriptor)
|
||||
{
|
||||
@@ -699,4 +700,16 @@ public class FMLModContainer implements ModContainer
|
||||
{
|
||||
return updateJSONUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassVersion(int classVersion)
|
||||
{
|
||||
this.classVersion = classVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClassVersion()
|
||||
{
|
||||
return this.classVersion;
|
||||
}
|
||||
}
|
||||
@@ -214,4 +214,16 @@ public class InjectedModContainer implements ModContainer
|
||||
{
|
||||
return wrappedContainer.getUpdateUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassVersion(int classVersion)
|
||||
{
|
||||
wrappedContainer.setClassVersion(classVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClassVersion()
|
||||
{
|
||||
return wrappedContainer.getClassVersion();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Java8VersionException extends EnhancedRuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final List<ModContainer> mods;
|
||||
|
||||
public Java8VersionException(List<ModContainer> mods)
|
||||
{
|
||||
super("Mods require Java 8");
|
||||
this.mods = mods;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void printStackTrace(WrappedPrintStream stream)
|
||||
{
|
||||
stream.println("Mods requiring Java 8:");
|
||||
for (ModContainer mc : mods)
|
||||
{
|
||||
stream.println(String.format("\t%s : %s", mc.getName(), mc.getModId()));
|
||||
}
|
||||
stream.println("");
|
||||
}
|
||||
|
||||
public List<ModContainer> getMods()
|
||||
{
|
||||
return mods;
|
||||
}
|
||||
}
|
||||
@@ -161,6 +161,7 @@ public class Loader
|
||||
private File forcedModFile;
|
||||
private ModDiscoverer discoverer;
|
||||
private ProgressBar progressBar;
|
||||
public final boolean java8;
|
||||
|
||||
public static Loader instance()
|
||||
{
|
||||
@@ -187,6 +188,14 @@ public class Loader
|
||||
|
||||
private Loader()
|
||||
{
|
||||
String[] ver = System.getProperty("java.version").split("\\.");
|
||||
int major = Integer.parseInt(ver[1]);
|
||||
java8 = major > 7;
|
||||
if (!java8)
|
||||
{
|
||||
FMLLog.severe("The game is not running with Java 8. Forge recommends Java 8 for maximum compatibility with mods");
|
||||
}
|
||||
|
||||
modClassLoader = new ModClassLoader(getClass().getClassLoader());
|
||||
if (!mccversion.equals(MC_VERSION))
|
||||
{
|
||||
@@ -489,6 +498,7 @@ public class Loader
|
||||
ModAPIManager.INSTANCE.manageAPI(modClassLoader, discoverer);
|
||||
disableRequestedMods();
|
||||
modController.distributeStateMessage(FMLLoadEvent.class);
|
||||
checkJavaCompatibility();
|
||||
sortModList();
|
||||
ModAPIManager.INSTANCE.cleanupAPIContainers(modController.getActiveModList());
|
||||
ModAPIManager.INSTANCE.cleanupAPIContainers(mods);
|
||||
@@ -543,6 +553,24 @@ public class Loader
|
||||
modController.transition(LoaderState.PREINITIALIZATION, false);
|
||||
}
|
||||
|
||||
|
||||
private void checkJavaCompatibility()
|
||||
{
|
||||
if (java8) return;
|
||||
List<ModContainer> j8mods = Lists.newArrayList();
|
||||
for (ModContainer mc : getActiveModList())
|
||||
{
|
||||
if (mc.getClassVersion() >= 52)
|
||||
{
|
||||
j8mods.add(mc);
|
||||
}
|
||||
}
|
||||
if (!j8mods.isEmpty())
|
||||
{
|
||||
throw new Java8VersionException(j8mods);
|
||||
}
|
||||
}
|
||||
|
||||
public void preinitializeMods()
|
||||
{
|
||||
if (!modController.isInState(LoaderState.PREINITIALIZATION))
|
||||
|
||||
@@ -152,4 +152,8 @@ public interface ModContainer
|
||||
boolean shouldLoadInEnvironment();
|
||||
|
||||
URL getUpdateUrl();
|
||||
|
||||
void setClassVersion(int classVersion);
|
||||
|
||||
int getClassVersion();
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class ASMDataTable
|
||||
private String annotationName;
|
||||
private String className;
|
||||
private String objectName;
|
||||
private int classVersion;
|
||||
private Map<String,Object> annotationInfo;
|
||||
public ASMData(ModCandidate candidate, String annotationName, String className, String objectName, Map<String,Object> info)
|
||||
{
|
||||
|
||||
@@ -83,6 +83,7 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
table.addContainer(container);
|
||||
foundMods.add(container);
|
||||
container.bindMetadata(mc);
|
||||
container.setClassVersion(modParser.getClassVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user