Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,48 @@ Organization: https://github.com/moonrise-studios

## Installation

Releases from `1.10.1` are published to Maven Central under `gg.moonrise.engine`. The Moonrise Maven repository also hosts older releases and snapshots.
Releases from `1.10.1` are published to Maven Central under `gg.moonrise.engine`, so no extra repository is
needed. Older releases and snapshots remain on the Moonrise Maven repository
(`https://repo.moonrise.gg/repository/maven-releases/` and `.../maven-snapshots/`); add it only to consume one of
those.

### Gradle (Kotlin DSL)

```kotlin
repositories {
mavenCentral()
maven("https://repo.moonrise.gg/repository/maven-releases/")
maven("https://repo.moonrise.gg/repository/maven-snapshots/")
}
```

Then add dependencies:

```kotlin
dependencies {
implementation("gg.moonrise.engine:plugin-engine-paper:1.10.1")
// or: implementation("gg.moonrise.engine:plugin-engine-bungeecord:1.10.1")
// or: implementation("gg.moonrise.engine:plugin-engine-velocity:1.10.1")
// or: implementation("gg.moonrise.engine:plugin-engine-common:1.10.1")
implementation("gg.moonrise.engine:plugin-engine-paper:1.10.2")
// or: implementation("gg.moonrise.engine:plugin-engine-bungeecord:1.10.2")
// or: implementation("gg.moonrise.engine:plugin-engine-velocity:1.10.2")
// or: implementation("gg.moonrise.engine:plugin-engine-common:1.10.2")
}
```

### Maven

```xml
<repositories>
<repository>
<id>moonrise-releases</id>
<url>https://repo.moonrise.gg/repository/maven-releases/</url>
</repository>
<repository>
<id>moonrise-snapshots</id>
<url>https://repo.moonrise.gg/repository/maven-snapshots/</url>
</repository>
</repositories>
```
Maven Central is Maven's default repository, so only the dependency is needed:

```xml
<dependencies>
<dependency>
<groupId>gg.moonrise.engine</groupId>
<artifactId>plugin-engine-paper</artifactId>
<version>1.10.1</version>
<version>1.10.2</version>
</dependency>
<!-- or: gg.moonrise.engine:plugin-engine-bungeecord:1.10.1 -->
<!-- or: gg.moonrise.engine:plugin-engine-velocity:1.10.1 -->
<!-- or: gg.moonrise.engine:plugin-engine-bungeecord:1.10.2 -->
<!-- or: gg.moonrise.engine:plugin-engine-velocity:1.10.2 -->
</dependencies>
```

Use `-SNAPSHOT` versions when consuming snapshot builds.
### Runtime libraries (Paper)

`PaperPluginLoader` resolves the engine's runtime libraries (Spring, Moss, ConfigLib, Cloud) and the plugin's
`libraries()` at server start from Maven Central only, through Paper's Central mirror
(`PAPER_DEFAULT_CENTRAL_REPOSITORY` or Google's mirror). A plugin that needs a library from another repository
adds that repository in `addLibraries(MavenLibraryResolver)`.

## Quick start (Paper plugins)

Expand Down
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ subprojects {
maven("https://repo1.maven.org/maven2/")
mavenCentral()

// Moonrise
maven("https://repo.moonrise.gg/repository/maven-releases/")
maven("https://repo.moonrise.gg/repository/maven-snapshots/")

// PaperMC
maven("https://repo.papermc.io/repository/maven-public/")

Expand Down
6 changes: 3 additions & 3 deletions bungeecord/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

var id = "plugin-engine-bungeecord"
var domain = "gg.moonrise.engine"
var apiVersion = "1.10.1"
var apiVersion = "1.10.2"

repositories {
maven("https://repo1.maven.org/maven2/")
Expand All @@ -25,8 +25,8 @@ dependencies {
compileOnly("org.incendo:cloud-bungee:2.0.0-beta.10")

// Moss
compileOnly("gg.moonrise.moss:moss-common:1.2.2")
compileOnly("gg.moonrise.moss:moss-bungeecord:1.2.2")
compileOnly("gg.moonrise.moss:moss-common:1.2.3")
compileOnly("gg.moonrise.moss:moss-bungeecord:1.2.3")

// Adventure
compileOnly("net.kyori:adventure-api:4.26.1")
Expand Down
4 changes: 2 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

var id = "plugin-engine-common"
var domain = "gg.moonrise.engine"
var apiVersion = "1.10.1"
var apiVersion = "1.10.2"

repositories {
maven("https://repo1.maven.org/maven2/")
Expand All @@ -19,7 +19,7 @@ dependencies {
compileOnly("org.incendo:cloud-core:2.0.0")

// Moss
compileOnly("gg.moonrise.moss:moss-common:1.2.2")
compileOnly("gg.moonrise.moss:moss-common:1.2.3")

// Adventure
compileOnly("net.kyori:adventure-api:4.26.1")
Expand Down
6 changes: 3 additions & 3 deletions paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

var id = "plugin-engine-paper"
var domain = "gg.moonrise.engine"
var apiVersion = "1.10.1"
var apiVersion = "1.10.2"

repositories {
maven("https://repo1.maven.org/maven2/")
Expand All @@ -26,8 +26,8 @@ dependencies {
compileOnly("org.incendo:cloud-paper:2.0.1")

// Moss
compileOnly("gg.moonrise.moss:moss-common:1.2.2")
compileOnly("gg.moonrise.moss:moss-paper:1.2.2")
compileOnly("gg.moonrise.moss:moss-common:1.2.3")
compileOnly("gg.moonrise.moss:moss-paper:1.2.3")

// PlaceholderAPI
compileOnly("me.clip:placeholderapi:2.11.7")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
import java.util.Objects;

/**
* Represents the SkylandsPluginLoader class.
* Paper plugin loader that resolves the engine's runtime libraries (Spring, Moss, ConfigLib, Cloud) and the
* plugin's own {@link #libraries()} at server start. Every library is resolved from Maven Central through Paper's
* Central mirror ({@code PAPER_DEFAULT_CENTRAL_REPOSITORY}, the {@code org.bukkit.plugin.java.LibraryLoader.centralURL}
* system property, or Google's Maven Central mirror). A plugin that needs another repository adds it in
* {@link #addLibraries(MavenLibraryResolver)}.
*/
public abstract class PaperPluginLoader implements PluginLoader {

private static final List<String> DEFAULT_LIBRARIES = List.of(
"org.springframework:spring-context:6.2.13",
"jakarta.annotation:jakarta.annotation-api:3.0.0",
"de.exlll:configlib-yaml:4.8.1",
"gg.moonrise.moss:moss-paper:1.2.2",
"gg.moonrise.moss:moss-paper:1.2.3",
"org.incendo:cloud-paper:2.0.1",
"org.incendo:cloud-annotations:2.0.0"
);
Expand All @@ -37,8 +41,6 @@ public void classloader(PluginClasspathBuilder builder) {
MavenLibraryResolver resolver = new MavenLibraryResolver();

resolver.addRepository(new RemoteRepository.Builder("central", "default", getDefaultMavenCentralMirror()).build());
resolver.addRepository(new RemoteRepository.Builder("moonrise-releases", "default", "https://repo.moonrise.gg/repository/maven-releases/").build());
resolver.addRepository(new RemoteRepository.Builder("moonrise-snapshots", "default", "https://repo.moonrise.gg/repository/maven-snapshots/").build());

for (String coordinates : runtimeLibraries()) {
resolver.addDependency(dependency(coordinates));
Expand All @@ -59,7 +61,8 @@ public void onClassLoaderInit(PluginClasspathBuilder builder) {
}

/**
* Executes addLibraries.
* Adds anything else to the resolver after the runtime libraries, such as another repository for a library
* that is not on Maven Central.
* @param resolver the resolver
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.papermc.paper.plugin.loader.library.ClassPathLibrary;
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.repository.RemoteRepository;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -35,6 +36,25 @@ void registersStableCloudPaperRuntime() throws ReflectiveOperationException {
assertFalse(coordinates.contains("org.incendo:cloud-paper:jar:2.0.0-beta.10"));
}

@Test
void resolvesOnlyFromTheMavenCentralMirror() throws ReflectiveOperationException {
CapturingClasspathBuilder builder = new CapturingClasspathBuilder();
new PaperPluginLoader() {
}.classloader(builder);

List<RemoteRepository> repositories = repositories(builder.resolver());

assertEquals(List.of("central"), repositories.stream().map(RemoteRepository::getId).toList());
assertFalse(repositories.getFirst().getUrl().contains("repo.moonrise.gg"));
}

@Test
void defaultMossIsTheFirstReleaseOnMavenCentral() throws ReflectiveOperationException {
List<String> coordinates = resolvedCoordinates(loader(List.of()));

assertTrue(coordinates.contains("gg.moonrise.moss:moss-paper:jar:1.2.3"));
}

@Test
void libraryReplacesTheEngineDefaultWithTheSameArtifact() throws ReflectiveOperationException {
List<String> coordinates = resolvedCoordinates(loader(List.of("org.incendo:cloud-paper:2.0.2")));
Expand Down Expand Up @@ -96,6 +116,14 @@ private static List<Dependency> dependencies(MavenLibraryResolver resolver)
return List.copyOf((List<Dependency>) field.get(resolver));
}

@SuppressWarnings("unchecked")
private static List<RemoteRepository> repositories(MavenLibraryResolver resolver)
throws ReflectiveOperationException {
Field field = MavenLibraryResolver.class.getDeclaredField("repositories");
field.setAccessible(true);
return List.copyOf((List<RemoteRepository>) field.get(resolver));
}

private static final class CapturingClasspathBuilder implements PluginClasspathBuilder {

private final List<ClassPathLibrary> libraries = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion velocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

var id = "plugin-engine-velocity"
var domain = "gg.moonrise.engine"
var apiVersion = "1.10.1"
var apiVersion = "1.10.2"

repositories {
maven("https://repo1.maven.org/maven2/")
Expand Down
Loading