优化 I18n (#2948)

* update

* update

* update

* update

* update
This commit is contained in:
Glavo
2024-03-23 14:11:52 +08:00
committed by GitHub
parent 8b94fe5b0b
commit 94ccee0b76
9 changed files with 67 additions and 84 deletions

View File

@@ -23,6 +23,7 @@ import org.jackhuang.hmcl.task.FileDownloadTask;
import java.io.IOException;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
@@ -30,18 +31,18 @@ import java.util.stream.Stream;
import static org.jackhuang.hmcl.util.io.NetworkUtils.encodeLocation;
public class RemoteMod {
private static RemoteMod EMPTY = null;
public static void registerEmptyRemoteMod(RemoteMod empty) {
EMPTY = empty;
}
public static RemoteMod getEmptyRemoteMod() {
if (EMPTY == null) {
throw new NullPointerException();
public static final RemoteMod BROKEN = new RemoteMod("", "", "RemoteMod.BROKEN", "", Collections.emptyList(), "", "", new RemoteMod.IMod() {
@Override
public List<RemoteMod> loadDependencies(RemoteModRepository modRepository) throws IOException {
throw new IOException();
}
return EMPTY;
}
@Override
public Stream<RemoteMod.Version> loadVersions(RemoteModRepository modRepository) throws IOException {
throw new IOException();
}
});
private final String slug;
private final String author;
@@ -158,7 +159,7 @@ public class RemoteMod {
public RemoteMod load() throws IOException {
if (this.remoteMod == null) {
if (this.type == DependencyType.BROKEN) {
this.remoteMod = RemoteMod.getEmptyRemoteMod();
this.remoteMod = RemoteMod.BROKEN;
} else {
this.remoteMod = this.remoteModRepository.getModById(this.id);
}