From 3ead2fa832ec31da0da09ca6e64b27c423e3e64e Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Tue, 28 Nov 2023 09:51:32 +0100 Subject: [PATCH] add bstats and add spotless to build-logic --- build-logic/build.gradle.kts | 23 ++++++++++++++++++- .../main/kotlin/common-conventions.gradle.kts | 6 ++++- build-logic/src/main/kotlin/ext.kt | 2 ++ .../main/kotlin/paper-conventions.gradle.kts | 5 ---- gradle/libs.versions.toml | 2 ++ paper/build.gradle.kts | 1 + .../mizule/timetriggeredperms/paper/TTP.kt | 3 +++ 7 files changed, 35 insertions(+), 7 deletions(-) diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 4c51167..9a0234a 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -1,5 +1,8 @@ +import com.diffplug.gradle.spotless.FormatExtension + plugins { `kotlin-dsl` + alias(libs.plugins.spotless) } repositories { @@ -35,4 +38,22 @@ kotlin { } } } -} \ No newline at end of file +} + +spotless { + fun FormatExtension.applyCommon() { + trimTrailingWhitespace() + endWithNewline() + encoding("UTF-8") + toggleOffOn() + target("*.gradle.kts") + } + kotlinGradle { + applyCommon() + ktlint("1.0.1") + } + kotlin { + applyCommon() + ktlint("1.0.1") + } +} diff --git a/build-logic/src/main/kotlin/common-conventions.gradle.kts b/build-logic/src/main/kotlin/common-conventions.gradle.kts index db80155..7d8e174 100644 --- a/build-logic/src/main/kotlin/common-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/common-conventions.gradle.kts @@ -1,7 +1,8 @@ import com.diffplug.gradle.spotless.FormatExtension import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer import net.kyori.indra.licenser.spotless.HeaderFormat -import java.util.* +import java.util.Calendar +import java.util.Date plugins { id("base-conventions") @@ -90,6 +91,9 @@ tasks { archiveClassifier.set("") mergeServiceFiles() transform(Log4j2PluginsCacheFileTransformer::class.java) + + relocate("xyz.jpenilla.gremlin", "dev.mizule.timetriggeredperms.lib.xyz.jpenilla.gremlin") + relocate("org.bstats", "dev.mizule.timetriggeredperms.lib.org.bstats") } withType().configureEach { diff --git a/build-logic/src/main/kotlin/ext.kt b/build-logic/src/main/kotlin/ext.kt index 6a76823..457c4d7 100644 --- a/build-logic/src/main/kotlin/ext.kt +++ b/build-logic/src/main/kotlin/ext.kt @@ -1,3 +1,5 @@ +@file:Suppress("ktlint") + import net.kyori.indra.git.IndraGitExtension import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.api.Project diff --git a/build-logic/src/main/kotlin/paper-conventions.gradle.kts b/build-logic/src/main/kotlin/paper-conventions.gradle.kts index 60b64ea..a052dad 100644 --- a/build-logic/src/main/kotlin/paper-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/paper-conventions.gradle.kts @@ -25,11 +25,6 @@ tasks { named("clean", Delete::class) { delete(project.projectDir.resolve("run")) } - - - shadowJar { - relocate("xyz.jpenilla.gremlin", "dev.mizule.timetriggeredperms.lib.xyz.jpenilla.gremlin") - } } hangarPublish { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index eaa64ed..5550662 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,7 @@ hangar-publish = { module = "io.papermc:hangar-publish-plugin", version.ref = "h [plugins] gremlin-gradle = { id = "xyz.jpenilla.gremlin-gradle", version.ref = "gremlin" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } [versions] indra = "3.1.3" @@ -26,3 +27,4 @@ gremlin = "0.0.3" idea-gradle = "1.1.7" run-task = "2.2.2" hangar-publish = "0.1.0" +spotless = "6.23.0" diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index 9c91348..c33138a 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -27,6 +27,7 @@ dependencies { runtimeDownloadOnlyApi(kotlin("reflect")) runtimeDownloadOnlyApi("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") runtimeDownloadOnlyApi("org.spongepowered:configurate-extra-kotlin:4.2.0-SNAPSHOT") + implementation("org.bstats:bstats-bukkit:3.0.2") } applyJarMetadata("timetriggeredperms-paper") diff --git a/paper/src/main/kotlin/dev/mizule/timetriggeredperms/paper/TTP.kt b/paper/src/main/kotlin/dev/mizule/timetriggeredperms/paper/TTP.kt index d811626..a24c659 100644 --- a/paper/src/main/kotlin/dev/mizule/timetriggeredperms/paper/TTP.kt +++ b/paper/src/main/kotlin/dev/mizule/timetriggeredperms/paper/TTP.kt @@ -28,6 +28,7 @@ import dev.mizule.timetriggeredperms.core.TTPPlugin import dev.mizule.timetriggeredperms.core.config.Config import dev.mizule.timetriggeredperms.paper.command.ReloadCommand import dev.mizule.timetriggeredperms.paper.listener.LuckPermsListener +import org.bstats.bukkit.Metrics import org.bukkit.Bukkit import org.bukkit.plugin.java.JavaPlugin import org.spongepowered.configurate.kotlin.extensions.get @@ -38,6 +39,7 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader class TTP : JavaPlugin(), TTPPlugin { private val configPath = dataFolder.resolve("permissions.yml") + private val pluginId = 20404 val configLoader = YamlConfigurationLoader.builder() .file(configPath) @@ -61,6 +63,7 @@ class TTP : JavaPlugin(), TTPPlugin { configNode.set(config) // update the backing node to add defaults configLoader.save(configNode) } + Metrics(this, pluginId) LuckPermsListener(this) Bukkit.getCommandMap().register("timetriggeredperms", ReloadCommand(this))