Curse CDN download provider
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher.
|
||||
* Copyright (C) 2018 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hmcl.download;
|
||||
|
||||
public class CurseCDNDownloadProvider extends MojangDownloadProvider {
|
||||
public static final CurseCDNDownloadProvider INSTANCE = new CurseCDNDownloadProvider();
|
||||
|
||||
protected CurseCDNDownloadProvider() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String injectURL(String baseURL) {
|
||||
return baseURL == null ? null : baseURL.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven");
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,12 @@ import org.jackhuang.hmcl.download.optifine.OptiFineVersionList;
|
||||
* @see <a href="http://wiki.vg">http://wiki,vg</a>
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class MojangDownloadProvider implements DownloadProvider {
|
||||
public class MojangDownloadProvider implements DownloadProvider {
|
||||
|
||||
public static final MojangDownloadProvider INSTANCE = new MojangDownloadProvider();
|
||||
private boolean isChina;
|
||||
|
||||
private MojangDownloadProvider() {
|
||||
public MojangDownloadProvider(boolean isChina) {
|
||||
this.isChina = isChina;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,9 +77,16 @@ public final class MojangDownloadProvider implements DownloadProvider {
|
||||
|
||||
@Override
|
||||
public String injectURL(String baseURL) {
|
||||
if (baseURL.contains("net/minecraftforge/forge"))
|
||||
return baseURL;
|
||||
if (baseURL == null)
|
||||
return null;
|
||||
else if (baseURL.contains("scala-swing") || baseURL.contains("scala-xml") || baseURL.contains("scala-parser-combinators"))
|
||||
return baseURL.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
|
||||
else if (baseURL.contains("typesafe") || baseURL.contains("scala"))
|
||||
if (isChina)
|
||||
return baseURL.replace("http://files.minecraftforge.net/maven", "http://maven.aliyun.com/nexus/content/groups/public");
|
||||
else
|
||||
return baseURL.replace("http://files.minecraftforge.net/maven", "http://repo1.maven.org/maven2");
|
||||
else
|
||||
return baseURL.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven");
|
||||
return baseURL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user