Search in sources :

Example 1 with UpdateUtils

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;
    });
}
Also used : UpdateUtils(cc.hyperium.utils.UpdateUtils) ClickEvent(net.minecraft.event.ClickEvent) ChatColor(cc.hyperium.utils.ChatColor) IChatComponent(net.minecraft.util.IChatComponent) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ChatComponentText(net.minecraft.util.ChatComponentText) InvokeEvent(cc.hyperium.event.InvokeEvent)

Aggregations

InvokeEvent (cc.hyperium.event.InvokeEvent)1 ChatColor (cc.hyperium.utils.ChatColor)1 UpdateUtils (cc.hyperium.utils.UpdateUtils)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ClickEvent (net.minecraft.event.ClickEvent)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 IChatComponent (net.minecraft.util.IChatComponent)1