diff options
Diffstat (limited to 'src/Java')
-rw-r--r-- | src/Java/gtPlusPlus/GTplusplus.java | 6 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java | 4 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/lib/CORE.java | 4 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java | 2 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Utils.java | 8 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java | 68 |
6 files changed, 63 insertions, 29 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index bd79aeb764..4afbde44d2 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -33,7 +33,9 @@ import gtPlusPlus.core.item.general.RF2EU_Battery; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.gregtech.CustomGTMaterials; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.geo.GeoUtils; import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.networking.NetworkUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -197,6 +199,10 @@ public class GTplusplus implements ActionListener { public void preInit(final FMLPreInitializationEvent event) { Utils.LOG_INFO("Loading " + CORE.name + " V" + CORE.VERSION); + //HTTP Requests + CORE.MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); + CORE.USER_COUNTRY = GeoUtils.determineUsersCountry(); + // Handle GT++ Config handleConfigFile(event); diff --git a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java index b787acd02d..464b825177 100644 --- a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java @@ -39,8 +39,8 @@ public class LoginEventHandler { if (!this.localPlayerRef.worldObj.isRemote){ PlayerCache.appendParamChanges(this.localPlayersName, this.localPlayersUUID.toString()); - if (!CORE.isModUpToDate){ - Utils.LOG_INFO("You're not using the latest recommended version of GT++, consider updating."); + if (!Utils.isModUpToDate()){ + Utils.LOG_INFO("[GT++] You're not using the latest recommended version of GT++, consider updating."); if (!CORE.MASTER_VERSION.toLowerCase().equals("offline")) { Utils.LOG_INFO("Latest version is: "+CORE.MASTER_VERSION); } diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 6e4ee627a1..5d88740aac 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -33,8 +33,8 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; public static final String VERSION = "1.5.9-release"; - public static final String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); - public static final String USER_COUNTRY = GeoUtils.determineUsersCountry(); + public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); + public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); public static boolean DEBUG = false; public static final boolean LOAD_ALL_CONTENT = false; diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 97a5520bbb..b395cbac6f 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -894,7 +894,7 @@ public class RECIPES_Machines { ItemStack controlCircuit = ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR); RecipeUtils.addShapedGregtechRecipe( controlCircuit, "cableGt12NaquadahAlloy", controlCircuit, - "plateDoubleHastelloyN", ItemList.Cover_Screen.get(1), "plateDoubleHastelloyN", + "plateDoubleHastelloyN", GregtechItemList.Gregtech_Computer_Cube.get(1), "plateDoubleHastelloyN", "plateThorium232", CI.machineHull_UV, "plateThorium232", RECIPE_LFTRController); diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 0653420e5b..1ce9a29877 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -22,7 +22,6 @@ import gtPlusPlus.core.proxy.ClientProxy; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.Ic2Items; import ic2.core.init.InternalName; import ic2.core.item.resources.ItemCell; @@ -54,15 +53,16 @@ public class Utils { } public static boolean isModUpToDate(){ - if (CORE.MASTER_VERSION.toLowerCase().equals("offline")){ return false; } - if (CORE.MASTER_VERSION.equals(CORE.VERSION.toLowerCase())){ + else if (CORE.MASTER_VERSION.toLowerCase().equals(CORE.VERSION.toLowerCase())){ return true; } - return false; + else { + return false; + } } public static TC_AspectStack getTcAspectStack (final TC_Aspects aspect, final long size){ diff --git a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java index 77f7d74928..b09b1a1056 100644 --- a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java +++ b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java @@ -4,37 +4,57 @@ import java.io.*; import java.net.*; import java.util.Enumeration; +import gtPlusPlus.core.util.Utils; + public class NetworkUtils { public static String getContentFromURL(final String args) { if (checkNetworkIsAvailableWithValidInterface()){ - try { - URL url; - // get URL content - url = new URL(args); - final URLConnection conn = url.openConnection(); - // open the stream and put it into BufferedReader - final BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); - String inputLine; - String tempLine = null; - while ((inputLine = br.readLine()) != null) { - tempLine = inputLine; - } - br.close(); - return tempLine; + try { + URL url; + // get URL content + url = new URL(args); + final URLConnection conn = url.openConnection(); + // open the stream and put it into BufferedReader + final BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String inputLine; + String tempLine = null; + while ((inputLine = br.readLine()) != null) { + tempLine = inputLine; } - catch (final MalformedURLException e) {} - catch (final IOException e) {} + br.close(); + return tempLine; + } + catch (final MalformedURLException e) { + Utils.LOG_INFO("Bad URL for Version Check."); + } + catch (final IOException e) { + Utils.LOG_INFO("IOException during Version Check."); + } } + Utils.LOG_INFO("Network Not Available during Version Check."); return "offline"; } public static boolean checkNetworkIsAvailableWithValidInterface(){ try { if (hasValidNetworkInterface()){ - if (checkAddressWithTimeout("http://www.google.com", 10) || checkAddressWithTimeout("http://www.baidu.com", 10) || checkAddressWithTimeout("https://github.com/draknyte1/GTplusplus", 10) || checkAddressWithTimeout("www.yahoo.com", 10)){ + if (checkAddressWithTimeout("http://www.google.com", 10) || + checkAddressWithTimeout("http://www.baidu.com", 10) || + checkAddressWithTimeout("https://github.com/draknyte1/GTplusplus", 10) || + checkAddressWithTimeout("www.yahoo.com", 10)/* || + netIsAvailableGoogle() || + netIsAvailableBaidu() || + netIsAvailableGithub() || + netIsAvailableOther()*/){ return true; } + else { + Utils.LOG_INFO("No sites responded to network connectivity test."); + } + } + else { + Utils.LOG_INFO("Network Adapter was not valid."); } } catch (SocketException e) {} @@ -95,9 +115,17 @@ public class NetworkUtils { } return false; } - + private static boolean checkAddressWithTimeout(String URL, int timeout) { - try { + + try { + InetAddress.getByName(URL).isReachable(3000); //Replace with your name + return true; + } catch (Exception e) { + return false; + } + + /*try { final InetAddress[] addresses = InetAddress.getAllByName(URL); for (final InetAddress address : addresses) { if (address.isReachable(timeout)) { @@ -108,7 +136,7 @@ public class NetworkUtils { } catch (final Exception e) { return false; } - return false; + return false;*/ } private static boolean hasValidNetworkInterface() throws SocketException{ |