use of cc.hyperium.utils.UpdateUtils in project Hyperium by HyperiumClient.
the class UpdateChecker method serverJoinEvent.
@InvokeEvent
public void serverJoinEvent(ServerJoinEvent event) {
// If they were already asked, don't even make the new thread.
if (asked)
return;
UpdateUtils updateUtils = new UpdateUtils();
Multithreading.runAsync(() -> {
boolean latest = updateUtils.isAbsoluteLatest();
boolean beta = updateUtils.isBeta();
int version = Metadata.getVersionID();
Hyperium.LOGGER.info("version is: " + version);
// dont alert beta users
if (beta)
return;
// If they're on the latest version, I don't want to mess with them.
if (latest)
return;
Hyperium.INSTANCE.getNotification().display("You have an update pending.", "Click here to be sent to the installer.", 10f, null, () -> {
try {
Desktop.getDesktop().browse(new URI("https://hyperium.cc/downloads"));
} catch (IOException | URISyntaxException e) {
IChatComponent urlComponent = new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.GRAY + "Click to be sent to update Hyperium");
urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://hyperium.cc/downloads"));
Hyperium.INSTANCE.getHandlers().getGeneralChatHandler().sendMessage(urlComponent);
}
}, new Color(200, 150, 50));
asked = true;
});
}
Aggregations