瀏覽代碼

修复Java路径锁死Bug

Snow 1 年之前
父節點
當前提交
d4998ba6ef

+ 40 - 34
.idea/artifacts/SNGL_FX17_jar.xml

@@ -3,49 +3,55 @@
     <output-path>$PROJECT_DIR$/out/artifacts/SNGL_FX17_jar</output-path>
     <root id="archive" name="SNGL-FX17.jar">
       <element id="module-output" name="SNGL-FX17" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/client5/httpclient5-fluent/5.2.1/httpclient5-fluent-5.2.1.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/commons/commons-compress/1.22/commons-compress-1.22.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/cn/hutool/hutool-all/5.7.17/hutool-all-5.7.17.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.11/commons-codec-1.11.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-controls:mac-aarch64:21-ea+17" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ehcache/modules/ehcache-core/3.10.8/ehcache-core-3.10.8.jar" path-in-jar="/" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/dev/3-3/jmccc/3.1.4/jmccc-3.1.4.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/terracotta/statistics/2.1.2/statistics-2.1.2.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-fxml/17.0.6/javafx-fxml-17.0.6-mac-aarch64.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/dev/3-3/jmccc-mcdownloader/3.1.4/jmccc-mcdownloader-3.1.4.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore-nio/4.4.15/httpcore-nio-4.4.15.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.glassfish.jaxb:txw2:3.0.0-M5" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ehcache/modules/ehcache-api/3.10.8/ehcache-api-3.10.8.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/io/github/mkpaz/atlantafx-base/2.0.0/atlantafx-base-2.0.0.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/terracotta/terracotta-utilities-tools/0.0.15/terracotta-utilities-tools-0.0.15.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-base/17.0.6/javafx-base-17.0.6-mac-aarch64.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/tukaani/xz/1.9/xz-1.9.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/log4j/log4j/1.2.17/log4j-1.2.17.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/java/dev/jna/jna/5.10.0/jna-5.10.0.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/github/oshi/oshi-core/5.8.6/oshi-core-5.8.6.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.glassfish.jaxb:jaxb-runtime:3.0.0-M5" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5/5.2/httpcore5-5.2.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/commons/commons-compress/1.22/commons-compress-1.22.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: com.sun.istack:istack-commons-runtime:4.0.0" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5-h2/5.2/httpcore5-h2-5.2.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-graphics:mac-aarch64:21-ea+17" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/dev/3-3/jmccc-mojang-api/3.1.4/jmccc-mojang-api-3.1.4.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/java/dev/jna/jna-platform/5.10.0/jna-platform-5.10.0.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-base/17.0.6/javafx-base-17.0.6.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/17.0.6/javafx-graphics-17.0.6-mac-aarch64.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ow2/asm/asm/9.4/asm-9.4.jar" path-in-jar="/" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/cache/cache-api/1.1.1/cache-api-1.1.1.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.15/httpcore-4.4.15.jar" path-in-jar="/" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/dev/3-3/jmccc-yggdrasil-authenticator/3.1.4/jmccc-yggdrasil-authenticator-3.1.4.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/17.0.6/javafx-controls-17.0.6-mac-aarch64.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5-h2/5.2/httpcore5-h2-5.2.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-fxml/17.0.6/javafx-fxml-17.0.6.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/terracotta/offheap-store/2.5.3/offheap-store-2.5.3.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5/5.2/httpcore5-5.2.jar" path-in-jar="/" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ehcache/modules/ehcache-impl/3.10.8/ehcache-impl-3.10.8.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/17.0.6/javafx-controls-17.0.6.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/17.0.6/javafx-graphics-17.0.6.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-fxml:mac-aarch64:21-ea+17" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/terracotta/terracotta-utilities-tools/0.0.15/terracotta-utilities-tools-0.0.15.jar" path-in-jar="/" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/dev/3-3/jmccc-microsoft-authenticator/3.1.4/jmccc-microsoft-authenticator-3.1.4.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.apache.httpcomponents:httpcore:4.4.16" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-base:21-ea+17" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/terracotta/statistics/2.1.2/statistics-2.1.2.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-graphics:21-ea+17" />
+      <element id="library" level="project" name="Maven: com.sun.activation:jakarta.activation:2.0.0" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpasyncclient/4.1.5/httpasyncclient-4.1.5.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/tukaani/xz/1.9/xz-1.9.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-fxml:21-ea+17" />
+      <element id="library" level="project" name="Maven: org.glassfish.jaxb:jaxb-core:3.0.0-M5" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/io/github/mkpaz/atlantafx-base/2.0.0/atlantafx-base-2.0.0.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.16" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/client5/httpclient5-fluent/5.2.1/httpclient5-fluent-5.2.1.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/java/dev/jna/jna-platform/5.10.0/jna-platform-5.10.0.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2.jar" path-in-jar="/" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ehcache/sizeof/0.4.3/sizeof-0.4.3.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ehcache/modules/ehcache-core/3.10.8/ehcache-core-3.10.8.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/github/oshi/oshi-core/5.8.6/oshi-core-5.8.6.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/terracotta/offheap-store/2.5.3/offheap-store-2.5.3.jar" path-in-jar="/" />
       <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/client5/httpclient5/5.2.1/httpclient5-5.2.1.jar" path-in-jar="/" />
-      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpasyncclient/4.1.5/httpasyncclient-4.1.5.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/log4j/log4j/1.2.17/log4j-1.2.17.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.11/commons-codec-1.11.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-controls:21-ea+17" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ehcache/modules/ehcache-impl/3.10.8/ehcache-impl-3.10.8.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/cn/hutool/hutool-all/5.6.0/hutool-all-5.6.0.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/dev/3-3/jmccc-mcdownloader/3.1.4/jmccc-mcdownloader-3.1.4.jar" path-in-jar="/" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/java/dev/jna/jna/5.10.0/jna-5.10.0.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.ehcache:ehcache:3.10.0" />
+      <element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/ow2/asm/asm/9.4/asm-9.4.jar" path-in-jar="/" />
+      <element id="library" level="project" name="Maven: org.openjfx:javafx-base:mac-aarch64:21-ea+17" />
+      <element id="library" level="project" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:3.0.0" />
     </root>
   </artifact>
 </component>

+ 47 - 6
pom.xml

@@ -18,12 +18,12 @@
         <dependency>
             <groupId>org.openjfx</groupId>
             <artifactId>javafx-controls</artifactId>
-            <version>17.0.6</version>
+            <version>21-ea+17</version>
         </dependency>
         <dependency>
             <groupId>org.openjfx</groupId>
             <artifactId>javafx-fxml</artifactId>
-            <version>17.0.6</version>
+            <version>21-ea+17</version>
         </dependency>
 
         <dependency>
@@ -76,13 +76,54 @@
         <dependency>
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
-            <version>5.7.17</version>
+            <version>5.6.0</version>
         </dependency>
+
+        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl -->
+        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>1.7.30</version> <!-- 版本号可能会变化,请检查最新版本 -->
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>2.21.1</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j-impl</artifactId>
+            <version>2.21.1</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ehcache</groupId>
+            <artifactId>ehcache</artifactId>
+            <version>3.10.0</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.16</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents.client5/httpclient5 -->
+        <dependency>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>5.2.1</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore-nio -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore-nio</artifactId>
+            <version>4.4.16</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 87 - 75
src/main/java/com/snowchen/snglfx17/AppCore/DownloadCore.java

@@ -2,13 +2,13 @@ package com.snowchen.snglfx17.AppCore;
 
 import org.to2mbn.jmccc.mcdownloader.MinecraftDownloader;
 import org.to2mbn.jmccc.mcdownloader.MinecraftDownloaderBuilder;
+import org.to2mbn.jmccc.mcdownloader.RemoteVersionList;
 import org.to2mbn.jmccc.mcdownloader.download.concurrent.DownloadCallback;
 import org.to2mbn.jmccc.mcdownloader.download.tasks.DownloadTask;
 import org.to2mbn.jmccc.mcdownloader.download.concurrent.CallbackAdapter;
 import org.to2mbn.jmccc.option.MinecraftDirectory;
 import org.to2mbn.jmccc.version.Version;
 import org.to2mbn.jmccc.mcdownloader.provider.DefaultLayoutProvider;
-import com.snowchen.snglfx17.AppCore.LaunchCore;
 
 public class DownloadCore {
     public class BmclApiProvider extends DefaultLayoutProvider {
@@ -40,80 +40,92 @@ public class DownloadCore {
 
     }
 
-    public void DownloadGameVersion (){
-            // 下载位置(要下载到的.minecraft目录)
-            MinecraftDirectory dir = new MinecraftDirectory(LaunchCore.Game_Directory);
-
-            // 创建MinecraftDownloader
-            MinecraftDownloader downloader = MinecraftDownloaderBuilder
-                    .create()
-                    .build();
-
-            // 下载Minecraft1.xx
-            downloader.downloadIncrementally(dir, "1.20.1", new CallbackAdapter<Version>() {
-
-                @Override
-                public void done(Version result) {
-                    // 当完成时调用
-                    // 参数代表实际下载到的Minecraft版本
-                    System.out.printf("下载完成,下载到的Minecraft版本:%s%n", result);
-                }
-
-                @Override
-                public void failed(Throwable e) {
-                    // 当失败时调用
-                    // 参数代表是由于哪个异常而失败的
-                    System.out.printf("下载失败%n");
-                    e.printStackTrace();
-                }
-
-                @Override
-                public void cancelled() {
-                    // 当被取消时调用
-                    System.out.printf("下载取消%n");
-                }
-
-                @Override
-                public <R> DownloadCallback<R> taskStart(DownloadTask<R> task) {
-                    // 当有一个下载任务被派生出来时调用
-                    // 在这里返回一个DownloadCallback就可以监听该下载任务的状态
-                    System.out.printf("开始下载:%s%n", task.getURI());
-                    return new CallbackAdapter<R>() {
-
-                        @Override
-                        public void done(R result) {
-                            // 当这个DownloadTask完成时调用
-                            System.out.printf("子任务完成:%s%n", task.getURI());
-                        }
-
-                        @Override
-                        public void failed(Throwable e) {
-                            // 当这个DownloadTask失败时调用
-                            System.out.printf("子任务失败:%s。原因:%s%n", task.getURI(), e);
-                        }
-
-                        @Override
-                        public void cancelled() {
-                            // 当这个DownloadTask被取消时调用
-                            System.out.printf("子任务取消:%s%n", task.getURI());
-                        }
-
-                        @Override
-                        public void retry(Throwable e, int current, int max) {
-                            // 当这个DownloadTask因出错而重试时调用
-                            // 重试不代表着失败
-                            // 也就是说,一个DownloadTask可以重试若干次,
-                            // 每次决定要进行一次重试时就会调用这个方法
-                            // 当最后一次重试失败,这个任务也将失败了,failed()才会被调用
-                            // 所以调用顺序就是这样:
-                            // retry()->retry()->...->failed()
-                            System.out.printf("子任务重试[%d/%d]:%s。原因:%s%n", current, max, task.getURI(), e);
-                        }
-                    };
-                }
-            });
-        downloader.shutdown();
-        }
+    public static void DownloadMinecraftVersion() {
+        // 下载位置(要下载到的.minecraft目录)
+        MinecraftDirectory dir = new MinecraftDirectory("/home/yushijinhun/.minecraft");
+
+        // 创建MinecraftDownloader
+        MinecraftDownloader downloader = MinecraftDownloaderBuilder.create().build();
+
+        // 下载Minecraft1.9
+        downloader.downloadIncrementally(dir, "1.20.2", new CallbackAdapter<Version>() {
+
+            @Override
+            public void done(Version result) {
+                // 当完成时调用
+                // 参数代表实际下载到的Minecraft版本
+                System.out.printf("下载完成,下载到的Minecraft版本:%s%n", result);
+            }
+
+            @Override
+            public void failed(Throwable e) {
+                // 当失败时调用
+                // 参数代表是由于哪个异常而失败的
+                System.out.printf("下载失败%n");
+                e.printStackTrace();
+            }
+
+            @Override
+            public void cancelled() {
+                // 当被取消时调用
+                System.out.printf("下载取消%n");
+            }
+
+            @Override
+            public <R> DownloadCallback<R> taskStart(DownloadTask<R> task) {
+                // 当有一个下载任务被派生出来时调用
+                // 在这里返回一个DownloadCallback就可以监听该下载任务的状态
+                System.out.printf("开始下载:%s%n", task.getURI());
+                return new CallbackAdapter<R>() {
+
+                    @Override
+                    public void done(R result) {
+                        // 当这个DownloadTask完成时调用
+                        System.out.printf("子任务完成:%s%n", task.getURI());
+                    }
+
+                    @Override
+                    public void failed(Throwable e) {
+                        // 当这个DownloadTask失败时调用
+                        System.out.printf("子任务失败:%s。原因:%s%n", task.getURI(), e);
+                    }
+
+                    @Override
+                    public void cancelled() {
+                        // 当这个DownloadTask被取消时调用
+                        System.out.printf("子任务取消:%s%n", task.getURI());
+                    }
+
+                    @Override
+                    public void retry(Throwable e, int current, int max) {
+                        // 当这个DownloadTask因出错而重试时调用
+                        // 重试不代表着失败
+                        // 也就是说,一个DownloadTask可以重试若干次,
+                        // 每次决定要进行一次重试时就会调用这个方法
+                        // 当最后一次重试失败,这个任务也将失败了,failed()才会被调用
+                        // 所以调用顺序就是这样:
+                        // retry()->retry()->...->failed()
+                        System.out.printf("子任务重试[%d/%d]:%s。原因:%s%n", current, max, task.getURI(), e);
+                    }
+                };
+            }
+        });
+
+    }
+    public static void DownloadRemoteVersionList(){
+        MinecraftDownloader downloader = MinecraftDownloaderBuilder
+                .create()
+                .build();
+        downloader.fetchRemoteVersionList(new CallbackAdapter<RemoteVersionList>() {
+
+            @Override
+            public void done(RemoteVersionList result) {
+                System.out.printf("版本列表下载完成:%s%n", result);
+            }
+
+            // ............省略其它方法
+        });
+    }
 
     }
 

+ 3 - 2
src/main/java/com/snowchen/snglfx17/AppCore/LaunchCore.java

@@ -10,6 +10,7 @@ import org.to2mbn.jmccc.option.LaunchOption;
 import org.to2mbn.jmccc.option.MinecraftDirectory;
 
 import org.to2mbn.jmccc.option.WindowSize;
+import org.to2mbn.jmccc.auth.Authenticator;
 import org.to2mbn.jmccc.util.ExtraArgumentsTemplates;
 
 import java.io.File;
@@ -20,7 +21,7 @@ import java.util.Map;
 public class LaunchCore {
     public static String Game_Version,Server_Address,Java_Environment = "";
     public static String Player_Name = "";
-    public static String Game_Directory = ".minecraft";
+    public static String Game_Directory;
     public static int Server_Port;
     public static int Max_Mem;
     public static boolean FullScreen_Set = false;
@@ -56,7 +57,7 @@ public class LaunchCore {
     }
     private void GameOption()//游戏设置定义
     {
-        File javaEnvir = new File("/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin/java");//设置Java目录
+        File javaEnvir = new File(Java_Environment);//设置Java目录
         option.setJavaEnvironment(new JavaEnvironment(javaEnvir));
 
         option.setMaxMemory(Max_Mem); //最大内存

+ 41 - 13
src/main/java/com/snowchen/snglfx17/HelloController.java

@@ -1,27 +1,18 @@
 package com.snowchen.snglfx17;
 
+import cn.hutool.system.oshi.OshiUtil;
+import com.snowchen.snglfx17.AppCore.DownloadCore;
 import com.snowchen.snglfx17.AppCore.LaunchCore;
-import com.snowchen.snglfx17.AppCore.SystemState;
 import javafx.application.Platform;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
-import javafx.event.ActionEvent;
 import javafx.fxml.FXML;
 import javafx.scene.control.*;
-import javafx.scene.control.Alert;
-import cn.hutool.core.io.unit.DataUnit;
-import cn.hutool.core.lang.Console;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.system.oshi.OshiUtil;
-import oshi.hardware.*;
-
 import org.to2mbn.jmccc.launch.LaunchException;
-import oshi.SystemInfo;
+import oshi.hardware.GlobalMemory;
 
 import java.io.*;
 import java.util.Objects;
-import java.text.DecimalFormat;
-import java.util.Set;
 
 public class HelloController {
     public void initialize() throws InterruptedException {
@@ -34,7 +25,7 @@ public class HelloController {
                 "\\___ \\|  \\| | |  _| |    \n" +
                 " ___) | |\\  | |_| | |___ \n" +
                 "|____/|_| \\_|\\____|_____|");
-        //SystemState.main();
+        InitializeJavaEnviroment();
         InitializeVersionChoice();
         InitializeMaxMem();
         SetMaxMemListen();
@@ -86,6 +77,8 @@ public class HelloController {
     private void InitializeVersionChoice() {
         // 指定目录路径
         String directoryPath = SetGameDirectory.getText()+"/versions/";
+        LaunchCore.Game_Directory = SetGameDirectory.getText();
+
         System.out.println(directoryPath);
         // 创建File对象,表示目录
         File directory = new File(directoryPath);
@@ -168,6 +161,33 @@ public class HelloController {
             LaunchCore.Max_Mem = (int) SetMaxMem.getValue();
         });
     }
+    private  void InitializeJavaEnviroment(){
+        // 获取Java版本
+        String javaVersion = System.getProperty("java.version");
+        // 获取Java安装路径
+        String javaHome = System.getProperty("java.home");
+        JavaVersion.setText("Java版本:"+javaVersion);
+        String osName = System.getProperty("os.name").toLowerCase();
+        if (osName.contains("mac")) {
+            System.out.println("检测到系统为MacOS,设置默认Java路径");
+            SetJavaEnviroment.setText(javaHome+"/bin/java");
+            System.out.println(SetJavaEnviroment.getText());
+        } else if (osName.contains("win")) {
+            System.out.println("检测到系统为Windows,设置默认Java路径");
+            SetJavaEnviroment.setText(javaHome+"/bin/java.exe");
+            System.out.println(SetJavaEnviroment.getText());
+        } else {
+            System.out.println("其他操作系统");
+        }
+    }
+    @FXML
+    protected void TestDownload(){
+        System.out.println("开始测试");
+        DownloadCore.DownloadMinecraftVersion();
+        //DownloadCore.DownloadRemoteVersionList();
+        InitializeVersionChoice();
+
+    }
     @FXML
     private CheckBox SetFullScreen;
 
@@ -197,6 +217,14 @@ public class HelloController {
     @FXML
     private ChoiceBox<String> VersionChoice;//版本选择下拉框
 
+    @FXML
+    private ListView<String> MinecraftDownloadVersionList;
+
+    @FXML
+    private Label JavaVersion;
+
+
+
 
 }
 

+ 46 - 21
src/main/resources/com/snowchen/snglfx17/hello-view.fxml

@@ -4,6 +4,9 @@
 <?import javafx.scene.control.CheckBox?>
 <?import javafx.scene.control.ChoiceBox?>
 <?import javafx.scene.control.Hyperlink?>
+<?import javafx.scene.control.Label?>
+<?import javafx.scene.control.ListView?>
+<?import javafx.scene.control.ScrollPane?>
 <?import javafx.scene.control.Separator?>
 <?import javafx.scene.control.Slider?>
 <?import javafx.scene.control.Tab?>
@@ -22,46 +25,46 @@
             <content>
               <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="450.0" prefWidth="675.0">
                      <children>
-                        <Button layoutX="459.0" layoutY="284.0" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#StartButtonClick" prefHeight="44.0" prefWidth="208.0" text="启动">
+                        <Button layoutX="456.0" layoutY="286.0" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#StartButtonClick" prefHeight="44.0" prefWidth="200.0" text="启动" AnchorPane.bottomAnchor="80.0" AnchorPane.leftAnchor="456.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="286.0">
                            <font>
-                              <Font name="164-SSJianZhengTi" size="30.0" />
+                              <Font name="164-SSJianZhengTi" size="27.0" />
                            </font>
                         </Button>
-                        <Text layoutX="469.0" layoutY="224.0" strokeType="OUTSIDE" strokeWidth="0.0" text="玩家名" textAlignment="CENTER" wrappingWidth="72.21630859375">
+                        <Text layoutX="463.0" layoutY="224.0" strokeType="OUTSIDE" strokeWidth="0.0" text="玩家名" textAlignment="CENTER" wrappingWidth="72.21630859375" AnchorPane.bottomAnchor="182.4052734375" AnchorPane.leftAnchor="463.0" AnchorPane.rightAnchor="139.78369140625" AnchorPane.topAnchor="209.603515625">
                            <font>
                               <Font name="164-SSJianZhengTi" size="18.0" />
                            </font>
                         </Text>
-                        <Text layoutX="470.0" layoutY="261.0" strokeType="OUTSIDE" strokeWidth="0.0" text="游戏版本" textAlignment="CENTER" wrappingWidth="72.21630859375">
+                        <Text layoutX="463.0" layoutY="260.0" strokeType="OUTSIDE" strokeWidth="0.0" text="游戏版本" textAlignment="CENTER" wrappingWidth="72.21630859375" AnchorPane.bottomAnchor="146.4052734375" AnchorPane.leftAnchor="463.0" AnchorPane.rightAnchor="139.78369140625" AnchorPane.topAnchor="245.603515625">
                            <font>
                               <Font name="164-SSJianZhengTi" size="18.0" />
                            </font>
                         </Text>
-                        <TextField fx:id="PlayerNameInput" layoutX="549.0" layoutY="203.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="32.0" prefWidth="110.0" />
-                        <ChoiceBox fx:id="VersionChoice" layoutX="550.0" layoutY="239.0" minHeight="5.0" minWidth="10.0" prefHeight="32.0" prefWidth="110.0" />
-                        <CheckBox layoutX="456.0" layoutY="348.0" mnemonicParsing="false" text="版本隔离" underline="true">
+                        <TextField fx:id="PlayerNameInput" layoutX="539.0" layoutY="203.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="32.0" prefWidth="110.0" AnchorPane.bottomAnchor="175.0" AnchorPane.leftAnchor="539.0" AnchorPane.rightAnchor="26.0" AnchorPane.topAnchor="203.0" />
+                        <ChoiceBox fx:id="VersionChoice" layoutX="539.0" layoutY="239.0" minHeight="5.0" minWidth="10.0" prefHeight="32.0" prefWidth="110.0" AnchorPane.bottomAnchor="139.0" AnchorPane.leftAnchor="539.0" AnchorPane.rightAnchor="26.0" AnchorPane.topAnchor="239.0" />
+                        <CheckBox layoutX="451.0" layoutY="348.0" mnemonicParsing="false" text="版本隔离" underline="true" AnchorPane.bottomAnchor="41.0" AnchorPane.leftAnchor="451.0" AnchorPane.rightAnchor="127.0" AnchorPane.topAnchor="348.0">
                            <font>
                               <Font name="164-SSJianZhengTi" size="18.0" />
                            </font>
                         </CheckBox>
-                        <CheckBox fx:id="SetFullScreen" layoutX="563.0" layoutY="348.0" mnemonicParsing="false" text="全屏模式" textAlignment="CENTER" textOverrun="CENTER_ELLIPSIS" underline="true">
+                        <CheckBox fx:id="SetFullScreen" layoutX="556.0" layoutY="348.0" mnemonicParsing="false" text="全屏模式" textAlignment="CENTER" textOverrun="CENTER_ELLIPSIS" underline="true" AnchorPane.bottomAnchor="41.0" AnchorPane.leftAnchor="556.0" AnchorPane.rightAnchor="22.0" AnchorPane.topAnchor="348.0">
                            <font>
                               <Font name="164-SSJianZhengTi" size="18.0" />
                            </font>
                         </CheckBox>
-                        <Text layoutX="9.0" layoutY="401.0" strokeType="OUTSIDE" strokeWidth="0.0" text="SNGL Ver 0.2 Alpha" wrappingWidth="182.0791015625" />
-                        <Hyperlink layoutX="542.0" layoutY="383.0" prefHeight="25.0" prefWidth="130.0" text="Powered by JMCCC" textAlignment="RIGHT" />
-                        <TextArea fx:id="LogArea" editable="false" layoutX="12.0" layoutY="11.0" prefHeight="374.0" prefWidth="420.0" promptText="Launcher Version:SNG Ver0.2 Alpha" wrapText="true">
+                        <Text layoutX="14.0" layoutY="401.0" strokeType="OUTSIDE" strokeWidth="0.0" text="SNGL Ver 0.2 Alpha" wrappingWidth="182.0791015625" AnchorPane.bottomAnchor="6.046875" AnchorPane.leftAnchor="13.5" AnchorPane.rightAnchor="478.9208984375" AnchorPane.topAnchor="387.5" />
+                        <Hyperlink layoutX="529.0" layoutY="384.0" prefHeight="25.0" prefWidth="134.0" text="Powered by JMCCC" textAlignment="RIGHT" AnchorPane.bottomAnchor="1.0" AnchorPane.leftAnchor="529.0" AnchorPane.rightAnchor="12.0" AnchorPane.topAnchor="384.0" />
+                        <TextArea fx:id="LogArea" editable="false" layoutX="12.0" layoutY="11.0" prefHeight="374.0" prefWidth="420.0" promptText="Launcher Version:SNGL Ver0.2 Alpha" wrapText="true" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="243.0" AnchorPane.topAnchor="11.0">
                            <font>
                               <Font name="Consolas" size="13.0" />
                            </font></TextArea>
-                        <Separator layoutX="431.0" layoutY="-3.0" orientation="VERTICAL" prefHeight="416.0" prefWidth="28.0" />
+                        <Separator layoutX="431.0" layoutY="-3.0" orientation="VERTICAL" prefHeight="416.0" prefWidth="28.0" AnchorPane.bottomAnchor="-3.0" AnchorPane.leftAnchor="431.0" AnchorPane.rightAnchor="216.0" AnchorPane.topAnchor="-3.0" />
 
    </children>
                   </AnchorPane>
             </content>
           </Tab>
-            <Tab closable="false" text="详细设置">
+            <Tab closable="false" text="版本设置">
               <content>
                 <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                      <children>
@@ -85,7 +88,7 @@
                               <Font name="164-SSJianZhengTi" size="18.0" />
                            </font>
                         </Text>
-                        <TextField fx:id="SetGameDirectory" layoutX="123.0" layoutY="72.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="30.0" prefWidth="310.0" promptText="请填写绝对目录" text="/Users/Snow/IdeaProjects/.minecraft">
+                        <TextField fx:id="SetGameDirectory" layoutX="123.0" layoutY="72.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="30.0" prefWidth="310.0" promptText="请填写绝对目录" text=".minecraft">
                            <font>
                               <Font size="15.0" />
                            </font>
@@ -116,6 +119,11 @@
                               <Font size="14.0" />
                            </font>
                         </TextField>
+                        <Label fx:id="JavaVersion" layoutX="443.0" layoutY="112.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="32.0" prefWidth="220.0" text="Label" AnchorPane.bottomAnchor="266.0" AnchorPane.leftAnchor="443.0" AnchorPane.rightAnchor="12.0" AnchorPane.topAnchor="112.0">
+                           <font>
+                              <Font size="16.0" />
+                           </font>
+                        </Label>
                      </children></AnchorPane>
               </content>
             </Tab>
@@ -123,11 +131,23 @@
               <content>
                 <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                      <children>
-                        <TabPane prefHeight="361.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
+                        <TabPane prefHeight="411.0" prefWidth="675.0" tabClosingPolicy="UNAVAILABLE">
                           <tabs>
                             <Tab text="Minecraft下载">
                               <content>
-                                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
+                                <AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="371.0" prefWidth="670.0">
+                                       <children>
+                                          <Button layoutX="14.0" layoutY="14.0" mnemonicParsing="false" onAction="#TestDownload" prefHeight="32.0" prefWidth="141.0" text="下载测试" />
+                                          <ScrollPane hbarPolicy="NEVER" layoutY="56.0" prefHeight="315.0" prefWidth="675.0" vbarPolicy="ALWAYS">
+                                            <content>
+                                              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="313.0" prefWidth="663.0">
+                                                   <children>
+                                                      <ListView fx:id="MinecraftDownloadVersionList" layoutX="12.0" layoutY="6.0" prefHeight="299.0" prefWidth="646.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="8.0" />
+                                                   </children>
+                                                </AnchorPane>
+                                            </content>
+                                          </ScrollPane>
+                                       </children></AnchorPane>
                               </content>
                             </Tab>
                             <Tab text="Forge下载">
@@ -140,11 +160,16 @@
                      </children></AnchorPane>
               </content>
             </Tab>
-          <Tab text="日志输出">
-            <content>
-              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
-            </content>
-          </Tab>
+            <Tab text="启动器设置">
+              <content>
+                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
+              </content>
+            </Tab>
+            <Tab text="关于">
+               <content>
+                  <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
+               </content>
+            </Tab>
         </tabs>
       </TabPane>