Skip to content

Commit d927538

Browse files
committed
Merge remote-tracking branch 'official/main' into prs-base
2 parents 680f860 + eae2670 commit d927538

31 files changed

Lines changed: 1039 additions & 902 deletions

HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItem.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,14 @@
3232
import org.jackhuang.hmcl.auth.CredentialExpiredException;
3333
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorAccount;
3434
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
35-
import org.jackhuang.hmcl.auth.microsoft.MicrosoftAccount;
3635
import org.jackhuang.hmcl.auth.offline.OfflineAccount;
3736
import org.jackhuang.hmcl.auth.yggdrasil.CompleteGameProfile;
3837
import org.jackhuang.hmcl.auth.yggdrasil.TextureType;
39-
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
4038
import org.jackhuang.hmcl.setting.Accounts;
4139
import org.jackhuang.hmcl.task.Schedulers;
4240
import org.jackhuang.hmcl.task.Task;
4341
import org.jackhuang.hmcl.ui.Controllers;
4442
import org.jackhuang.hmcl.ui.DialogController;
45-
import org.jackhuang.hmcl.ui.FXUtils;
4643
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
4744
import org.jackhuang.hmcl.util.skin.InvalidSkinException;
4845
import org.jackhuang.hmcl.util.skin.NormalizedSkin;
@@ -128,7 +125,7 @@ public ObservableBooleanValue canUploadSkin() {
128125
.orElse(emptySet());
129126
return uploadableTextures.contains(TextureType.SKIN);
130127
}, profile);
131-
} else if (account instanceof OfflineAccount || account instanceof MicrosoftAccount) {
128+
} else if (account instanceof OfflineAccount || account.canUploadSkin()) {
132129
return createBooleanBinding(() -> true);
133130
} else {
134131
return createBooleanBinding(() -> false);
@@ -144,11 +141,7 @@ public Task<?> uploadSkin() {
144141
Controllers.dialog(new OfflineAccountSkinPane((OfflineAccount) account));
145142
return null;
146143
}
147-
if (account instanceof MicrosoftAccount) {
148-
FXUtils.openLink("https://www.minecraft.net/msaprofile/mygames/editskin");
149-
return null;
150-
}
151-
if (!(account instanceof YggdrasilAccount)) {
144+
if (!account.canUploadSkin()) {
152145
return null;
153146
}
154147

@@ -174,7 +167,7 @@ public Task<?> uploadSkin() {
174167
NormalizedSkin skin = new NormalizedSkin(skinImg);
175168
String model = skin.isSlim() ? "slim" : "";
176169
LOG.info("Uploading skin [" + selectedFile + "], model [" + model + "]");
177-
((YggdrasilAccount) account).uploadSkin(model, selectedFile.toPath());
170+
account.uploadSkin(skin.isSlim(), selectedFile.toPath());
178171
})
179172
.thenComposeAsync(refreshAsync())
180173
.whenComplete(Schedulers.javafx(), e -> {

HMCL/src/main/java/org/jackhuang/hmcl/ui/account/CreateAccountPane.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
import java.util.ArrayList;
6767
import java.util.List;
68+
import java.util.Locale;
6869
import java.util.Map;
6970
import java.util.UUID;
7071
import java.util.concurrent.CountDownLatch;
@@ -637,7 +638,7 @@ public DialogCharacterSelector() {
637638
StackPane.setAlignment(cancel, Pos.BOTTOM_RIGHT);
638639
cancel.setOnAction(e -> latch.countDown());
639640

640-
listBox.startCategory(i18n("account.choose"));
641+
listBox.startCategory(i18n("account.choose").toUpperCase(Locale.ROOT));
641642

642643
setCenter(listBox);
643644

HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java

Lines changed: 122 additions & 119 deletions
Large diffs are not rendered by default.

HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import org.jackhuang.hmcl.util.platform.Architecture;
5151
import org.jackhuang.hmcl.util.platform.OperatingSystem;
5252
import org.jackhuang.hmcl.util.platform.Platform;
53-
import org.jackhuang.hmcl.util.tree.TarFileTree;
5453

5554
import java.io.*;
5655
import java.nio.file.Files;
@@ -151,7 +150,7 @@ private void onAddJavaHome(Path file) {
151150

152151
private void onInstallArchive(Path file) {
153152
Task.supplyAsync(() -> {
154-
try (ArchiveFileTree<?, ?> tree = TarFileTree.open(file)) {
153+
try (ArchiveFileTree<?, ?> tree = ArchiveFileTree.open(file)) {
155154
JavaInfo info = JavaInfo.fromArchive(tree);
156155

157156
if (!JavaManager.isCompatible(info.getPlatform()))

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ private static final class ModItem extends StackPane {
388388

389389
switch (dataItem.getVersionType()) {
390390
case Alpha:
391-
content.getTags().add(i18n("version.game.snapshot"));
391+
content.getTags().add(i18n("mods.channel.alpha"));
392392
graphicPane.getChildren().setAll(SVG.ALPHA_CIRCLE_OUTLINE.createIcon(Theme.blackFill(), 24, 24));
393393
break;
394394
case Beta:
395-
content.getTags().add(i18n("version.game.snapshot"));
395+
content.getTags().add(i18n("mods.channel.beta"));
396396
graphicPane.getChildren().setAll(SVG.BETA_CIRCLE_OUTLINE.createIcon(Theme.blackFill(), 24, 24));
397397
break;
398398
case Release:
399-
content.getTags().add(i18n("version.game.release"));
399+
content.getTags().add(i18n("mods.channel.release"));
400400
graphicPane.getChildren().setAll(SVG.RELEASE_CIRCLE_OUTLINE.createIcon(Theme.blackFill(), 24, 24));
401401
break;
402402
}

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Hello Minecraft! Launcher
3+
* Copyright (C) 2024 huangyuhui <huanghongxun2008@126.com> and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
118
package org.jackhuang.hmcl.ui.versions;
219

320
import com.github.steveice10.opennbt.tag.builtin.*;
@@ -10,11 +27,14 @@
1027
import javafx.collections.ObservableList;
1128
import javafx.geometry.Pos;
1229
import javafx.scene.control.Label;
30+
import javafx.scene.control.ProgressIndicator;
1331
import javafx.scene.control.ScrollPane;
1432
import javafx.scene.layout.BorderPane;
1533
import javafx.scene.layout.StackPane;
1634
import javafx.scene.layout.VBox;
1735
import org.jackhuang.hmcl.game.World;
36+
import org.jackhuang.hmcl.task.Schedulers;
37+
import org.jackhuang.hmcl.task.Task;
1838
import org.jackhuang.hmcl.ui.FXUtils;
1939
import org.jackhuang.hmcl.ui.construct.ComponentList;
2040
import org.jackhuang.hmcl.ui.construct.DoubleValidator;
@@ -32,22 +52,36 @@
3252
import static org.jackhuang.hmcl.util.i18n.I18n.formatDateTime;
3353
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
3454

55+
/**
56+
* @author Glavo
57+
*/
3558
public final class WorldInfoPage extends StackPane implements DecoratorPage {
3659
private final World world;
37-
private final CompoundTag levelDat;
38-
private final CompoundTag dataTag;
60+
private CompoundTag levelDat;
3961

40-
private final ObjectProperty<State> stateProperty = new SimpleObjectProperty<>();
62+
private final ObjectProperty<State> stateProperty;
4163

42-
public WorldInfoPage(World world) throws IOException {
64+
public WorldInfoPage(World world) {
4365
this.world = world;
44-
this.levelDat = world.readLevelDat();
45-
this.dataTag = levelDat.get("Data");
66+
this.stateProperty = new SimpleObjectProperty<>(State.fromTitle(i18n("world.info.title", world.getWorldName())));
67+
68+
this.getChildren().add(new ProgressIndicator());
69+
Task.supplyAsync(world::readLevelDat)
70+
.whenComplete(Schedulers.javafx(), ((result, exception) -> {
71+
if (exception == null) {
72+
this.levelDat = result;
73+
loadWorldInfo();
74+
} else {
75+
LOG.warning("Failed to load level.dat", exception);
76+
this.getChildren().setAll(new Label(i18n("world.info.failed")));
77+
}
78+
})).start();
79+
}
4680

81+
private void loadWorldInfo() {
82+
CompoundTag dataTag = levelDat.get("Data");
4783
CompoundTag worldGenSettings = dataTag.get("WorldGenSettings");
4884

49-
stateProperty.set(State.fromTitle(i18n("world.info.title", world.getWorldName())));
50-
5185
ScrollPane scrollPane = new ScrollPane();
5286
scrollPane.setFitToHeight(true);
5387
scrollPane.setFitToWidth(true);
@@ -483,7 +517,6 @@ String formatPosition(Tag tag) {
483517
Tag z = listTag.get(2);
484518

485519
if (x instanceof DoubleTag && y instanceof DoubleTag && z instanceof DoubleTag) {
486-
//noinspection MalformedFormatString
487520
return this == OVERWORLD
488521
? String.format("(%.2f, %.2f, %.2f)", x.getValue(), y.getValue(), z.getValue())
489522
: String.format("%s (%.2f, %.2f, %.2f)", name, x.getValue(), y.getValue(), z.getValue());

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldListItem.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ public void manageDatapacks() {
102102
}
103103

104104
public void showInfo() {
105-
try {
106-
Controllers.navigate(new WorldInfoPage(world));
107-
} catch (Exception e) {
108-
// TODO
109-
}
105+
Controllers.navigate(new WorldInfoPage(world));
110106
}
111107
}

HMCL/src/main/java11/org/jackhuang/hmcl/util/logging/CallerFinder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
* @author Glavo
1010
*/
1111
final class CallerFinder {
12-
private static final StackWalker WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
1312
private static final String PACKAGE_PREFIX = CallerFinder.class.getPackageName() + ".";
1413
private static final Predicate<StackWalker.StackFrame> PREDICATE = stackFrame -> !stackFrame.getClassName().startsWith(PACKAGE_PREFIX);
1514
private static final Function<Stream<StackWalker.StackFrame>, Optional<StackWalker.StackFrame>> FUNCTION = stream -> stream.filter(PREDICATE).findFirst();
15+
private static final Function<StackWalker.StackFrame, String> FRAME_MAPPING = frame -> frame.getClassName() + "." + frame.getMethodName();
1616

1717
static String getCaller() {
18-
return WALKER.walk(FUNCTION).map(it -> it.getClassName() + "." + it.getMethodName()).orElse(null);
18+
return StackWalker.getInstance().walk(FUNCTION).map(FRAME_MAPPING).orElse(null);
1919
}
2020

2121
private CallerFinder() {

HMCL/src/main/resources/assets/lang/I18N.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,9 @@ mods.add.success=%s was added successfully.
930930
mods.broken_dependency.title=Broken dependency
931931
mods.broken_dependency.desc=This dependency existed before. However, it doesn't exist now. Try using another download source.
932932
mods.category=Category
933+
mods.channel.alpha=Alpha
934+
mods.channel.beta=Beta
935+
mods.channel.release=Release
933936
mods.check_updates=Check for Updates
934937
mods.check_updates.current_version=Current Version
935938
mods.check_updates.empty=All mods are up-to-date
@@ -1007,6 +1010,7 @@ world.info.difficulty.peaceful=Peaceful
10071010
world.info.difficulty.easy=Easy
10081011
world.info.difficulty.normal=Normal
10091012
world.info.difficulty.hard=Hard
1013+
world.info.failed=Failed to read the world info
10101014
world.info.game_version=Game Version
10111015
world.info.last_played=Last Played
10121016
world.info.generate_features=Generate Structures

0 commit comments

Comments
 (0)