-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
233 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,8 @@ buildNumber.properties | |
|
||
# Common working directory | ||
run/ | ||
run1_19_4/ | ||
run1_17_1/ | ||
build | ||
.gradle | ||
/*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,64 @@ | ||
import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYaml | ||
import xyz.jpenilla.runpaper.task.RunServer | ||
|
||
plugins { | ||
`java-library` | ||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.13" | ||
id("xyz.jpenilla.run-paper") version "2.3.1" // Adds runServer and runMojangMappedServer tasks for testing | ||
`my-conventions` | ||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.13" apply false | ||
id("xyz.jpenilla.run-paper") version "2.3.1" // Adds runServer task for testing | ||
id("xyz.jpenilla.resource-factory-bukkit-convention") version "1.2.0" // Generates plugin.yml based on the Gradle config | ||
id("com.gradleup.shadow") version "8.3.5" | ||
} | ||
|
||
group = "io.papermc.paperweight" | ||
version = "1.0.0-SNAPSHOT" | ||
description = "Test plugin for paperweight-userdev" | ||
java.disableAutoTargetJvm() // Allow consuming JVM 21 projects (i.e. paper_1_21_4) even though our release is 17 | ||
|
||
java { | ||
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 11 installed for example. | ||
toolchain.languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
dependencies { | ||
compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT") | ||
|
||
implementation(project(":paper_hooks")) | ||
|
||
// For 1.20.4 or below, or when you care about supporting Spigot on >=1.20.5: | ||
/* | ||
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION | ||
// Shade the reobf variant | ||
runtimeOnly(project(":paper_1_17_1", configuration = "reobf")) | ||
runtimeOnly(project(":paper_1_19_4", configuration = "reobf")) | ||
|
||
// For Paper 1.20.5+, we don't need to use the reobf variant. | ||
// If you still support spigot, you will need to use the reobf variant, | ||
// and remove the Mojang-mapped metadata from the manifest below. | ||
runtimeOnly(project(":paper_1_21_4")) | ||
} | ||
|
||
tasks.assemble { | ||
dependsOn(tasks.reobfJar) | ||
dependsOn(tasks.shadowJar) | ||
} | ||
*/ | ||
|
||
dependencies { | ||
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") | ||
// paperweight.foliaDevBundle("1.21.4-R0.1-SNAPSHOT") | ||
// paperweight.devBundle("com.example.paperfork", "1.21.4-R0.1-SNAPSHOT") | ||
} | ||
|
||
tasks { | ||
compileJava { | ||
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable. | ||
// See https://openjdk.java.net/jeps/247 for more information. | ||
options.release = 21 | ||
} | ||
javadoc { | ||
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything | ||
} | ||
|
||
// Only relevant for 1.20.4 or below, or when you care about supporting Spigot on >=1.20.5: | ||
/* | ||
reobfJar { | ||
// This is an example of how you might change the output location for reobfJar. It's recommended not to do this | ||
// for a variety of reasons, however it's asked frequently enough that an example of how to do it is included here. | ||
outputJar = layout.buildDirectory.file("libs/PaperweightTestPlugin-${project.version}.jar") | ||
} | ||
*/ | ||
tasks.jar { | ||
manifest.attributes( | ||
"paperweight-mappings-namespace" to "mojang", | ||
) | ||
} | ||
|
||
// Configure plugin.yml generation | ||
// - name, version, and description are inherited from the Gradle project. | ||
bukkitPluginYaml { | ||
main = "io.papermc.paperweight.testplugin.TestPlugin" | ||
main = "my.plugin.MyPlugin" | ||
load = BukkitPluginYaml.PluginLoadOrder.STARTUP | ||
authors.add("Author") | ||
apiVersion = "1.21.4" | ||
apiVersion = "1.17" | ||
} | ||
|
||
tasks.runServer { | ||
minecraftVersion("1.21.4") | ||
} | ||
|
||
tasks.register("run1_17_1", RunServer::class) { | ||
minecraftVersion("1.17.1") | ||
pluginJars.from(tasks.shadowJar.flatMap { it.archiveFile }) | ||
runDirectory = layout.projectDirectory.dir("run1_17_1") | ||
systemProperties["Paper.IgnoreJavaVersion"] = true | ||
} | ||
|
||
tasks.register("run1_19_4", RunServer::class) { | ||
minecraftVersion("1.19.4") | ||
pluginJars.from(tasks.shadowJar.flatMap { it.archiveFile }) | ||
runDirectory = layout.projectDirectory.dir("run1_19_4") | ||
systemProperties["Paper.IgnoreJavaVersion"] = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.kotlin.dsl.maven | ||
import org.gradle.kotlin.dsl.repositories | ||
|
||
plugins { | ||
`java-library` | ||
} | ||
|
||
java { | ||
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 17 installed for example. | ||
// If you need to compile to for example JVM 8 or 17 bytecode, adjust the 'release' option below and keep the toolchain at 21. | ||
toolchain.languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
|
||
repositories { | ||
maven("https://repo.papermc.io/repository/maven-public/") | ||
} | ||
|
||
tasks { | ||
withType<JavaCompile>().configureEach { | ||
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable. | ||
// See https://openjdk.java.net/jeps/247 for more information. | ||
options.release = 17 | ||
} | ||
withType<Javadoc>().configureEach { | ||
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# Project meta | ||
group = io.papermc.paperweight | ||
version = 1.0.0-SNAPSHOT | ||
description = Test plugin for paperweight-userdev | ||
|
||
# Gradle configuration | ||
org.gradle.parallel=true | ||
org.gradle.caching=true | ||
org.gradle.configuration-cache=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
`my-conventions` | ||
id("io.papermc.paperweight.userdev") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":paper_hooks")) | ||
|
||
paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT") | ||
} |
12 changes: 12 additions & 0 deletions
12
paper_1_17_1/src/main/java/my/plugin/hooks/paper_1_17_1/PaperHooks1_17_1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package my.plugin.hooks.paper_1_17_1; | ||
|
||
import my.plugin.hooks.PaperHooks; | ||
import net.minecraft.SharedConstants; | ||
import org.slf4j.Logger; | ||
|
||
public class PaperHooks1_17_1 implements PaperHooks { | ||
@Override | ||
public void doSomething(final Logger logger) { | ||
logger.info(SharedConstants.getCurrentVersion().getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
`my-conventions` | ||
id("io.papermc.paperweight.userdev") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":paper_hooks")) | ||
|
||
paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT") | ||
} |
12 changes: 12 additions & 0 deletions
12
paper_1_19_4/src/main/java/my/plugin/hooks/paper_1_19_4/PaperHooks1_19_4.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package my.plugin.hooks.paper_1_19_4; | ||
|
||
import my.plugin.hooks.PaperHooks; | ||
import net.minecraft.SharedConstants; | ||
import org.slf4j.Logger; | ||
|
||
public class PaperHooks1_19_4 implements PaperHooks { | ||
@Override | ||
public void doSomething(final Logger logger) { | ||
logger.info(SharedConstants.getCurrentVersion().getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
`my-conventions` | ||
id("io.papermc.paperweight.userdev") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":paper_hooks")) | ||
|
||
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") | ||
// paperweight.foliaDevBundle("1.21.4-R0.1-SNAPSHOT") | ||
// paperweight.devBundle("com.example.paperfork", "1.21.4-R0.1-SNAPSHOT") | ||
} | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
// Override release for newer MC | ||
options.release = 21 | ||
} |
12 changes: 12 additions & 0 deletions
12
paper_1_21_4/src/main/java/my/plugin/hooks/paper_1_21_4/PaperHooks1_21_4.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package my.plugin.hooks.paper_1_21_4; | ||
|
||
import my.plugin.hooks.PaperHooks; | ||
import net.minecraft.SharedConstants; | ||
import org.slf4j.Logger; | ||
|
||
public class PaperHooks1_21_4 implements PaperHooks { | ||
@Override | ||
public void doSomething(final Logger logger) { | ||
logger.info(SharedConstants.getCurrentVersion().getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
`my-conventions` | ||
} | ||
|
||
dependencies { | ||
compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package my.plugin.hooks; | ||
|
||
import java.lang.reflect.Method; | ||
import org.bukkit.Bukkit; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.slf4j.Logger; | ||
|
||
public interface PaperHooks { | ||
void doSomething(Logger logger); | ||
|
||
static PaperHooks get() { | ||
return Holder.INSTANCE; | ||
} | ||
|
||
final class Holder { | ||
private static final PaperHooks INSTANCE; | ||
|
||
static { | ||
final PaperHooks hooks; | ||
String minecraftVersion = minecraftVersionFromServerBuildInfo(); | ||
if (minecraftVersion == null) { | ||
minecraftVersion = Bukkit.getServer().getMinecraftVersion(); | ||
} | ||
// You probably want to do something smarter here | ||
try { | ||
final String underscored = minecraftVersion.replace(".", "_"); | ||
hooks = (PaperHooks) Class.forName("my.plugin.hooks.paper_" + underscored + ".PaperHooks" + underscored).getDeclaredConstructors()[0].newInstance(); | ||
} catch (final ReflectiveOperationException e) { | ||
throw new RuntimeException("Could not create PaperHooks for " + minecraftVersion, e); | ||
} | ||
INSTANCE = hooks; | ||
} | ||
|
||
// For bootstrap-time compatibility on applicable versions | ||
private static @Nullable String minecraftVersionFromServerBuildInfo() { | ||
try { | ||
final Class<?> cls = Class.forName("io.papermc.paper.ServerBuildInfo"); | ||
final Method method = cls.getMethod("minecraftVersionId"); | ||
final Object instance = cls.getMethod("buildInfo").invoke(null); | ||
return (String) method.invoke(instance); | ||
} catch (final Throwable e) { | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
src/main/java/io/papermc/paperweight/testplugin/PluginBrigadierCommand.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.