diff --git a/platform/mac/mac.gradle b/platform/mac/mac.gradle index b3a9c065e88..60da6f60577 100644 --- a/platform/mac/mac.gradle +++ b/platform/mac/mac.gradle @@ -57,6 +57,7 @@ tasks.register('exportMacX64', Copy.class) { into('Resources') { from file('platform/mac/' + appIcon) rename(appIcon, 'mcreatorapp.icns') from file('platform/mac/' + icon) rename(icon, 'mcreator.icns') + from file('platform/mac/macOSUpdater.jar') } into('MacOS') { from file('platform/mac/mcreator_x64') rename('mcreator_x64', 'mcreator') @@ -111,6 +112,7 @@ tasks.register('exportMacAarch64', Copy.class) { into('Resources') { from file('platform/mac/' + appIcon) rename(appIcon, 'mcreatorapp.icns') from file('platform/mac/' + icon) rename(icon, 'mcreator.icns') + from file('platform/mac/macOSUpdater.jar') } into('MacOS') { from file('platform/mac/mcreator_aarch64') rename('mcreator_aarch64', 'mcreator') diff --git a/platform/mac/macOSUpdater.jar b/platform/mac/macOSUpdater.jar new file mode 100644 index 00000000000..c31cf3ad0d4 Binary files /dev/null and b/platform/mac/macOSUpdater.jar differ diff --git a/plugins/mcreator-localization/lang/texts.properties b/plugins/mcreator-localization/lang/texts.properties index 0ed7c7afa9e..3436b657fb1 100644 --- a/plugins/mcreator-localization/lang/texts.properties +++ b/plugins/mcreator-localization/lang/texts.properties @@ -528,14 +528,15 @@ dialog.unsaved_changes.message=There may be unsaved changes of this mod el dialog.unsaved_changes.title=Unsaved changes dialog.update_notify.message=You are using an outdated version of MCreator
Consider updating your MCreator to get the latest features and bug fixes!

Your version: {0}
The latest version: {1}

Changelog of the latest releases:
dialog.update_notify.update_title=MCreator update -dialog.update_notify.more_recent_build=There is a more recent build for version {0} available
Consider re-downloading the current version to get the latest features and bug fixes!

Your build number: {1}
The latest build number: {2}

Changelog of {3} builds:
+dialog.update_notify.more_recent_build=There is a more recent build for version {0} available
Consider updating now to get the latest features and bug fixes!

Your build number: {1}
The latest build number: {2}

Changelog of {3} builds:
dialog.update_notify.error_failed_check_internet_message=Failed to check for updates. Reason: no internet dialog.update_notify.error_failed_check_internet_title=No internet dialog.update_notify.no_update_message=You have the latest version of MCreator installed! dialog.update_notify.no_pluin_update_message=There are no plugin updates available at this time! dialog.update_notify.no_update_title=No updates -dialog.update_notify.open_download_page=Open download page +dialog.update_notify.learn_more=Learn More dialog.update_notify.remind_later=Remind me later +dialog.update_notify.update_now=Update Now dialog.plugin_update_notify.message=MCreator detected the following plugins can be updated: dialog.plugin_update_notify.update=Update plugin dialog.plugin_update_notify.close=Close this window diff --git a/src/main/java/net/mcreator/ui/dialogs/UpdateNotifyDialog.java b/src/main/java/net/mcreator/ui/dialogs/UpdateNotifyDialog.java index 42ea8d16c51..7981aa081aa 100644 --- a/src/main/java/net/mcreator/ui/dialogs/UpdateNotifyDialog.java +++ b/src/main/java/net/mcreator/ui/dialogs/UpdateNotifyDialog.java @@ -18,6 +18,7 @@ package net.mcreator.ui.dialogs; +import net.mcreator.io.OS; import net.mcreator.Launcher; import net.mcreator.io.net.api.update.Release; import net.mcreator.io.net.api.update.UpdateInfo; @@ -28,15 +29,19 @@ import net.mcreator.ui.laf.MCreatorTheme; import net.mcreator.util.DesktopUtils; import net.mcreator.util.MCreatorVersionNumber; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import javax.swing.*; import javax.swing.text.DefaultCaret; import java.awt.*; +import java.io.IOException; import java.util.List; import java.util.Map; public class UpdateNotifyDialog { + private static final Logger LOG = LogManager.getLogger("Updater"); public static void showUpdateDialogIfUpdateExists(Window parent, boolean notifyForUpdates, boolean notifyForPatches, boolean showNoUpdates) { @@ -64,12 +69,29 @@ public static void showUpdateDialogIfUpdateExists(Window parent, boolean notifyF ar.setText(fullChangelog(updateInfo)); - Object[] options = { L10N.t("dialog.update_notify.open_download_page"), - L10N.t("dialog.update_notify.remind_later") }; - int option = JOptionPane.showOptionDialog(parent, pan, L10N.t("dialog.update_notify.update_title"), - JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); - if (option == 0) { + Object[] options = { + L10N.t("dialog.update_notify.update_now"), + L10N.t("dialog.update_notify.learn_more"), + L10N.t("dialog.update_notify.remind_later"), + }; + int option = JOptionPane.showOptionDialog(parent, pan, + L10N.t("dialog.update_notify.update_title"), + JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, + null, options, options[0]); + + if (option == 1) { DesktopUtils.browseSafe(MCreatorApplication.SERVER_DOMAIN + "/download#update"); + } else if (option == 0) { + if (OS.getOS() == OS.MAC) { + try { + Runtime.getRuntime().exec("./jdk.bundle/Contents/Home/bin/java -jar ./Resources/macOSUpdater.jar"); + System.exit(0); + } catch (IOException e) { + LOG.error("Failed to launch updater for macOS"); + } + } else { + DesktopUtils.browseSafe(MCreatorApplication.SERVER_DOMAIN + "/download#update"); + } } } else if (updateInfo.isNewPatchAvailable() && notifyForPatches) { JPanel pan = new JPanel(new BorderLayout()); @@ -94,12 +116,29 @@ public static void showUpdateDialogIfUpdateExists(Window parent, boolean notifyF ar.setText(releaseChangelog(updateInfo.getReleases().get(Launcher.version.major).getBuilds(), Launcher.version.buildlong)); - Object[] options = { L10N.t("dialog.update_notify.open_download_page"), - L10N.t("dialog.update_notify.remind_later") }; - int option = JOptionPane.showOptionDialog(parent, pan, L10N.t("dialog.update_notify.update_title"), - JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); - if (option == 0) { - DesktopUtils.browseSafe(MCreatorApplication.SERVER_DOMAIN + "/download#updatebuild"); + Object[] options = { + L10N.t("dialog.update_notify.update_now"), + L10N.t("dialog.update_notify.learn_more"), + L10N.t("dialog.update_notify.remind_later"), + }; + int option = JOptionPane.showOptionDialog(parent, pan, + L10N.t("dialog.update_notify.update_title"), + JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, + null, options, options[0]); + + if (option == 1) { + DesktopUtils.browseSafe(MCreatorApplication.SERVER_DOMAIN + "/download#update"); + } else if (option == 0) { + if (OS.getOS() == OS.MAC) { + try { + Runtime.getRuntime().exec("./jdk.bundle/Contents/Home/bin/java -jar ./Resources/macOSUpdater.jar"); + System.exit(0); + } catch (IOException e) { + LOG.error("Failed to launch updater for macOS"); + } + } else { + DesktopUtils.browseSafe(MCreatorApplication.SERVER_DOMAIN + "/download#update"); + } } } else if (showNoUpdates) { JOptionPane.showMessageDialog(parent, L10N.t("dialog.update_notify.no_update_message"), diff --git a/src/main/java/net/mcreator/ui/notifications/StartupNotifications.java b/src/main/java/net/mcreator/ui/notifications/StartupNotifications.java index f22ba068486..03a2b3030e9 100644 --- a/src/main/java/net/mcreator/ui/notifications/StartupNotifications.java +++ b/src/main/java/net/mcreator/ui/notifications/StartupNotifications.java @@ -71,7 +71,7 @@ private static void handleUpdatesCore updateInfo.getLatestMajor()), new NotificationsRenderer.ActionButton(L10N.t("notification.common.more_info"), e -> UpdateNotifyDialog.showUpdateDialogIfUpdateExists(parent, true, false, false)), - new NotificationsRenderer.ActionButton(L10N.t("dialog.update_notify.open_download_page"), + new NotificationsRenderer.ActionButton(L10N.t("dialog.update_notify.learn_more"), e -> DesktopUtils.browseSafe( MCreatorApplication.SERVER_DOMAIN + "/download#update"))); } @@ -85,7 +85,7 @@ private static void handleUpdatesCore updateInfo.getLatestPatchVersion()), new NotificationsRenderer.ActionButton(L10N.t("notification.common.more_info"), e -> UpdateNotifyDialog.showUpdateDialogIfUpdateExists(parent, false, true, false)), - new NotificationsRenderer.ActionButton(L10N.t("dialog.update_notify.open_download_page"), + new NotificationsRenderer.ActionButton(L10N.t("dialog.update_notify.learn_more"), e -> DesktopUtils.browseSafe( MCreatorApplication.SERVER_DOMAIN + "/download#updatebuild"))); }