Compare commits

...
3 Commits
Author SHA1 Message Date
huangyuhui 7a86881926 Fixed downloading libraries that are forbidden in specific OS. Closes #163 2017-08-26 17:45:40 +08:00
huangyuhui b255fd4601 CDATA 2017-08-26 09:04:10 +08:00
huangyuhui 562dd8d916 Fixed #190 2017-08-26 08:35:27 +08:00
6 changed files with 21 additions and 8 deletions

No files matched your search

@@ -175,8 +175,13 @@ public class LaunchingUIDaemon {
@Override
public void accept(PrintlnEvent t) {
if (!t.isError() && logHandler != null)
logHandler.newLogLine(t.getLine() + C.LINE_SEPARATOR);
String log = t.getLine();
if (!t.isError() && logHandler != null) {
if (!log.trim().startsWith("<")) { // without logging configuration.
log = "<![CDATA[" + log.replace("]]>", "") + "]]>";
}
logHandler.newLogLine(log + C.LINE_SEPARATOR);
}
else System.err.println(t.getLine());
HMCLGameLauncher.GameLauncherTag tag = (HMCLGameLauncher.GameLauncherTag) launcher.getTag();
LauncherVisibility l = tag.launcherVisibility;
@@ -39,7 +39,7 @@ public class HMCLGameProvider extends MinecraftVersionManager<HMCLMinecraftServi
public File getLibraryFile(MinecraftVersion version, IMinecraftLibrary lib) {
VersionSetting vs = service.getProfile().getVersionSetting(version.id);
File self = super.getLibraryFile(version, lib);
if (self.exists() || (vs != null && service.getProfile().isNoCommon()))
if (self == null || self.exists() || (vs != null && service.getProfile().isNoCommon()))
return self;
else
return lib.getFilePath(new File(Settings.getInstance().getCommonpath()));
@@ -57,7 +57,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
for (IMinecraftLibrary l : v.getLibraries())
if (l != null && l.allow()) {
File ff = service.version().getLibraryFile(mv, l);
if (!ff.exists() && l.getDownloadURL(service.getDownloadType().name()) != null) {
if (ff != null && !ff.exists() && l.getDownloadURL(service.getDownloadType().name()) != null) {
String libURL = l.getDownloadURL(service.getDownloadType().name());
if (libURL != null)
downloadLibraries.add(new DownloadLibraryJob(l, libURL, ff));
@@ -41,7 +41,11 @@ public abstract class AbstractMinecraftLibrary implements IMinecraftLibrary {
@Override
public String getDownloadURL(String downloadSource) {
return getDownloadInfo().getUrl(DownloadType.valueOf(downloadSource));
LibraryDownloadInfo info = getDownloadInfo();
if (info == null)
return null;
else
return info.getUrl(DownloadType.valueOf(downloadSource));
}
@Override
@@ -123,6 +123,8 @@ public class MinecraftLibrary extends AbstractMinecraftLibrary {
if (natives != null) {
if (downloads.classifiers == null)
downloads.classifiers = new HashMap<>();
if (StrUtils.isBlank(getNative()))
return null;
if (!downloads.classifiers.containsKey(getNative()))
downloads.classifiers.put(getNative(), info = new LibraryDownloadInfo());
else info = downloads.classifiers.get(getNative());
@@ -247,11 +247,13 @@ public class MinecraftVersionManager<T extends IMinecraftService> extends IMinec
throw new GameException("Wrong format: minecraft.json");
ArrayList<File> unzippings = new ArrayList<>();
ArrayList<Extract> extractRules = new ArrayList<>();
for (IMinecraftLibrary l : v.libraries)
if (l.isNative() && v.isAllowedToUnpackNatives()) {
unzippings.add(getLibraryFile(v, l));
for (IMinecraftLibrary l : v.libraries) {
final File f = getLibraryFile(v, l);
if (l.isNative() && v.isAllowedToUnpackNatives() && f != null) {
unzippings.add(f);
extractRules.add(l.getDecompressExtractRules());
}
}
return new DecompressLibraryJob(unzippings.toArray(new File[unzippings.size()]), extractRules.toArray(new Extract[extractRules.size()]), getDecompressNativesToLocation(v));
}