diff --git a/src/com/softgate/App.java b/src/com/softgate/App.java index aec28ca..af9f769 100644 --- a/src/com/softgate/App.java +++ b/src/com/softgate/App.java @@ -6,12 +6,27 @@ import javafx.scene.Scene; import javafx.scene.layout.StackPane; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; + public final class App extends Application { + + private static final Properties properties = new Properties(); + + public static int version = 155; @Override public void init() { - + try(FileReader reader = new FileReader(new File("version.properties"))) { + properties.load(reader); + version = Integer.parseInt(properties.getProperty("version")); + } catch (IOException e) { + e.printStackTrace(); + } } @Override diff --git a/src/com/softgate/controller/Controller.java b/src/com/softgate/controller/Controller.java index fb7917c..25d1316 100644 --- a/src/com/softgate/controller/Controller.java +++ b/src/com/softgate/controller/Controller.java @@ -1,8 +1,12 @@ package com.softgate.controller; +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; import java.net.URL; import java.util.ResourceBundle; +import com.softgate.App; import com.softgate.net.CacheRequester; import javafx.animation.PauseTransition; @@ -38,7 +42,7 @@ protected Boolean call() throws Exception { updateMessage("Connecting..."); - requester.connect("oldschool" + 1 + ".runescape.com", 135); + requester.connect("oldschool" + 1 + ".runescape.com", App.version); while (requester.getState() != CacheRequester.State.CONNECTED) { @@ -48,14 +52,19 @@ protected Boolean call() throws Exception { requester.process(); } - + + if (requester.getRevision() > App.version) { + App.version = requester.getRevision(); + try(PrintWriter writer = new PrintWriter(new FileWriter(new File("./version.properties")))) { + writer.println(String.format("version=%d", requester.getRevision())); + } + } + updateMessage(String.format("Success!\nRevision=%d", requester.getRevision())); return true; } }); - - } diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..4ea3616 --- /dev/null +++ b/version.properties @@ -0,0 +1 @@ +version=158