G-Earth/Extensions/G-Translator_1.0.2/decompiled/gearth/misc/UpdateChecker.java
Administrator 368b92d87a G-Earth 1.5.4 beta 22 - Initial release
Komplettes G-Earth Paket inkl. JRE, Extensions und Tools.

Extensions:
- G-BuildTools, G-Click Ultimate, G-Loader, G-Manipulate
- G-Presets, G-Translator, G-Trigger, G-itemViewer
- Market Utils, Packet Info Explorer, Plants
- RandomRoomVisitor, RoomLogger, Sanbovir Photo Inspector
- SpyFriends, WallAligner, XabboScripter, xabbo
2026-03-16 09:45:04 +01:00

78 lines
3.5 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javafx.application.Platform
* javafx.scene.Node
* javafx.scene.control.Alert
* javafx.scene.control.Alert$AlertType
* javafx.scene.control.ButtonType
* javafx.scene.control.Hyperlink
* javafx.scene.control.Label
* javafx.scene.layout.FlowPane
* javafx.scene.web.WebView
*/
package gearth.misc;
import gearth.GEarth;
import gearth.ui.titlebar.TitleBarController;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.web.WebView;
import org.apache.commons.io.IOUtils;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.json.JSONObject;
public class UpdateChecker {
public static void checkForUpdates() {
new Thread(() -> {
try {
JSONObject object = new JSONObject(IOUtils.toString(new URL(GEarth.gitApi).openStream(), StandardCharsets.UTF_8));
String gitv = (String)object.get("tag_name");
if (new ComparableVersion(GEarth.version).compareTo(new ComparableVersion(gitv)) < 0) {
Platform.runLater(() -> {
String body = (String)object.get("body");
boolean isForcedUpdate = body.contains("(!)");
Alert alert = new Alert(isForcedUpdate ? Alert.AlertType.ERROR : Alert.AlertType.INFORMATION, "G-Earth is outdated!", new ButtonType[]{ButtonType.OK});
FlowPane fp = new FlowPane();
Label lbl = new Label("A new version of G-Earth has been found (" + gitv + ")" + System.lineSeparator() + System.lineSeparator() + "Update to the latest version:");
Hyperlink link = new Hyperlink("https://github.com/sirjonasxx/G-Earth/releases");
fp.getChildren().addAll((Object[])new Node[]{lbl, link});
link.setOnAction(event -> {
GEarth.main.getHostServices().showDocument(link.getText());
event.consume();
});
WebView webView = new WebView();
webView.getEngine().loadContent("<html>A new version of G-Earth has been found (" + gitv + ")<br><br>Update to the latest version:<br><a href=\"https://github.com/sirjonasxx/G-Earth/releases\">https://github.com/sirjonasxx/G-Earth/releases</a></html>");
webView.setPrefSize(500.0, 200.0);
alert.setResizable(false);
alert.getDialogPane().setMinHeight(Double.NEGATIVE_INFINITY);
alert.getDialogPane().setContent((Node)fp);
if (isForcedUpdate) {
alert.setOnCloseRequest(event -> System.exit(0));
}
try {
TitleBarController.create(alert).showAlert();
}
catch (IOException e) {
e.printStackTrace();
}
});
}
}
catch (IOException iOException) {
// empty catch block
}
}).start();
}
}