Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
663e1ef7ab | ||
|
|
1a47d355f0 | ||
|
|
e407994103 | ||
|
|
bda2149c02 |
No files matched your search
@@ -17,10 +17,6 @@ public class URLValidator extends ValidatorBase {
|
||||
super();
|
||||
}
|
||||
|
||||
public URLValidator(@NamedArg("message") String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ObservableList<String> getProtocols() {
|
||||
return protocols;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ install.installer.forge=Forge
|
||||
install.installer.game=游戏
|
||||
install.installer.install=安装%s
|
||||
install.installer.liteloader=LiteLoader
|
||||
install.installer.not_installed=暂不安装%s,点击此处安装
|
||||
install.installer.not_installed=暂不安装%s,可以点击此处安装
|
||||
install.installer.optifine=OptiFine
|
||||
install.installer.version=%s版本
|
||||
install.modpack=安装整合包
|
||||
|
||||
@@ -36,27 +36,27 @@ public class BMCLAPIDownloadProvider implements DownloadProvider {
|
||||
|
||||
@Override
|
||||
public String getLibraryBaseURL() {
|
||||
return "http://bmclapi2.bangbang93.com/libraries/";
|
||||
return "https://bmclapi2.bangbang93.com/libraries/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionListURL() {
|
||||
return "http://bmclapi2.bangbang93.com/mc/game/version_manifest.json";
|
||||
return "https://bmclapi2.bangbang93.com/mc/game/version_manifest.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionBaseURL() {
|
||||
return "http://bmclapi2.bangbang93.com/versions/";
|
||||
return "https://bmclapi2.bangbang93.com/versions/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssetIndexBaseURL() {
|
||||
return "http://bmclapi2.bangbang93.com/indexes/";
|
||||
return "https://bmclapi2.bangbang93.com/indexes/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssetBaseURL() {
|
||||
return "http://bmclapi2.bangbang93.com/assets/";
|
||||
return "https://bmclapi2.bangbang93.com/assets/";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,12 +78,12 @@ public class BMCLAPIDownloadProvider implements DownloadProvider {
|
||||
@Override
|
||||
public String injectURL(String baseURL) {
|
||||
return baseURL
|
||||
.replace("https://launchermeta.mojang.com", "http://bmclapi2.bangbang93.com")
|
||||
.replace("https://launcher.mojang.com", "http://bmclapi2.bangbang93.com")
|
||||
.replace("https://libraries.minecraft.net", "http://bmclapi2.bangbang93.com/libraries")
|
||||
.replaceFirst("https?://files\\.minecraftforge\\.net/maven", "http://bmclapi2.bangbang93.com/maven")
|
||||
.replace("http://dl.liteloader.com/versions/versions.json", "http://bmclapi2.bangbang93.com/maven/com/mumfrey/liteloader/versions.json")
|
||||
.replace("http://dl.liteloader.com/versions", "http://bmclapi2.bangbang93.com/maven");
|
||||
.replace("https://launchermeta.mojang.com", "https://bmclapi2.bangbang93.com")
|
||||
.replace("https://launcher.mojang.com", "https://bmclapi2.bangbang93.com")
|
||||
.replace("https://libraries.minecraft.net", "https://bmclapi2.bangbang93.com/libraries")
|
||||
.replaceFirst("https?://files\\.minecraftforge\\.net/maven", "https://bmclapi2.bangbang93.com/maven")
|
||||
.replace("http://dl.liteloader.com/versions/versions.json", "https://bmclapi2.bangbang93.com/maven/com/mumfrey/liteloader/versions.json")
|
||||
.replace("http://dl.liteloader.com/versions", "https://bmclapi2.bangbang93.com/maven");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,10 +17,12 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.download.game;
|
||||
|
||||
import org.jackhuang.hmcl.game.CompatibilityRule;
|
||||
import org.jackhuang.hmcl.game.Library;
|
||||
import org.jackhuang.hmcl.game.Version;
|
||||
import org.jackhuang.hmcl.task.TaskResult;
|
||||
import org.jackhuang.hmcl.util.Constants;
|
||||
import org.jackhuang.hmcl.util.Platform;
|
||||
import org.jackhuang.hmcl.util.SimpleMultimap;
|
||||
import org.jackhuang.hmcl.util.VersionNumber;
|
||||
|
||||
@@ -44,7 +46,6 @@ public class LibrariesUniqueTask extends TaskResult<Version> {
|
||||
public void execute() {
|
||||
List<Library> libraries = new ArrayList<>(version.getLibraries());
|
||||
|
||||
Map<String, VersionNumber> versionMap = new HashMap<>();
|
||||
SimpleMultimap<String, Library> multimap = new SimpleMultimap<String, Library>(HashMap::new, LinkedList::new);
|
||||
|
||||
for (Library library : libraries) {
|
||||
@@ -52,32 +53,36 @@ public class LibrariesUniqueTask extends TaskResult<Version> {
|
||||
VersionNumber number = VersionNumber.asVersion(library.getVersion());
|
||||
String serialized = Constants.GSON.toJson(library);
|
||||
|
||||
if (versionMap.containsKey(id)) {
|
||||
VersionNumber otherNumber = versionMap.get(id);
|
||||
if (number.compareTo(otherNumber) > 0) {
|
||||
multimap.removeKey(id);
|
||||
versionMap.put(id, number);
|
||||
multimap.put(id, library);
|
||||
} else if (number.compareTo(otherNumber) == 0) { // same library id.
|
||||
boolean flag = false;
|
||||
// prevent from duplicated libraries
|
||||
for (Library otherLibrary : multimap.get(id))
|
||||
if (library.equals(otherLibrary)) {
|
||||
String otherSerialized = Constants.GSON.toJson(otherLibrary);
|
||||
// A trick, the library that has more information is better, which can be
|
||||
// considered whose serialized JSON text will be longer.
|
||||
if (serialized.length() <= otherSerialized.length()) {
|
||||
flag = true;
|
||||
break;
|
||||
} else {
|
||||
multimap.removeValue(id, otherLibrary);
|
||||
if (multimap.containsKey(id)) {
|
||||
boolean hasEqualRule = false;
|
||||
for (Library otherLibrary : multimap.get(id)) {
|
||||
VersionNumber otherNumber = VersionNumber.asVersion(otherLibrary.getVersion());
|
||||
if (CompatibilityRule.equals(library.getRules(), otherLibrary.getRules())) { // rules equal, ignore older version.
|
||||
hasEqualRule = true;
|
||||
if (number.compareTo(otherNumber) > 0) { // if this library is newer
|
||||
multimap.removeValue(otherLibrary);
|
||||
multimap.put(id, library);
|
||||
break;
|
||||
} else if (number.compareTo(otherNumber) == 0) { // same library id.
|
||||
// prevent from duplicated libraries
|
||||
if (library.equals(otherLibrary)) {
|
||||
String otherSerialized = Constants.GSON.toJson(otherLibrary);
|
||||
// A trick, the library that has more information is better, which can be
|
||||
// considered whose serialized JSON text will be longer.
|
||||
if (serialized.length() > otherSerialized.length()) {
|
||||
multimap.removeValue(id, otherLibrary);
|
||||
multimap.put(id, library);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
multimap.put(id, library);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasEqualRule) {
|
||||
multimap.put(id, library);
|
||||
}
|
||||
} else {
|
||||
versionMap.put(id, number);
|
||||
multimap.put(id, library);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,25 @@ public final class CompatibilityRule {
|
||||
return action == Action.ALLOW;
|
||||
}
|
||||
|
||||
public static boolean equals(Collection<CompatibilityRule> rules1, Collection<CompatibilityRule> rules2) {
|
||||
return Objects.hashCode(rules1) == Objects.hashCode(rules2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CompatibilityRule that = (CompatibilityRule) o;
|
||||
return action == that.action &&
|
||||
Objects.equals(os, that.os) &&
|
||||
Objects.equals(features, that.features);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(action, os, features);
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
ALLOW,
|
||||
DISALLOW
|
||||
|
||||
@@ -137,6 +137,10 @@ public class Library implements Comparable<Library> {
|
||||
return checksums;
|
||||
}
|
||||
|
||||
public List<CompatibilityRule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
|
||||
public boolean is(String groupId, String artifactId) {
|
||||
return this.groupId.equals(groupId) && this.artifactId.equals(artifactId);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public class DefaultLauncher extends Launcher {
|
||||
if (isWindows) {
|
||||
writer.write("@echo off");
|
||||
writer.newLine();
|
||||
writer.write("set APPDATA=" + options.getGameDir().getParent());
|
||||
writer.write("set APPDATA=" + options.getGameDir().getAbsoluteFile().getParent());
|
||||
writer.newLine();
|
||||
writer.write("cd /D %APPDATA%");
|
||||
writer.newLine();
|
||||
|
||||
Reference in new issue
Block a user