mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +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
@@ -19,6 +19,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -69,6 +70,7 @@ import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.storage.SaveFormatComparator;
|
||||
import net.minecraft.world.storage.SaveFormatOld;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.DummyModContainer;
|
||||
import net.minecraftforge.fml.common.DuplicateModsFoundException;
|
||||
@@ -76,6 +78,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLContainerHolder;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.IFMLSidedHandler;
|
||||
import net.minecraftforge.fml.common.Java8VersionException;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderException;
|
||||
import net.minecraftforge.fml.common.MetadataCollection;
|
||||
@@ -158,6 +161,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
private boolean loading = true;
|
||||
|
||||
private Java8VersionException j8onlymods;
|
||||
|
||||
private WrongMinecraftVersionException wrongMC;
|
||||
|
||||
private CustomModLoadingErrorDisplayException customError;
|
||||
@@ -212,6 +217,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
dupesFound = dupes;
|
||||
}
|
||||
catch (Java8VersionException j8mods)
|
||||
{
|
||||
j8onlymods = j8mods;
|
||||
}
|
||||
catch (MissingModsException missing)
|
||||
{
|
||||
modsMissing = missing;
|
||||
@@ -297,7 +306,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
*/
|
||||
public void finishMinecraftLoading()
|
||||
{
|
||||
if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null)
|
||||
if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null || j8onlymods!=null)
|
||||
{
|
||||
SplashProgress.finish();
|
||||
return;
|
||||
@@ -344,6 +353,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
}
|
||||
loading = false;
|
||||
client.gameSettings.loadOptions(); //Reload options to load any mod added keybindings.
|
||||
Loader.instance().loadingComplete();
|
||||
SplashProgress.finish();
|
||||
}
|
||||
|
||||
public void extendModList()
|
||||
@@ -383,6 +394,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
showGuiScreen(new GuiWrongMinecraft(wrongMC));
|
||||
}
|
||||
else if (j8onlymods != null)
|
||||
{
|
||||
showGuiScreen(new GuiJava8Error(j8onlymods));
|
||||
}
|
||||
else if (modsMissing != null)
|
||||
{
|
||||
showGuiScreen(new GuiModsMissing(modsMissing));
|
||||
@@ -401,10 +416,16 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
Loader.instance().loadingComplete();
|
||||
SplashProgress.finish();
|
||||
logMissingTextureErrors();
|
||||
if (!Loader.instance().java8)
|
||||
{
|
||||
if ((new Date()).getTime() >= ForgeModContainer.java8Reminder + (1000 * 60 * 60 * 24))
|
||||
{
|
||||
showGuiScreen(new GuiJava8Error(new Java8VersionException(Collections.<ModContainer>emptyList())));
|
||||
ForgeModContainer.updateNag();
|
||||
}
|
||||
}
|
||||
}
|
||||
logMissingTextureErrors();
|
||||
}
|
||||
/**
|
||||
* Get the server instance
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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.client;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Java8VersionException;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiJava8Error extends GuiErrorScreen
|
||||
{
|
||||
private Java8VersionException java8VersionException;
|
||||
public GuiJava8Error(Java8VersionException java8VersionException)
|
||||
{
|
||||
super(null,null);
|
||||
this.java8VersionException = java8VersionException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(new GuiButton(1, 50, this.height - 38, this.width/2 -55, 20, I18n.format("fml.button.visitjavadownloads")));
|
||||
if (java8VersionException.getMods().isEmpty())
|
||||
{
|
||||
this.buttonList.add(new GuiButton(3, this.width / 2 + 5, this.height - 38, this.width / 2 - 55, 20, I18n.format("fml.button.continue")));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height - 38, this.width / 2 - 55, 20, I18n.format("menu.quit")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException
|
||||
{
|
||||
if (button.id == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
Desktop.getDesktop().browse(new URI("http://www.oracle.com/technetwork/java/javase/downloads/index.html"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.ERROR, e, "Problem launching browser");
|
||||
}
|
||||
}
|
||||
else if (button.id == 2)
|
||||
{
|
||||
FMLCommonHandler.instance().exitJava(1,true);
|
||||
}
|
||||
else if (button.id == 3)
|
||||
{
|
||||
FMLClientHandler.instance().showGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
int offset = 25;
|
||||
if (!java8VersionException.getMods().isEmpty())
|
||||
{
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.java8problem", TextFormatting.RED, TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.java8recommended", TextFormatting.RED, TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF);
|
||||
}
|
||||
offset+=15;
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.javaversion", System.getProperty("java.version").split("\\.")[1], System.getProperty("java.version")), this.width / 2, offset, 0xFFFFFF);
|
||||
offset += 10;
|
||||
if (!java8VersionException.getMods().isEmpty())
|
||||
{
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.upgradejavaorremove", TextFormatting.RED,TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF);
|
||||
offset += 15;
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.modslistedbelow", I18n.format("fml.messages.requirejava8")), this.width / 2, offset, 0xFFFFFF);
|
||||
offset += 10;
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.countbadandgood", java8VersionException.getMods().size(), Loader.instance().getActiveModList().size()), this.width / 2, offset, 0xFFFFFF);
|
||||
offset += 5;
|
||||
for (ModContainer mc : java8VersionException.getMods())
|
||||
{
|
||||
offset += 10;
|
||||
this.drawCenteredString(this.fontRendererObj, String.format("%s (%s)", mc.getName(), mc.getModId()), this.width / 2, offset, 0xEEEEEE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String text = I18n.format("fml.messages.upgradejava", TextFormatting.RED,TextFormatting.BOLD, TextFormatting.RESET).replaceAll("\\\\n", "\n");
|
||||
List<String> lines = Lists.newArrayList();
|
||||
for (String line : text.split("\n"))
|
||||
{
|
||||
lines.addAll(this.fontRendererObj.listFormattedStringToWidth(line, this.width - this.fontRendererObj.FONT_HEIGHT * 4));
|
||||
}
|
||||
|
||||
int maxWidth = 0;
|
||||
for (String line : lines)
|
||||
{
|
||||
maxWidth = Math.max(maxWidth, this.fontRendererObj.getStringWidth(line));
|
||||
}
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
this.drawString(this.fontRendererObj, line, (this.width - maxWidth) / 2, offset, 0xFFFFFF);
|
||||
offset += this.fontRendererObj.FONT_HEIGHT + 2;
|
||||
}
|
||||
|
||||
offset += 15;
|
||||
}
|
||||
// super.super
|
||||
for (int i = 0; i < this.buttonList.size(); ++i)
|
||||
{
|
||||
((GuiButton)this.buttonList.get(i)).drawButton(this.mc, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user