From 12cdb5ad7820eab806cdd1eb7f44072ccec19b3c Mon Sep 17 00:00:00 2001 From: Daniel Orr Date: Tue, 5 Nov 2024 17:03:49 +0000 Subject: [PATCH] feat: plugin.yml for plugins --- gradle.properties | 2 +- paper/build.gradle.kts | 14 ++++++++++++++ .../net/mcbrawls/inject/paper/InjectPaper.java | 3 ++- paper/src/main/resources/plugin.yml | 3 +++ spigot/build.gradle.kts | 14 ++++++++++++++ .../net/mcbrawls/inject/spigot/InjectSpigot.java | 5 +++-- spigot/src/main/resources/plugin.yml | 3 +++ 7 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 paper/src/main/resources/plugin.yml create mode 100644 spigot/src/main/resources/plugin.yml diff --git a/gradle.properties b/gradle.properties index 453031c..f8e14a9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,6 @@ yarn_mappings=1.21.1+build.3 loader_version=0.16.7 # Mod Properties -version=2.2.0 +version=2.2.1 group=net.mcbrawls.inject id=inject diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index 3f10ddf..68545b3 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -7,6 +7,8 @@ plugins { fun prop(name: String) = project.rootProject.property(name) as String +val isPublishing = gradle.startParameter.taskNames.any { it.contains("publish") } + group = prop("group") version = prop("version") @@ -71,6 +73,18 @@ tasks { } } +tasks.processResources { + inputs.property("version", project.version) + + filesMatching("plugin.yml") { + if (isPublishing) { + exclude() + } else { + expand("version" to project.version) + } + } +} + runPaper { disablePluginJarDetection() } diff --git a/paper/src/main/java/net/mcbrawls/inject/paper/InjectPaper.java b/paper/src/main/java/net/mcbrawls/inject/paper/InjectPaper.java index 4b43422..a7c29d3 100644 --- a/paper/src/main/java/net/mcbrawls/inject/paper/InjectPaper.java +++ b/paper/src/main/java/net/mcbrawls/inject/paper/InjectPaper.java @@ -4,13 +4,14 @@ import net.kyori.adventure.key.Key; import net.mcbrawls.inject.api.InjectPlatform; import net.mcbrawls.inject.api.Injector; +import org.bukkit.plugin.java.JavaPlugin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; -public class InjectPaper implements InjectPlatform { +public class InjectPaper extends JavaPlugin implements InjectPlatform { private static final Logger LOGGER = LoggerFactory.getLogger("inject"); public static InjectPaper INSTANCE = new InjectPaper(); private static final List injectors = new ArrayList<>(); diff --git a/paper/src/main/resources/plugin.yml b/paper/src/main/resources/plugin.yml new file mode 100644 index 0000000..0b79df5 --- /dev/null +++ b/paper/src/main/resources/plugin.yml @@ -0,0 +1,3 @@ +name: Inject +main: net.mcbrawls.inject.paper.InjectPaper +version: ${version} diff --git a/spigot/build.gradle.kts b/spigot/build.gradle.kts index 879f6df..6ec97a7 100644 --- a/spigot/build.gradle.kts +++ b/spigot/build.gradle.kts @@ -8,6 +8,8 @@ plugins { fun prop(name: String) = project.rootProject.property(name) as String +val isPublishing = gradle.startParameter.taskNames.any { it.contains("publish") } + group = prop("group") version = prop("version") @@ -61,6 +63,18 @@ tasks { } } +tasks.processResources { + inputs.property("version", project.version) + + filesMatching("plugin.yml") { + if (isPublishing) { + exclude() + } else { + expand("version" to project.version) + } + } +} + publishing { publications { create("mavenJava") { diff --git a/spigot/src/main/java/net/mcbrawls/inject/spigot/InjectSpigot.java b/spigot/src/main/java/net/mcbrawls/inject/spigot/InjectSpigot.java index 324ff9a..d7ae36c 100644 --- a/spigot/src/main/java/net/mcbrawls/inject/spigot/InjectSpigot.java +++ b/spigot/src/main/java/net/mcbrawls/inject/spigot/InjectSpigot.java @@ -3,12 +3,13 @@ import net.mcbrawls.inject.api.InjectPlatform; import net.mcbrawls.inject.api.Injector; import net.mcbrawls.inject.spigot.interceptor.ClientConnectionInterceptor; +import org.bukkit.plugin.java.JavaPlugin; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; -public class InjectSpigot implements InjectPlatform { +public class InjectSpigot extends JavaPlugin implements InjectPlatform { private static final Logger LOGGER = Logger.getLogger("inject"); public static InjectSpigot INSTANCE = new InjectSpigot(); private static final List injectors = new ArrayList<>(); @@ -45,4 +46,4 @@ public void registerInjector(Injector injector) { LOGGER.info("Inject initialized"); } } -} \ No newline at end of file +} diff --git a/spigot/src/main/resources/plugin.yml b/spigot/src/main/resources/plugin.yml new file mode 100644 index 0000000..f10b381 --- /dev/null +++ b/spigot/src/main/resources/plugin.yml @@ -0,0 +1,3 @@ +name: Inject +main: net.mcbrawls.inject.spigot.InjectSpigot +version: ${version}