mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-21 11:43:27 +00:00
use paper plugin loader to avoid maven central warning
This commit is contained in:
parent
f9888d19a5
commit
2e2ea8f1e4
@ -25,6 +25,7 @@ plugins {
|
|||||||
|
|
||||||
val apiVersion = "1.19"
|
val apiVersion = "1.19"
|
||||||
val main = "com.volmit.iris.Iris"
|
val main = "com.volmit.iris.Iris"
|
||||||
|
val loader = "com.volmit.iris.IrisPluginLoader"
|
||||||
|
|
||||||
val dynamic: Configuration by configurations.creating
|
val dynamic: Configuration by configurations.creating
|
||||||
configurations.compileOnly { extendsFrom(dynamic) }
|
configurations.compileOnly { extendsFrom(dynamic) }
|
||||||
@ -69,6 +70,7 @@ dependencies {
|
|||||||
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
|
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
|
||||||
implementation("net.kyori:adventure-api:4.17.0")
|
implementation("net.kyori:adventure-api:4.17.0")
|
||||||
implementation("org.bstats:bstats-bukkit:3.1.0")
|
implementation("org.bstats:bstats-bukkit:3.1.0")
|
||||||
|
implementation(project(":core:paper-loader"))
|
||||||
|
|
||||||
// Dynamically Loaded
|
// Dynamically Loaded
|
||||||
dynamic("commons-io:commons-io:2.13.0")
|
dynamic("commons-io:commons-io:2.13.0")
|
||||||
@ -118,6 +120,7 @@ tasks {
|
|||||||
"version" to rootProject.version,
|
"version" to rootProject.version,
|
||||||
"apiVersion" to apiVersion,
|
"apiVersion" to apiVersion,
|
||||||
"main" to main,
|
"main" to main,
|
||||||
|
"loader" to loader,
|
||||||
"libraries" to dynamic.allDependencies.map { "\n - $it" }.sorted().joinToString("")
|
"libraries" to dynamic.allDependencies.map { "\n - $it" }.sorted().joinToString("")
|
||||||
)
|
)
|
||||||
filesMatching("**/plugin.yml") {
|
filesMatching("**/plugin.yml") {
|
||||||
|
3
core/paper-loader/build.gradle.kts
Normal file
3
core/paper-loader/build.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dependencies {
|
||||||
|
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.volmit.iris;
|
||||||
|
|
||||||
|
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
|
||||||
|
import io.papermc.paper.plugin.loader.PluginLoader;
|
||||||
|
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||||
|
import org.eclipse.aether.graph.Dependency;
|
||||||
|
import org.eclipse.aether.repository.RemoteRepository;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public class IrisPluginLoader implements PluginLoader {
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public void classloader(@NotNull PluginClasspathBuilder builder) {
|
||||||
|
var pluginUri = URI.create("jar:file:" + builder.getContext().getPluginSource().toAbsolutePath() + "!/plugin.yml");
|
||||||
|
var plugin = YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(pluginUri.toURL().openStream())));
|
||||||
|
var repository = "https://maven-central.storage-download.googleapis.com/maven2";
|
||||||
|
|
||||||
|
try {
|
||||||
|
var field = MavenLibraryResolver.class.getDeclaredField("MAVEN_CENTRAL_DEFAULT_MIRROR");
|
||||||
|
repository = (String) field.get(null);
|
||||||
|
} catch (Throwable e) {}
|
||||||
|
|
||||||
|
var resolver = new MavenLibraryResolver();
|
||||||
|
resolver.addRepository(new RemoteRepository.Builder("central", "default", repository).build());
|
||||||
|
plugin.getStringList("libraries").forEach(library -> resolver.addDependency(new Dependency(new DefaultArtifact(library), null)));
|
||||||
|
builder.addLibrary(resolver);
|
||||||
|
}
|
||||||
|
}
|
@ -10,4 +10,7 @@ commands:
|
|||||||
iris:
|
iris:
|
||||||
aliases: [ ir, irs ]
|
aliases: [ ir, irs ]
|
||||||
api-version: '${apiVersion}'
|
api-version: '${apiVersion}'
|
||||||
hotload-dependencies: false
|
hotload-dependencies: false
|
||||||
|
|
||||||
|
paper-plugin-loader: ${loader}
|
||||||
|
paper-skip-libraries: true
|
@ -21,7 +21,7 @@ plugins {
|
|||||||
|
|
||||||
rootProject.name = "Iris"
|
rootProject.name = "Iris"
|
||||||
|
|
||||||
include(":core", ":core:agent")
|
include(":core", ":core:agent", ":core:paper-loader")
|
||||||
include(
|
include(
|
||||||
":nms:v1_21_R5",
|
":nms:v1_21_R5",
|
||||||
":nms:v1_21_R4",
|
":nms:v1_21_R4",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user