diff --git a/libs/libRefTools.jar b/libs/libRefTools.jar index a53cd8a..cbe5f10 100644 Binary files a/libs/libRefTools.jar and b/libs/libRefTools.jar differ diff --git a/src/Launcher/Main.java b/src/Launcher/Main.java index 6e67d89..e8558f8 100644 --- a/src/Launcher/Main.java +++ b/src/Launcher/Main.java @@ -10,6 +10,7 @@ favour and pour yourself some nice Jack Daniels. You deserve it if you're going package Launcher; +import Launcher.net.Updater; import com.tofvesson.reflection.SafeReflection; import javafx.application.Application; import javafx.fxml.FXMLLoader; @@ -147,7 +148,11 @@ public class Main extends Application { icon.setImage(appIcon); } - public static void main(String[] args) { launch(args); } + public static void main(String[] args) { + Updater u = Updater.getInstance(); + + launch(args); + } /** * Search for packs with an 80% match compared to detected string. diff --git a/src/Launcher/net/Updater.java b/src/Launcher/net/Updater.java index e590836..9e9d75b 100644 --- a/src/Launcher/net/Updater.java +++ b/src/Launcher/net/Updater.java @@ -1,6 +1,10 @@ package Launcher.net; +import com.tofvesson.async.Async; +import com.tofvesson.reflection.SafeReflection; + import java.io.IOException; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; @@ -9,27 +13,28 @@ import java.net.URLConnection; */ public class Updater { - private static Updater instance; + private static volatile Updater instance; + private static final Async setup = new Async<>(SafeReflection.getFirstConstructor(Updater.class)); private URLConnection conn; + public static final URL updateURL; + private boolean isUpdateAvailable = false; - private Updater(String URL) throws IOException { - conn = new URL(URL).openConnection(); + static { + URL u = null; + try { u = new URL("https://github.com/GabrielTofvesson/TeamAvionLauncher/releases/"); } catch (MalformedURLException e) { e.printStackTrace(); } + updateURL = u; } - public void downloadStuff(){ - //TODO: + private Updater(){ + try { + conn = updateURL.openConnection(); + + } catch (IOException e) { + System.out.println("No internet connection available!"); + } } - public void downloadMoreStuff(){ - - } - - public void downloadEvenMoreStuff(){ - - } - - public static Updater getInstance(String url) throws IOException { - if(instance==null) instance = new Updater(url); - return instance; + public static Updater getInstance() { + return instance==null?instance=setup.await():instance; // Await async creation } }