-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMahjongPaperLoader.java
More file actions
47 lines (40 loc) · 1.99 KB
/
Copy pathMahjongPaperLoader.java
File metadata and controls
47 lines (40 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package top.ellan.mahjong.bootstrap;
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
import io.papermc.paper.plugin.loader.PluginLoader;
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.repository.RemoteRepository;
public final class MahjongPaperLoader implements PluginLoader {
@Override
public void classloader(PluginClasspathBuilder classpathBuilder) {
MavenLibraryResolver resolver = new MavenLibraryResolver();
resolver.addRepository(new RemoteRepository.Builder(
"central",
"default",
this.mavenCentralRepositoryUrl()
).build());
this.addDependency(resolver, "io.github.ssttkkl:mahjong-utils-jvm:0.7.7");
this.addDependency(resolver, "org.mariadb.jdbc:mariadb-java-client:3.5.9");
this.addDependency(resolver, "com.mysql:mysql-connector-j:9.7.0");
this.addDependency(resolver, "com.h2database:h2:2.4.240");
this.addDependency(resolver, "com.zaxxer:HikariCP:7.1.0");
this.addDependency(resolver, "org.jetbrains.kotlin:kotlin-stdlib:2.4.0");
this.addDependency(resolver, "org.jetbrains.kotlinx:kotlinx-serialization-json:1.11.0");
classpathBuilder.addLibrary(resolver);
}
private void addDependency(MavenLibraryResolver resolver, String coordinates) {
resolver.addDependency(new Dependency(new DefaultArtifact(coordinates), null));
}
private String mavenCentralRepositoryUrl() {
try {
Object mirror = MavenLibraryResolver.class.getField("MAVEN_CENTRAL_DEFAULT_MIRROR").get(null);
if (mirror instanceof String url && !url.isBlank()) {
return url;
}
} catch (ReflectiveOperationException ignored) {
// Older Paper versions do not expose the mirror constant.
}
return "https://repo.maven.apache.org/maven2/";
}
}