Skip to content

Commit 3f2009a

Browse files
committed
do not add huawei mirror for non Chinese users
1 parent 0bf96a2 commit 3f2009a

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

LibrariesResolver/lite/src/main/java/top/mrxiaom/pluginbase/resolver/DefaultLibraryResolver.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import java.io.File;
66
import java.util.Arrays;
7+
import java.util.Collections;
78
import java.util.List;
9+
import java.util.Locale;
810
import java.util.logging.Logger;
911

1012
public class DefaultLibraryResolver extends AbstractLibraryResolver {
@@ -20,12 +22,24 @@ public DefaultLibraryResolver(Logger logger, File librariesDir) {
2022
* <ul>
2123
* <li><a href="https://mirrors.huaweicloud.com/repository/maven">华为云镜像</a></li>
2224
* <li><a href="https://repo.maven.apache.org/maven2">Maven Central 中心仓库</a></li>
25+
* <li><a href="https://maven-central.storage-download.googleapis.com/maven2">Maven Central 中心仓库(海外)</a></li>
2326
* </ul>
2427
*/
2528
public static List<RemoteRepository> getDefaultRepositories() {
26-
return Arrays.asList(
27-
new RemoteRepository("huaweicloud", "https://mirrors.huaweicloud.com/repository/maven"),
28-
new RemoteRepository("central", "https://repo.maven.apache.org/maven2")
29-
);
29+
if (Locale.getDefault().getCountry().equals("CN")) {
30+
return Arrays.asList(
31+
new RemoteRepository("huaweicloud", "https://mirrors.huaweicloud.com/repository/maven"),
32+
new RemoteRepository("central", "https://repo.maven.apache.org/maven2")
33+
);
34+
} else {
35+
String central = System.getenv("PAPER_DEFAULT_CENTRAL_REPOSITORY");
36+
if (central == null) {
37+
central = System.getProperty("org.bukkit.plugin.java.LibraryLoader.centralURL");
38+
}
39+
if (central == null) {
40+
central = "https://maven-central.storage-download.googleapis.com/maven2";
41+
}
42+
return Collections.singletonList(new RemoteRepository("central", central));
43+
}
3044
}
3145
}

LibrariesResolver/maven/src/main/java/top/mrxiaom/pluginbase/resolver/DefaultLibraryResolver.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import java.io.File;
66
import java.util.Arrays;
7+
import java.util.Collections;
78
import java.util.List;
9+
import java.util.Locale;
810
import java.util.logging.Logger;
911

1012
public class DefaultLibraryResolver extends AbstractLibraryResolver {
@@ -20,12 +22,24 @@ public DefaultLibraryResolver(Logger logger, File librariesDir) {
2022
* <ul>
2123
* <li><a href="https://mirrors.huaweicloud.com/repository/maven">华为云镜像</a></li>
2224
* <li><a href="https://repo.maven.apache.org/maven2">Maven Central 中心仓库</a></li>
25+
* <li><a href="https://maven-central.storage-download.googleapis.com/maven2">Maven Central 中心仓库(海外)</a></li>
2326
* </ul>
2427
*/
2528
public static List<RemoteRepository> getDefaultRepositories() {
26-
return Arrays.asList(
27-
new RemoteRepository.Builder("huaweicloud", "default", "https://mirrors.huaweicloud.com/repository/maven").build(),
28-
new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build()
29-
);
29+
if (Locale.getDefault().getCountry().equals("CN")) {
30+
return Arrays.asList(
31+
new RemoteRepository.Builder("huaweicloud", "default", "https://mirrors.huaweicloud.com/repository/maven").build(),
32+
new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build()
33+
);
34+
} else {
35+
String central = System.getenv("PAPER_DEFAULT_CENTRAL_REPOSITORY");
36+
if (central == null) {
37+
central = System.getProperty("org.bukkit.plugin.java.LibraryLoader.centralURL");
38+
}
39+
if (central == null) {
40+
central = "https://maven-central.storage-download.googleapis.com/maven2";
41+
}
42+
return Collections.singletonList(new RemoteRepository.Builder("central", "default", central).build());
43+
}
3044
}
3145
}

0 commit comments

Comments
 (0)