Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Now saves current version
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad committed Nov 22, 2017
1 parent 582688a commit 241c3ef
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
17 changes: 16 additions & 1 deletion src/com/softgate/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions src/com/softgate/controller/Controller.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {

Expand All @@ -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;
}

});



}

Expand Down
1 change: 1 addition & 0 deletions version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=158

0 comments on commit 241c3ef

Please sign in to comment.