mirror of
https://github.com/GTNewHorizons/Tainted-Magic.git
synced 2026-11-18 11:19:24 +00:00
commit source
This commit is contained in:
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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user