Fix: version::compareTo compares the name, instead of the game version. (#2664)

* Fix: version.compareTo compares the name, but not the game version.

* Fix more.

* update

* update

Co-authored-by: zkitefly <z18344203426@qq.com>

---------

Co-authored-by: Glavo <zjx001202@gmail.com>
Co-authored-by: zkitefly <z18344203426@qq.com>
This commit is contained in:
Burning_TNT 2024-01-21 00:29:06 +08:00 committed by GitHub
parent 89b5b64943
commit ddcead7c85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -25,6 +25,7 @@ import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.platform.ManagedProcess;
import org.jackhuang.hmcl.util.versioning.VersionNumber;
import java.io.File;
import java.io.IOException;
@ -83,9 +84,10 @@ public final class HMCLGameLauncher extends DefaultLauncher {
1.11 ~ 12zh_cn 时正常zh_CN 时虽然显示了中文但语言设置会错误地显示选择英文
1.13+ zh_cn 时正常zh_CN 时自动切换为英文
*/
if (this.version.compareTo(new Version("1.1")) < 0) {
VersionNumber gameVersion = VersionNumber.asVersion(repository.getGameVersion(version).orElse("0.0"));
if (gameVersion.compareTo("1.1") < 0) {
lang = null;
} else if (this.version.compareTo(new Version("1.10")) <= 0) {
} else if (gameVersion.compareTo("1.11") < 0) {
lang = "zh_CN";
} else {
lang = "zh_cn";

View File

@ -256,7 +256,7 @@ public class DefaultLauncher extends Launcher {
if (StringUtils.isNotBlank(options.getServerIp())) {
String[] args = options.getServerIp().split(":");
if (version.compareTo(new Version("1.20")) < 0) {
if (VersionNumber.VERSION_COMPARATOR.compare(repository.getGameVersion(version).orElse("0.0"), "1.20") < 0) {
res.add("--server");
res.add(args[0]);
res.add("--port");