mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29: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
@@ -14,6 +14,7 @@ import java.net.URL;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -74,6 +75,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
public static boolean defaultHasSpawnFuzz = true;
|
||||
public static boolean forgeLightPipelineEnabled = true;
|
||||
public static boolean replaceVanillaBucketModel = true;
|
||||
public static long java8Reminder = 0;
|
||||
|
||||
private static Configuration config;
|
||||
private static ForgeModContainer INSTANCE;
|
||||
@@ -259,6 +261,11 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
replaceVanillaBucketModel = prop.getBoolean(Boolean.FALSE);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", java8Reminder,
|
||||
"The timestamp of the last reminder to update to Java 8 in number of milliseconds since January 1, 1970, 00:00:00 GMT. Nag will show only once every 24 hours. To disable it set this to some really high number.");
|
||||
java8Reminder = prop.getLong(java8Reminder);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
config.setCategoryPropertyOrder(CATEGORY_CLIENT, propOrder);
|
||||
|
||||
if (config.hasChanged())
|
||||
@@ -267,6 +274,13 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateNag()
|
||||
{
|
||||
Property prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", java8Reminder);
|
||||
prop.set((new Date()).getTime());
|
||||
config.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* By subscribing to the OnConfigChangedEvent we are able to execute code when our config screens are closed.
|
||||
* This implementation uses the optional configID string to handle multiple Configurations using one event handler.
|
||||
|
||||
@@ -680,14 +680,7 @@ public class Property
|
||||
*/
|
||||
public int getInt()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return Integer.parseInt(defaultValue);
|
||||
}
|
||||
return getInt(Integer.parseInt(defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -727,6 +720,54 @@ public class Property
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value in this property as a long,
|
||||
* if the value is not a valid long, it will return the initially provided default.
|
||||
*
|
||||
* @return The value
|
||||
*/
|
||||
public long getLong()
|
||||
{
|
||||
return getLong(Long.parseLong(defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value in this property as a long,
|
||||
* if the value is not a valid long, it will return the
|
||||
* provided default.
|
||||
*
|
||||
* @param _default The default to provide if the current value is not a validlong
|
||||
* @return The value
|
||||
*/
|
||||
public long getLong(long _default)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Long.parseLong(value);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return _default;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current value stored in this property can be converted to a long.
|
||||
* @return True if the type of the Property is an Long
|
||||
*/
|
||||
public boolean isLongValue()
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(value);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value in this property as a boolean,
|
||||
* if the value is not a valid boolean, it will return the
|
||||
@@ -1148,6 +1189,7 @@ public class Property
|
||||
this.setValues(values);
|
||||
}
|
||||
public void set(int value){ set(Integer.toString(value)); }
|
||||
public void set(long value){ set(Long.toString(value)); }
|
||||
public void set(boolean value){ set(Boolean.toString(value)); }
|
||||
public void set(double value){ set(Double.toString(value)); }
|
||||
}
|
||||
Reference in new issue
Block a user