From 9c6c1f6f806dd08efb1a2207188c5837e789cf39 Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Sun, 13 Oct 2024 09:37:40 -0700 Subject: [PATCH] chore: update gradle script --- build.gradle | 113 ------------------ build.gradle.kts | 105 ++++++++++++++++ settings.gradle | 1 - settings.gradle.kts | 1 + .../SlimefunTranslation.java | 8 +- 5 files changed, 112 insertions(+), 116 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 524ce80ae..000000000 --- a/build.gradle +++ /dev/null @@ -1,113 +0,0 @@ -plugins { - id 'java' - id 'maven-publish' - id 'com.github.johnrengelman.shadow' version '8.1.1' - id 'io.freefair.lombok' version '8.7.1' - id 'net.minecrell.plugin-yml.bukkit' version '0.6.0' -} - -repositories { - mavenLocal() - mavenCentral() - - maven { - url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') - } - - maven { - url = uri('https://s01.oss.sonatype.org/content/repositories/snapshots/') - } - - maven { - url = uri('https://jitpack.io') - } - - maven { - url = uri('https://repo.dmulloy2.net/repository/public/') - } - - maven { - url = uri('https://repo.extendedclip.com/content/repositories/placeholderapi/') - } -} - -dependencies { - compileOnly 'org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT' - compileOnly 'com.github.Slimefun:Slimefun4:da9c2ac4cc' - implementation 'net.guizhanss:GuizhanLib-api:1.7.6' - implementation 'org.bstats:bstats-bukkit:3.0.2' - compileOnly 'me.clip:placeholderapi:2.11.6' - compileOnly 'com.comphenix.protocol:ProtocolLib:5.1.0' -} - -group = 'net.guizhanss' -version = 'UNOFFICIAL' -description = 'SlimefunTranslation' - -java { - sourceCompatibility = JavaVersion.VERSION_16 -} - -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' -} - -tasks.withType(Javadoc) { - options.encoding = 'UTF-8' -} - -shadowJar { - relocate 'org.bstats', 'net.guizhanss.slimefuntranslation.libs.bstats' - relocate 'net.guizhanss.guizhanlib', 'net.guizhanss.slimefuntranslation.libs.guizhanlib' - minimize() - archiveClassifier = '' -} - -bukkit { - main = 'net.guizhanss.slimefuntranslation.SlimefunTranslation' - apiVersion = '1.16' - authors = ['ybw0014'] - description = 'A Slimefun Addon that translates items without actually modifying the items.' - depend = ['Slimefun', 'ProtocolLib', 'PlaceholderAPI'] - softDepend = ['GuizhanLibPlugin'] - - commands { - sftranslation { - description = 'SlimefunTranslation command' - aliases = ['slimefuntranslation', 'sft', 'sftr', 'sftransl'] - } - } - - permissions { - 'sftranslation.command.id' { - description = 'Get the ID of the Slimefun item in your main hand' - setDefault('TRUE') - } - 'sftranslation.command.search' { - description = 'Search for a Slimefun item with your current language' - setDefault('TRUE') - } - 'sftranslation.command.translation.extract' { - description = 'Extract the translation files to the "translations" folder' - setDefault('OP') - } - 'sftranslation.command.translation.generate' { - description = 'Generate a translation file based on the given addon and language.' - setDefault('OP') - } - 'sftranslation.command.translation.reload' { - description = 'Reload the translation files.' - setDefault('OP') - } - } -} - -afterEvaluate { - publishing { - publications { - mavenJava(MavenPublication) { - from components.java - } - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..2e8aaf78a --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,105 @@ +import net.minecrell.pluginyml.bukkit.BukkitPluginDescription + +plugins { + id("java") + id("maven-publish") + id("com.gradleup.shadow") version "8.3.2" + id("io.freefair.lombok") version "8.7.1" + id("net.minecrell.plugin-yml.bukkit") version "0.6.0" + id("xyz.jpenilla.run-paper") version "2.3.1" +} + +group = "net.guizhanss" +version = "UNOFFICIAL" +description = "SlimefunTranslation" + +val mainPackage = "net.guizhanss.slimefuntranslation" + +repositories { + mavenCentral() + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") + maven("https://jitpack.io") + maven("https://repo.dmulloy2.net/repository/public/") + maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") +} + +dependencies { + compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT") + compileOnly("com.github.Slimefun:Slimefun4:RC-37") + compileOnly("me.clip:placeholderapi:2.11.6") + compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0") + implementation("net.guizhanss:guizhanlib-all:2.1.0") + implementation("org.bstats:bstats-bukkit:3.1.0") +} + +java { + sourceCompatibility = JavaVersion.VERSION_16 +} + +tasks.compileJava { + options.encoding = "UTF-8" +} + +tasks.javadoc { + options.encoding = "UTF-8" +} + +tasks.shadowJar { + fun doRelocate(from: String) { + val last = from.split(".").last() + relocate(from, "$mainPackage.libs.$last") + } + + doRelocate("net.guizhanss.guizhanlib") + doRelocate("org.bstats") + minimize() + archiveClassifier = "" +} + +bukkit { + main = "net.guizhanss.slimefuntranslation.SlimefunTranslation" + apiVersion = "1.16" + authors = listOf("ybw0014") + description = "A Slimefun Addon that translates items without actually modifying the items." + depend = listOf("Slimefun", "ProtocolLib", "PlaceholderAPI") + softDepend = listOf("GuizhanLibPlugin") + + commands { + register("sftranslation") { + description = "SlimefunTranslation command" + aliases = listOf("slimefuntranslation", "sft", "sftr", "sftransl") + } + } + + permissions { + register("sftranslation.command.id") { + description = "Get the ID of the Slimefun item in your main hand" + default = BukkitPluginDescription.Permission.Default.TRUE + } + register("sftranslation.command.search") { + description = "Search for a Slimefun item with your current language" + default = BukkitPluginDescription.Permission.Default.TRUE + } + register("sftranslation.command.translation.extract") { + description = "Extract the translation files to the \"translations\" folder" + default = BukkitPluginDescription.Permission.Default.OP + } + register("sftranslation.command.translation.generate") { + description = "Generate a translation file based on the given addon and language." + default = BukkitPluginDescription.Permission.Default.OP + } + register("sftranslation.command.translation.reload") { + description = "Reload the translation files." + default = BukkitPluginDescription.Permission.Default.OP + } + } +} + +publishing { + publications { + create("maven") { + from(components["java"]) + } + } +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index a24eb363b..000000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'SlimefunTranslation' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..a4b13fa2c --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "SlimefunTranslation" diff --git a/src/main/java/net/guizhanss/slimefuntranslation/SlimefunTranslation.java b/src/main/java/net/guizhanss/slimefuntranslation/SlimefunTranslation.java index 9c4f29f3c..8ca1367eb 100644 --- a/src/main/java/net/guizhanss/slimefuntranslation/SlimefunTranslation.java +++ b/src/main/java/net/guizhanss/slimefuntranslation/SlimefunTranslation.java @@ -129,12 +129,16 @@ protected void autoUpdate() { } else if (getPluginVersion().startsWith("Build")) { try { // use updater in lib plugin - Class clazz = Class.forName("net.guizhanss.guizhanlibplugin.updater.GuizhanUpdater"); + char[] pluginPackage = { + 'n', 'e', 't', '.', 'g', 'u', 'i', 'z', 'h', 'a', 'n', 's', 's', '.', + 'g', 'u', 'i', 'z', 'h', 'a', 'n', 'l', 'i', 'b', 'p', 'l', 'u', 'g', 'i', 'n' + }; + Class clazz = Class.forName(new String(pluginPackage) + ".updater.GuizhanUpdater"); Method updaterStart = clazz.getDeclaredMethod("start", Plugin.class, File.class, String.class, String.class, String.class); updaterStart.invoke(null, this, getFile(), getGithubUser(), getGithubRepo(), getGithubBranch()); } catch (Exception ignored) { // use updater in lib - new GuizhanBuildsUpdater(this, getFile(), getGithubUser(), getGithubRepo(), getGithubBranch()).start(); + GuizhanBuildsUpdater.start(this, getFile(), getGithubUser(), getGithubRepo(), getGithubBranch()); } } }