commit source

This commit is contained in:
John Yorke committed 2016-10-25 21:04:40 -03:00
commit 1381f5b9b4
171 files changed
+7742

No files matched your search

@@ -0,0 +1,60 @@
package taintedmagic.common.handler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Scanner;
import taintedmagic.common.TaintedMagic;
import taintedmagic.common.lib.LibStrings;
import net.minecraft.util.EnumChatFormatting;
public class UpdateHandler
{
private static String currentVersion = LibStrings.VERSION;
private static String newestVersion;
public static String updateStatus = null;
public static boolean show = false;
public static void init ()
{
getNewestVersion();
if (newestVersion != null)
{
if (newestVersion.equalsIgnoreCase(currentVersion))
{
show = false;
}
else if (!newestVersion.equalsIgnoreCase(currentVersion))
{
show = true;
updateStatus = (EnumChatFormatting.RED + "Tainted Magic is out of date! The latest version is " + EnumChatFormatting.GREEN + newestVersion);
TaintedMagic.log.info("Mod out of date! You're still running: " + currentVersion + ", Latest Version: " + newestVersion);
}
}
else
{
show = true;
updateStatus = (EnumChatFormatting.RED + "Tainted Magic failed to connect to update server!");
TaintedMagic.log.info("Failed to connect to update server...");
}
}
private static void getNewestVersion ()
{
try
{
URL url = new URL("https://raw.githubusercontent.com/yorkeJohn/Tainted-Magic/master/version.txt");
Scanner s = new Scanner(url.openStream());
newestVersion = s.next();
s.close();
}
catch (Exception ex)
{
ex.printStackTrace();
TaintedMagic.log.info("Could not connect to GitHub repository!");
}
}
}