mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-04-18 18:40:34 +08:00
Fixed not downloading when a library and an native library have the same name
This commit is contained in:
parent
29f53d574c
commit
7d8a66b71a
@ -37,8 +37,8 @@ public interface IMinecraftLibrary extends Cloneable {
|
||||
File getFilePath(File gameDir);
|
||||
|
||||
String getName();
|
||||
|
||||
boolean isRequiredToUnzip();
|
||||
|
||||
boolean isNative();
|
||||
|
||||
String getDownloadURL(String downloadSource);
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
StringBuilder library = new StringBuilder("");
|
||||
ArrayList<MinecraftLibrary> opt = new ArrayList<>();
|
||||
for (MinecraftLibrary l : version.libraries)
|
||||
if (l.allow() && !l.isRequiredToUnzip()) {
|
||||
if (l.allow() && !l.isNative()) {
|
||||
if (l.getName().toLowerCase(Locale.US).contains("optifine")) {
|
||||
opt.add(l);
|
||||
continue;
|
||||
|
@ -26,7 +26,7 @@ import org.jackhuang.hmcl.api.game.IMinecraftLibrary;
|
||||
*/
|
||||
public abstract class AbstractMinecraftLibrary implements IMinecraftLibrary {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
public AbstractMinecraftLibrary(String name) {
|
||||
this.name = name;
|
||||
|
@ -84,7 +84,7 @@ public class MinecraftLibrary extends AbstractMinecraftLibrary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredToUnzip() {
|
||||
public boolean isNative() {
|
||||
return natives != null && allow();
|
||||
}
|
||||
|
||||
@ -125,11 +125,7 @@ public class MinecraftLibrary extends AbstractMinecraftLibrary {
|
||||
downloads.classifiers = new HashMap<>();
|
||||
if (!downloads.classifiers.containsKey(getNative()))
|
||||
downloads.classifiers.put(getNative(), info = new LibraryDownloadInfo());
|
||||
else {
|
||||
info = downloads.classifiers.get(getNative());
|
||||
if (info == null)
|
||||
info = new LibraryDownloadInfo();
|
||||
}
|
||||
else info = downloads.classifiers.get(getNative());
|
||||
} else {
|
||||
if (downloads.artifact == null)
|
||||
downloads.artifact = new LibraryDownloadInfo();
|
||||
|
@ -30,7 +30,7 @@ public class MinecraftOldLibrary extends MinecraftLibrary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredToUnzip() {
|
||||
public boolean isNative() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,10 @@ import org.jackhuang.hmcl.api.game.IMinecraftLibrary;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -164,8 +166,7 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
||||
}
|
||||
|
||||
public File getNatives(File gameDir) {
|
||||
return new File(gameDir, "versions/" + id + "/" + id
|
||||
+ "-natives");
|
||||
return new File(gameDir, "versions/" + id + "/" + id + "-natives");
|
||||
}
|
||||
|
||||
public boolean isAllowedToUnpackNatives() {
|
||||
@ -193,8 +194,6 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
||||
return Objects.equals(this.id, ((MinecraftVersion) obj).id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public AssetIndexDownloadInfo getAssetsIndex() {
|
||||
if (assetIndex == null)
|
||||
assetIndex = new AssetIndexDownloadInfo(assets == null ? AssetsIndex.DEFAULT_ASSET_NAME : assets);
|
||||
@ -212,7 +211,7 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
||||
return i;
|
||||
}
|
||||
|
||||
public Set<IMinecraftLibrary> getLibraries() {
|
||||
return libraries == null ? new HashSet<>() : new HashSet<>(libraries);
|
||||
public List<IMinecraftLibrary> getLibraries() {
|
||||
return libraries == null ? new LinkedList<>() : Collections.unmodifiableList(libraries);
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class MinecraftVersionManager<T extends IMinecraftService> extends IMinec
|
||||
ArrayList<File> unzippings = new ArrayList<>();
|
||||
ArrayList<Extract> extractRules = new ArrayList<>();
|
||||
for (IMinecraftLibrary l : v.libraries)
|
||||
if (l.isRequiredToUnzip() && v.isAllowedToUnpackNatives()) {
|
||||
if (l.isNative() && v.isAllowedToUnpackNatives()) {
|
||||
unzippings.add(getLibraryFile(v, l));
|
||||
extractRules.add(l.getDecompressExtractRules());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user