From d9e3293cf3192cc1032e4480b652264f59fe37a3 Mon Sep 17 00:00:00 2001 From: coolGi Date: Mon, 2 Oct 2023 11:35:06 +1030 Subject: [PATCH 01/12] Added extra safety checks to nightly updater --- .../core/jar/updater/SelfUpdater.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 885cb0659..273a684e1 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -128,9 +128,21 @@ public class SelfUpdater return false; com.electronwill.nightconfig.core.Config pipeline = GitlabGetter.INSTANCE.projectPipelines.get(0); + if (pipeline.get("ref") != ModGitInfo.Git_Main_Branch) + { + LOGGER.warn("Latest pipeline was found for branch ["+ pipeline.get("ref") +"], but we are on branch ["+ ModGitInfo.Git_Main_Branch +"]."); + return false; + } + + if (pipeline.get("status") != "success") + { + LOGGER.warn("Pipeline for branch ["+ ModGitInfo.Git_Main_Branch +"], commit ["+ pipeline.get("id") +"], has either failed to build, or still building."); + return false; + } + if (!GitlabGetter.INSTANCE.getDownloads(pipeline.get("id")).containsKey(mcVersion)) { - LOGGER.warn("Minecraft version ["+ mcVersion +"] is not findable on Gitlab, findable versions are ["+ GitlabGetter.INSTANCE.getDownloads(pipeline.get("id")).keySet().toArray().toString() +"]"); + LOGGER.warn("Minecraft version ["+ mcVersion +"] is not findable on Gitlab, findable versions are ["+ GitlabGetter.INSTANCE.getDownloads(pipeline.get("id")).keySet().toArray().toString() +"]."); return false; } From 9b183aba9318ffdbcfd5f245f89fe0904de3489d Mon Sep 17 00:00:00 2001 From: coolGi Date: Mon, 2 Oct 2023 13:19:20 +1030 Subject: [PATCH 02/12] Fixed strings not using string's "equals" function --- .../seibel/distanthorizons/core/jar/updater/SelfUpdater.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 273a684e1..87b604764 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -128,13 +128,13 @@ public class SelfUpdater return false; com.electronwill.nightconfig.core.Config pipeline = GitlabGetter.INSTANCE.projectPipelines.get(0); - if (pipeline.get("ref") != ModGitInfo.Git_Main_Branch) + if (!pipeline.get("ref").equals(ModGitInfo.Git_Main_Branch)) { LOGGER.warn("Latest pipeline was found for branch ["+ pipeline.get("ref") +"], but we are on branch ["+ ModGitInfo.Git_Main_Branch +"]."); return false; } - if (pipeline.get("status") != "success") + if (!pipeline.get("status").equals("success")) { LOGGER.warn("Pipeline for branch ["+ ModGitInfo.Git_Main_Branch +"], commit ["+ pipeline.get("id") +"], has either failed to build, or still building."); return false; From b18fcb5815ce172ea61a3a11c87da0c38cc174e2 Mon Sep 17 00:00:00 2001 From: coolGi Date: Mon, 2 Oct 2023 14:16:08 +1030 Subject: [PATCH 03/12] Fixed updater on 1.20.2 --- .../seibel/distanthorizons/core/jar/updater/SelfUpdater.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 87b604764..2cb100520 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -130,7 +130,7 @@ public class SelfUpdater if (!pipeline.get("ref").equals(ModGitInfo.Git_Main_Branch)) { - LOGGER.warn("Latest pipeline was found for branch ["+ pipeline.get("ref") +"], but we are on branch ["+ ModGitInfo.Git_Main_Branch +"]."); + //LOGGER.warn("Latest pipeline was found for branch ["+ pipeline.get("ref") +"], but we are on branch ["+ ModGitInfo.Git_Main_Branch +"]."); return false; } From 877b0dae25a59b4e553e7045328938ff7ed24d85 Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 3 Oct 2023 12:44:36 +1030 Subject: [PATCH 04/12] Revert "Fix option and changelog button missing backgrounds" This reverts commit 5fb79325cea83ac50272c6676a0bbc8cf5081634. --- .../distanthorizons/textures/gui/button.png | Bin 694 -> 573 bytes .../distanthorizons/textures/gui/changelog.png | Bin 494 -> 299 bytes .../textures/gui/changelog_button_icon.png | Bin 299 -> 0 bytes .../textures/gui/options_button_icon.png | Bin 573 -> 0 bytes .../textures/gui/raw_button_background.png | Bin 5883 -> 0 bytes 5 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 core/src/main/resources/assets/distanthorizons/textures/gui/changelog_button_icon.png delete mode 100644 core/src/main/resources/assets/distanthorizons/textures/gui/options_button_icon.png delete mode 100644 core/src/main/resources/assets/distanthorizons/textures/gui/raw_button_background.png diff --git a/core/src/main/resources/assets/distanthorizons/textures/gui/button.png b/core/src/main/resources/assets/distanthorizons/textures/gui/button.png index b3091938805658ac2db4d7d5f81333de55331886..ed4a3a8716d9860448a4d2585381738f6b0c1cf6 100644 GIT binary patch delta 559 zcmdnSx|d~wWIY=L1H(VVTepD}V{wqX6T`Z5GB1G~i_{3uG+$o^Eg+kNfw4W4fd!-l zh^2s-fq`iO6I?`O0W+Mf0h0WBq}>6ic(bRAV~7Xu+fYOA!vO+zM>htuA3t+WcFvKN z-OdU-BF;S8zoCBix~|2=iuQ*uSa>>e$R1tWr0eVI>@j)UjtspCKiM%&*17H|z*w^>zx*WR5?3LOtVypSpTrk7||*_`)V zWYtxzD||YW-u25J@J~{jq0p7;U?@5HqsOw2^DKqwlJj-TaII<88rF zTb}Nzw7Z=sa^_RaMK_`BWlr~GeU9iQU+-%0)oj{yx?4<)^OTJBr@wbiPfGH{T^4lu z^do2bk+^xz8QbMJkFyv`9giIdxC!eG6sSZO$`aHdz?AUj4l{!?xVz`CW+;OFI76+4pv; z{9e8wf=y)dM4pX4g7Y~aoip08ZuZQj``;90m`E*nU8SXPD^>I+-(!n&*SpLnMHq`l zOt1ex`_jvj6DzCs##uRen9cSTlICkqh!lGm!E0zW*Uxj(ipGd`Uz>R5(vS|GAa$5u%w zWFlBr|NmF@j?Ht}IX&|Eu-#qvT9#$oxU}>@`)2oV`h%7saGb%=wJm$#dLxYsyxY50 z`d!F)g6WXcz@N>De-Gy5AygxSz@JMwo8j9i>P)}NMSra1GQn|`E>$&?1P4J0K)kTm zO46dMj33oV{i;~$mYzW1lQl@lhG{vSqE)h9F0tM!RjV7)n?O3;l&-L?XGi`c;FCl` z_yjGzczRh4k6tZ%D?}O!8fIzwmI)wR@`PZFMUybg1f_9I)jjN2;CBRYqaACG|a)Jcw6ehQvCf})? z|AU2?B_)8sqT=bsERjhj2UbmIou3={aVihfAtj#AY5qwbUT2dNfZ)f6Z@hH5ng31YQOt~)GJouKE;K&;aB(xwlN}Q{XCD$jFSqbR;yN#&Z5&)(NkDuk zi;ayeW9Zi^bqJ@22WQ%mvv4FO#mWBZ20v6VE_OC z32;bRa{vGi!vFvd!vV){sAK>D0P0CZK~yMHWs%WRgD?<9lUB-ZYAJ~U3_*iJZA9_^ zKhIr~X`S&rz<+S&X7>U@2r22Zu_Lx8xqsLf8wa8+ivvg@3qX|t0*{aXC7dcc&hlK> zdIP{b*_=GrO{?3sA*ob%myOoXoJ7~(B%S9Z5B7QHeW+4scS#O>o~LSsrky*h|ee3tYQ3eiw891Sd? zqDo%~#vmRq=&0NhLia7?660*6x9dFrtdZbK7~?ceU1irbdf)e+zf$@ebjt`Se*x_7 V7D%13Ml=8b002ovPDHLkV1g(+#Tx(s diff --git a/core/src/main/resources/assets/distanthorizons/textures/gui/changelog_button_icon.png b/core/src/main/resources/assets/distanthorizons/textures/gui/changelog_button_icon.png deleted file mode 100644 index bd7c50d0dd74bea5074f00bd02bdb115ccc7f232..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VOR-^lnk5hS=4k__`PV-Ol@H(5E z00ciieB(X5tMqiitAp7JXBgPn*xD*Ls~i6L{rk7Qu(5X7bivdIn_Ax%m|bb@X^H8$ zY*utwa5cB_9E)VBY@Kv9_W$d3`wwSw kvah!}H^+#JO_71&4y)@69i^a$K;JTWy85}Sb4q9e0JKMJwEzGB diff --git a/core/src/main/resources/assets/distanthorizons/textures/gui/options_button_icon.png b/core/src/main/resources/assets/distanthorizons/textures/gui/options_button_icon.png deleted file mode 100644 index ed4a3a8716d9860448a4d2585381738f6b0c1cf6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 573 zcmeAS@N?(olHy`uVBq!ia0vp^B0#Lc!3HG%8Q!`Lq!^2X+?^QKos)S9g)*CXu?K*gIqT^vI^c;AK^dLIrD zusgajnEm*fbFy=etn7AH*b#B&(f$py*L5u}R~?Qj#a`vY^waA34*H#LaWg*e=I;oW)S;czmhK%}!&<{ij7fMo#xE;Y@$p^yWmw z=E?)JRyrJ87PPYFchLcP0e$wX{OcaqFJwx|se9sED8p`Zp82xL!npP7@4Xqe- zTb#SzWi~0oSTtgK{r}mQUY49#S+zIL%E`lQwy%&hUwcBN*uw~3L#w%do|9g*JbdIm ztu!)bPtV>W$Fh_)H*FHmhA1R&t_u!%s?}4^G;#XISb;Rp-=JvpboFyt=akR{0Imw@ A8vpuP)Px#1ZP1_K>z@;j|==^1poj6gHTLVMF0Q*0RsX60RRI70|5a60t5pA1ONa60RR93 z00IL70s;a9009C30{{a800II4009C9EG{o7Dl8`{D=aQ8D=RH6EiWuAE-Wl8DJ&}} zD=I1~Dl021C@Ux}FE1)8EF~u>EG;T4D=8@{DJUo?CMG5&B_%E~E-f%EE-^4IEiEuG zFflPPFE1}8CL<{+Coe27E-NlBD=aN5DK0E3EiNl6D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^97LuzQ^*|F{VS#+eH^RlS#Cv1q{KPxCr?bI6XrRKfNLoJ>wh13fNse$bQ z>MYfd86eYicaV4qN2ECNQ=1D}N%3jN*ZvV@Q`#^m(5wZ1%y%?LDBQ@w>wj$cZ0&4}GdmW?os~ zs6~QB%BMQyuz%}A*J=Wc3^XtmxW?H>uhf#Zd2>pC6E+%5rBMv6pNxq^&!(TFR5VF} zm2y$K?Mvx10%9mx>Zl|+W}>2MajecPt=UN>6uzcB58o^}@R1}YIUSot`u`QQrkxEW z>&VMXFJR0A6IMMw}!S)Sp@VzcH;oNwpZ@?^PQugBxnYCWHyZ6>q%dcr6C z`o-bde7-(ATTjO8)oRQ~@)&~gc)UJapR8)wtmfnSdUZA)pXn2Ivl)%%>&*uGA@UH4 z*cD&Ys~2a$MzRp_VzXMWjsEd!HXNUQxLi*fyK-aOeyHHt1YS9uCj+#{m1X z9*;N3(0UER3O2Kul%vgo467ccQS#ktg_qpNz>CLbv(verD8zObzwq^4BIc_JhsNqd z^yTl-SH4aK`gjGNeEr}79)2G#g1CwzTyaDg%`SNx5HxNB}^8c5mY*>Zj R5#Im+002ovPDHLkV1mf`_b From e966d40ae24ee91df72697b22cb3ddb43f5128d2 Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 3 Oct 2023 22:48:04 +1030 Subject: [PATCH 05/12] Fixed jar reference with spaces in path --- .../distanthorizons/core/jar/JarUtils.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java index 0d4cc63cc..5ddfb9b06 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java @@ -34,7 +34,21 @@ import java.util.Objects; */ public class JarUtils { - public static final File jarFile = new File(JarUtils.class.getProtectionDomain().getCodeSource().getLocation().getPath()); + public static File jarFile = null; + + static { + try { + jarFile = new File(JarUtils.class.getProtectionDomain().getCodeSource().getLocation().toURI()); // Always safe + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + System.out.println(jarFile); + } /** From f81b453c39bca440be626023651c96a721ec0418 Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 3 Oct 2023 23:01:15 +1030 Subject: [PATCH 06/12] Removed test main function --- .../seibel/distanthorizons/core/jar/JarUtils.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java index 5ddfb9b06..9f007adc4 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/JarUtils.java @@ -39,15 +39,7 @@ public class JarUtils static { try { jarFile = new File(JarUtils.class.getProtectionDomain().getCodeSource().getLocation().toURI()); // Always safe - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public static void main(String[] args) { - System.out.println(jarFile); + } catch (Exception e) { e.printStackTrace(); } } @@ -109,7 +101,7 @@ public class JarUtils /** * Checks the checksum of a file given an algorithm * - * @param digest What algorithem to use
+ * @param digest What algorithm to use
* Eg.
* MessageDigest.getInstance("MD5")
* MessageDigest.getInstance("SHA-256")
From f45a4b8d621d3981946a14b3389059a1a7b20abe Mon Sep 17 00:00:00 2001 From: coolGi Date: Thu, 5 Oct 2023 13:09:42 +1030 Subject: [PATCH 07/12] Seeing if this will fix DH auto-updates on windows --- .../core/jar/updater/SelfUpdater.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 2cb100520..09973aae3 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -37,9 +37,11 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.net.URL; +import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Path; import java.security.MessageDigest; +import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -148,8 +150,8 @@ public class SelfUpdater String latestCommit = pipeline.get("sha"); - if (ModGitInfo.Git_Main_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update - return false; + //if (ModGitInfo.Git_Main_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update + // return false; LOGGER.info("New version (" + latestCommit + ") of " + ModInfo.READABLE_NAME + " is available"); @@ -163,6 +165,7 @@ public class SelfUpdater return true; } + /** * Should be called when the game is closed. * This is ued to delete the previous file if it is required at the end. @@ -183,7 +186,13 @@ public class SelfUpdater } try { - Files.delete(JarUtils.jarFile.toPath()); + //URLClassLoader loader = (URLClassLoader) SelfUpdater.class.getClassLoader(); + //((JarFile) loader.getClass().getField("jar").get(loader)).close(); + // + //Files.delete(JarUtils.jarFile.toPath()); + + // TODO: If the fix below doesnt work, do the thing above + JarUtils.jarFile.deleteOnExit(); } catch (Exception e) { From 18ed2e7eeec8975c66e0a82e5be12870da1d51ea Mon Sep 17 00:00:00 2001 From: coolGi Date: Thu, 5 Oct 2023 13:12:35 +1030 Subject: [PATCH 08/12] Disabled updating to the same commit --- .../seibel/distanthorizons/core/jar/updater/SelfUpdater.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 09973aae3..494222709 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -150,8 +150,8 @@ public class SelfUpdater String latestCommit = pipeline.get("sha"); - //if (ModGitInfo.Git_Main_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update - // return false; + if (ModGitInfo.Git_Main_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update + return false; LOGGER.info("New version (" + latestCommit + ") of " + ModInfo.READABLE_NAME + " is available"); From 1bea96b050f275626dffc84c8366a83591de7de7 Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 6 Oct 2023 16:26:39 +1030 Subject: [PATCH 09/12] Temporary fix for windows file locking --- .../core/jar/updater/SelfUpdater.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 494222709..36f4b7aa2 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -22,6 +22,7 @@ package com.seibel.distanthorizons.core.jar.updater; import com.seibel.distanthorizons.api.enums.config.EUpdateBranch; import com.seibel.distanthorizons.core.jar.JarUtils; import com.seibel.distanthorizons.core.jar.ModGitInfo; +import com.seibel.distanthorizons.core.jar.Platform; import com.seibel.distanthorizons.core.jar.installer.GitlabGetter; import com.seibel.distanthorizons.coreapi.ModInfo; import com.seibel.distanthorizons.core.config.Config; @@ -186,13 +187,17 @@ public class SelfUpdater } try { - //URLClassLoader loader = (URLClassLoader) SelfUpdater.class.getClassLoader(); - //((JarFile) loader.getClass().getField("jar").get(loader)).close(); - // - //Files.delete(JarUtils.jarFile.toPath()); - - // TODO: If the fix below doesnt work, do the thing above - JarUtils.jarFile.deleteOnExit(); + if (Platform.get() != Platform.WINDOWS) + { + Files.delete(JarUtils.jarFile.toPath()); + } + else + { + System.setProperty("java.awt.headless", "false"); // Required to make it work + JOptionPane.showMessageDialog(null, "As you are on Windows, DH can not update fully by itself\nPlease delete ["+ JarUtils.jarFile.getAbsolutePath() +"] manually\nClick OK once ready.", ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE); + + Runtime.getRuntime().exec("explorer.exe /select," + JarUtils.jarFile.getAbsolutePath()); + } } catch (Exception e) { From ffb1ce43552b4b39a68c520317e550140ab73e88 Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 6 Oct 2023 17:23:14 +1030 Subject: [PATCH 10/12] Fixed (hopefully) updater on Windows --- .../coreapi/util/jar/UpdateJarRun.java | 44 +++++++++ .../core/jar/updater/SelfUpdater.java | 89 +++++++++++-------- 2 files changed, 94 insertions(+), 39 deletions(-) create mode 100644 api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/UpdateJarRun.java diff --git a/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/UpdateJarRun.java b/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/UpdateJarRun.java new file mode 100644 index 000000000..f95e05caf --- /dev/null +++ b/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/UpdateJarRun.java @@ -0,0 +1,44 @@ +package com.seibel.distanthorizons.coreapi.util.jar; + +import java.io.File; +import java.nio.file.Files; +import java.util.concurrent.TimeUnit; + +/** + * Deletes the first file in the arguments when a lock is lifted from it (for Windows)
+ * DON'T MOVE: If this class is moved, then the updater will no longer work on Windows + * + * @author coolgi + */ +public class UpdateJarRun +{ + /** + * @param args Takes whatever the first argument is, treats it as a file, and deletes it once a process lock is lifted from it + */ + public static void main(String[] args) + { + File file = new File(args[0]); + try + { + for (int i = 0; i < 600; i++) // As it rests for around 0.1 second each loop, this should last a minute + { + if (file.canWrite()) + { + Files.delete(file.toPath()); + break; + } + TimeUnit.MILLISECONDS.sleep(100); + } + } + catch (Exception e) + { + e.printStackTrace(); + throw new RuntimeException("Deletion failed"); + } + + + // If it isn't deleted by the end, crash + if (Files.exists(file.toPath())) + throw new RuntimeException("File was not able to be deleted"); + } +} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 36f4b7aa2..083cd2a9f 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -167,45 +167,7 @@ public class SelfUpdater } - /** - * Should be called when the game is closed. - * This is ued to delete the previous file if it is required at the end. - */ - public static void onClose() - { - if (deleteOldOnClose) - { - try - { - Files.move(newFileLocation.toPath(), JarUtils.jarFile.getParentFile().toPath().resolve(newFileLocation.getName())); - Files.delete(newFileLocation.getParentFile().toPath()); - } - catch (Exception e) - { - LOGGER.warn("Failed to move updated fire from [" + newFileLocation.getAbsolutePath() + "] to [" + JarUtils.jarFile.getParentFile().getAbsolutePath() + "], please move it manually"); - e.printStackTrace(); - } - try - { - if (Platform.get() != Platform.WINDOWS) - { - Files.delete(JarUtils.jarFile.toPath()); - } - else - { - System.setProperty("java.awt.headless", "false"); // Required to make it work - JOptionPane.showMessageDialog(null, "As you are on Windows, DH can not update fully by itself\nPlease delete ["+ JarUtils.jarFile.getAbsolutePath() +"] manually\nClick OK once ready.", ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE); - - Runtime.getRuntime().exec("explorer.exe /select," + JarUtils.jarFile.getAbsolutePath()); - } - } - catch (Exception e) - { - LOGGER.warn("Failed to delete previous " + ModInfo.READABLE_NAME + " file, please delete it manually at [" + JarUtils.jarFile + "]"); - e.printStackTrace(); - } - } - } + public static boolean updateMod() { @@ -321,4 +283,53 @@ public class SelfUpdater return false; } } + + + + + + /** + * Should be called when the game is closed. + * This is ued to delete the previous file if it is required at the end. + */ + public static void onClose() + { + if (deleteOldOnClose) + { + try + { + Files.move(newFileLocation.toPath(), JarUtils.jarFile.getParentFile().toPath().resolve(newFileLocation.getName())); + Files.delete(newFileLocation.getParentFile().toPath()); + } + catch (Exception e) + { + LOGGER.warn("Failed to move updated fire from [" + newFileLocation.getAbsolutePath() + "] to [" + JarUtils.jarFile.getParentFile().getAbsolutePath() + "], please move it manually"); + e.printStackTrace(); + } + try + { + if (Platform.get() != Platform.WINDOWS) + { + Files.delete(JarUtils.jarFile.toPath()); + } + else + { + /* // If we want the user to delete it manually + System.setProperty("java.awt.headless", "false"); // Required to make it work + JOptionPane.showMessageDialog(null, "As you are on Windows, DH can not update fully by itself\nPlease delete ["+ JarUtils.jarFile.getAbsolutePath() +"] manually\nClick OK once ready.", ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE); + + Runtime.getRuntime().exec("explorer.exe /select," + JarUtils.jarFile.getAbsolutePath()); + */ + + // Execute the new jar, to delete the old jar once it detects the lock has been lifted + Runtime.getRuntime().exec("java -cp "+ newFileLocation.getAbsolutePath() +" com.seibel.distanthorizons.coreapi.util.jar.UpdateJarRun "+ JarUtils.jarFile.getAbsolutePath()); + } + } + catch (Exception e) + { + LOGGER.warn("Failed to delete previous " + ModInfo.READABLE_NAME + " file, please delete it manually at [" + JarUtils.jarFile + "]"); + e.printStackTrace(); + } + } + } } From 820683783b3de42eba0cb97d7857cc3fcd970bf4 Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 6 Oct 2023 17:24:31 +1030 Subject: [PATCH 11/12] Changed name to DeleteOnUnlock --- .../coreapi/util/jar/{UpdateJarRun.java => DeleteOnUnlock.java} | 2 +- .../seibel/distanthorizons/core/jar/updater/SelfUpdater.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/{UpdateJarRun.java => DeleteOnUnlock.java} (97%) diff --git a/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/UpdateJarRun.java b/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java similarity index 97% rename from api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/UpdateJarRun.java rename to api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java index f95e05caf..3f88b3067 100644 --- a/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/UpdateJarRun.java +++ b/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java @@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit; * * @author coolgi */ -public class UpdateJarRun +public class DeleteOnUnlock { /** * @param args Takes whatever the first argument is, treats it as a file, and deletes it once a process lock is lifted from it diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index 083cd2a9f..f9d590bf3 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -322,7 +322,7 @@ public class SelfUpdater */ // Execute the new jar, to delete the old jar once it detects the lock has been lifted - Runtime.getRuntime().exec("java -cp "+ newFileLocation.getAbsolutePath() +" com.seibel.distanthorizons.coreapi.util.jar.UpdateJarRun "+ JarUtils.jarFile.getAbsolutePath()); + Runtime.getRuntime().exec("java -cp "+ newFileLocation.getAbsolutePath() +" com.seibel.distanthorizons.coreapi.util.jar.DeleteOnUnlock "+ JarUtils.jarFile.getAbsolutePath()); } } catch (Exception e) From 417cf0a8917db0865f4d75d0e4b860a76138c1a7 Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 6 Oct 2023 18:02:28 +1030 Subject: [PATCH 12/12] Used .renameTo instead of .canWrite to check if file is unlocked --- .../seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java b/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java index 3f88b3067..e9d80a10b 100644 --- a/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java +++ b/api/src/main/java/com/seibel/distanthorizons/coreapi/util/jar/DeleteOnUnlock.java @@ -22,7 +22,7 @@ public class DeleteOnUnlock { for (int i = 0; i < 600; i++) // As it rests for around 0.1 second each loop, this should last a minute { - if (file.canWrite()) + if (file.renameTo(file)) // If it is able to be renamed, then it is unlocked and can be deleted { Files.delete(file.toPath()); break;