diff --git a/.github/workflows/build-commit.yml b/.github/workflows/build-commit.yml index 427b577..191d9c4 100644 --- a/.github/workflows/build-commit.yml +++ b/.github/workflows/build-commit.yml @@ -5,7 +5,7 @@ name: build-commit on: push: paths-ignore: - - "readme.md" + - "README.md" - "LICENSE" - ".gitignore" - "changelog.md" @@ -13,7 +13,7 @@ on: - "src/*/resources/lang/*" pull_request: paths-ignore: - - "readme.md" + - "README.md" - "LICENSE" - ".gitignore" - "changelog.md" @@ -38,7 +38,17 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Build with Gradle - run: ./gradlew :telekinesis-fabric:buildAllVersions --stacktrace + run: ./gradlew buildAllVersions --stacktrace - uses: actions/upload-artifact@v4 with: path: versions/**/build/libs/*.jar + + modrinth-description: + runs-on: ubuntu-latest + name: Sync Modrinth description + steps: + - uses: actions/checkout@v4 + - uses: funnyboy-roks/modrinth-auto-desc@v1.6 + with: + auth-token: ${{ secrets.MODRINTH_API_KEY }} + slug: 'skylper' \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7d66a8..022f825 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Release with Gradle - run: ./gradlew :telekinesis-fabric:releaseAllVersions --stacktrace + run: ./gradlew releaseAllVersions postUpdate --stacktrace env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }} @@ -31,3 +31,13 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SECRET_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SECRET_KEY_PASSWORD }} GPG_SECRET_KEY_ID: ${{ secrets.GPG_SECRET_KEY_ID }} + + modrinth-description: + runs-on: ubuntu-latest + name: Sync Modrinth description + steps: + - uses: actions/checkout@v4 + - uses: funnyboy-roks/modrinth-auto-desc@v1.6 + with: + auth-token: ${{ secrets.MODRINTH_API_KEY }} + slug: 'skylper' \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index e89c20e..479c7c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,17 +1,203 @@ +@file:Suppress("SpellCheckingInspection", "SENSELESS_COMPARISON") + +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + plugins { kotlin("jvm") version "2.0.0" kotlin("plugin.serialization") version "2.0.0" + id("fabric-loom") version "1.7-SNAPSHOT" id("me.modmuss50.mod-publish-plugin") version "0.5.+" - id("fabric-loom") version "1.7-SNAPSHOT" apply (false) - - id("io.papermc.paperweight.userdev") version "1.5.5" apply (false) - `maven-publish` signing } +val beta: Int = 1 // Pattern is '1.0.0-beta1-1.20.6-pre.2' +val featureVersion = "1.0.0${if (beta != null) "-beta$beta" else ""}" +val mcVersion = property("mcVersion")!!.toString() +val mcVersionRange = property("mcVersionRange")!!.toString() +version = "$featureVersion-$mcVersion" + +group = "dev.nyon" +val projectAuthors = listOf("btwonion") +val githubRepo = "btwonion/telekinesis" + +base { + archivesName.set(rootProject.name) +} + +loom { + if (stonecutter.current.isActive) { + runConfigs.all { + ideConfigGenerated(true) + runDir("../../run") + } + } + + mixin { useLegacyMixinAp = false } +} + +// Enable data generation for >1.20.6 +if (!listOf("1.20.1", "1.20.4", "1.20.6").contains(stonecutter.current.version)) { + fabricApi { + configureDataGeneration() + } +} + repositories { mavenCentral() + exclusiveContent { + forRepository { + maven("https://api.modrinth.com/maven") + } + filter { + includeGroup("maven.modrinth") + } + } + maven("https://maven.terraformersmc.com") + maven("https://maven.parchmentmc.org") + maven("https://repo.nyon.dev/releases") + maven("https://maven.isxander.dev/releases") + maven("https://maven.isxander.dev/snapshots") + maven("https://jitpack.io") +} + +dependencies { + minecraft("com.mojang:minecraft:$mcVersion") + mappings(loom.layered { + val parchment: String = property("deps.parchment").toString() + if (parchment.isNotEmpty()) parchment("org.parchmentmc.data:parchment-$parchment@zip") + officialMojangMappings() + }) + + implementation("org.vineflower:vineflower:1.10.1") + modImplementation("net.fabricmc:fabric-loader:0.15.11") + modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")!!}") + modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0") + + modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")!!}") + modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")!!}") + + include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.1.1")!!)!!) + + include(modImplementation("dev.nyon:konfig:2.0.1-1.20.4")!!) +} + +val javaVersion = property("javaVer")!!.toString() +tasks { + processResources { + val modId = "telekinesis" + val modName = "telekinesis" + val modDescription = "Adds a telekinesis enchantment to minecraft" + + val props = mapOf( + "id" to modId, + "name" to modName, + "description" to modDescription, + "version" to project.version, + "github" to githubRepo, + "mc" to mcVersionRange + ) + + props.forEach(inputs::property) + + filesMatching("fabric.mod.json") { + expand(props) + } + } + + register("releaseMod") { + group = "publishing" + + dependsOn("publishMods") + dependsOn("publish") + } + + withType { + options.release = javaVersion.toInt() + } + + withType { + compilerOptions { + jvmTarget = JvmTarget.fromTarget(javaVersion) + } + } +} + +val changelogText = buildString { + append("# v${project.version}\n") + rootProject.file("changelog.md").readText().also(::append) +} + +val supportedMcVersions: List = + property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty) + +publishMods { + displayName = "v${project.version}" + file = tasks.remapJar.get().archiveFile + changelog = changelogText + type = if (beta != null) BETA else STABLE + modLoaders.addAll("fabric", "quilt") + + modrinth { + projectId = "LLfA8jAD" + accessToken = providers.environmentVariable("MODRINTH_API_KEY") + minecraftVersions.addAll(supportedMcVersions) + + requires { slug = "fabric-api" } + requires { slug = "yacl" } + requires { slug = "fabric-language-kotlin" } + optional { slug = "modmenu" } + } + + github { + repository = githubRepo + accessToken = providers.environmentVariable("GITHUB_TOKEN") + commitish = "master" + } } + +publishing { + repositories { + maven { + name = "nyon" + url = uri("https://repo.nyon.dev/releases") + credentials { + username = providers.environmentVariable("NYON_USERNAME").orNull + password = providers.environmentVariable("NYON_PASSWORD").orNull + } + } + } + publications { + create("maven") { + groupId = "dev.nyon" + artifactId = "telekinesis" + version = project.version.toString() + from(components["java"]) + } + } +} + +java { + withSourcesJar() + + javaVersion.toInt().let { JavaVersion.values()[it - 1] }.let { + sourceCompatibility = it + targetCompatibility = it + } +} + +/* +signing { + val signingKey: String? by project + val signingPassword: String? by project + useGpgCmd() + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys(signingKey, signingPassword) + } + sign(publishing.publications) +} + */ + diff --git a/settings.gradle.kts b/settings.gradle.kts index fb46c1c..128d21c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,9 +23,6 @@ buildscript { } } -//include("telekinesis-paper") -include("telekinesis-fabric") - extensions.configure { kotlinController = true centralScript = "build.gradle.kts" @@ -33,5 +30,5 @@ extensions.configure { versions("1.20.1", "1.20.4", "1.20.6", "1.21") vcsVersion = "1.21" } - create(":telekinesis-fabric") + create(rootProject) } diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java b/src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java similarity index 100% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java rename to src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt b/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt similarity index 100% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt rename to src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/Main.kt b/src/main/kotlin/dev/nyon/telekinesis/Main.kt similarity index 100% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/Main.kt rename to src/main/kotlin/dev/nyon/telekinesis/Main.kt diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt similarity index 100% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt rename to src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt similarity index 100% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt rename to src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/config/Config.kt b/src/main/kotlin/dev/nyon/telekinesis/config/Config.kt similarity index 100% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/config/Config.kt rename to src/main/kotlin/dev/nyon/telekinesis/config/Config.kt diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/config/ModMenuImpl.kt b/src/main/kotlin/dev/nyon/telekinesis/config/ModMenuImpl.kt similarity index 100% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/config/ModMenuImpl.kt rename to src/main/kotlin/dev/nyon/telekinesis/config/ModMenuImpl.kt diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt b/src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt similarity index 100% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt rename to src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt diff --git a/telekinesis-fabric/src/main/resources/assets/telekinesis/icon.png b/src/main/resources/assets/telekinesis/icon.png similarity index 100% rename from telekinesis-fabric/src/main/resources/assets/telekinesis/icon.png rename to src/main/resources/assets/telekinesis/icon.png diff --git a/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/de_de.json b/src/main/resources/assets/telekinesis/lang/de_de.json similarity index 100% rename from telekinesis-fabric/src/main/resources/assets/telekinesis/lang/de_de.json rename to src/main/resources/assets/telekinesis/lang/de_de.json diff --git a/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/en_us.json b/src/main/resources/assets/telekinesis/lang/en_us.json similarity index 100% rename from telekinesis-fabric/src/main/resources/assets/telekinesis/lang/en_us.json rename to src/main/resources/assets/telekinesis/lang/en_us.json diff --git a/telekinesis-fabric/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json similarity index 100% rename from telekinesis-fabric/src/main/resources/fabric.mod.json rename to src/main/resources/fabric.mod.json diff --git a/telekinesis-fabric/src/main/resources/telekinesis.mixins.json b/src/main/resources/telekinesis.mixins.json similarity index 100% rename from telekinesis-fabric/src/main/resources/telekinesis.mixins.json rename to src/main/resources/telekinesis.mixins.json diff --git a/telekinesis-fabric/stonecutter.gradle.kts b/stonecutter.gradle.kts similarity index 100% rename from telekinesis-fabric/stonecutter.gradle.kts rename to stonecutter.gradle.kts diff --git a/telekinesis-fabric/build.gradle.kts b/telekinesis-fabric/build.gradle.kts deleted file mode 100644 index 479c7c8..0000000 --- a/telekinesis-fabric/build.gradle.kts +++ /dev/null @@ -1,203 +0,0 @@ -@file:Suppress("SpellCheckingInspection", "SENSELESS_COMPARISON") - -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - kotlin("jvm") version "2.0.0" - kotlin("plugin.serialization") version "2.0.0" - id("fabric-loom") version "1.7-SNAPSHOT" - - id("me.modmuss50.mod-publish-plugin") version "0.5.+" - - `maven-publish` - signing -} - -val beta: Int = 1 // Pattern is '1.0.0-beta1-1.20.6-pre.2' -val featureVersion = "1.0.0${if (beta != null) "-beta$beta" else ""}" -val mcVersion = property("mcVersion")!!.toString() -val mcVersionRange = property("mcVersionRange")!!.toString() -version = "$featureVersion-$mcVersion" - -group = "dev.nyon" -val projectAuthors = listOf("btwonion") -val githubRepo = "btwonion/telekinesis" - -base { - archivesName.set(rootProject.name) -} - -loom { - if (stonecutter.current.isActive) { - runConfigs.all { - ideConfigGenerated(true) - runDir("../../run") - } - } - - mixin { useLegacyMixinAp = false } -} - -// Enable data generation for >1.20.6 -if (!listOf("1.20.1", "1.20.4", "1.20.6").contains(stonecutter.current.version)) { - fabricApi { - configureDataGeneration() - } -} - -repositories { - mavenCentral() - exclusiveContent { - forRepository { - maven("https://api.modrinth.com/maven") - } - filter { - includeGroup("maven.modrinth") - } - } - maven("https://maven.terraformersmc.com") - maven("https://maven.parchmentmc.org") - maven("https://repo.nyon.dev/releases") - maven("https://maven.isxander.dev/releases") - maven("https://maven.isxander.dev/snapshots") - maven("https://jitpack.io") -} - -dependencies { - minecraft("com.mojang:minecraft:$mcVersion") - mappings(loom.layered { - val parchment: String = property("deps.parchment").toString() - if (parchment.isNotEmpty()) parchment("org.parchmentmc.data:parchment-$parchment@zip") - officialMojangMappings() - }) - - implementation("org.vineflower:vineflower:1.10.1") - modImplementation("net.fabricmc:fabric-loader:0.15.11") - modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")!!}") - modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0") - - modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")!!}") - modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")!!}") - - include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.1.1")!!)!!) - - include(modImplementation("dev.nyon:konfig:2.0.1-1.20.4")!!) -} - -val javaVersion = property("javaVer")!!.toString() -tasks { - processResources { - val modId = "telekinesis" - val modName = "telekinesis" - val modDescription = "Adds a telekinesis enchantment to minecraft" - - val props = mapOf( - "id" to modId, - "name" to modName, - "description" to modDescription, - "version" to project.version, - "github" to githubRepo, - "mc" to mcVersionRange - ) - - props.forEach(inputs::property) - - filesMatching("fabric.mod.json") { - expand(props) - } - } - - register("releaseMod") { - group = "publishing" - - dependsOn("publishMods") - dependsOn("publish") - } - - withType { - options.release = javaVersion.toInt() - } - - withType { - compilerOptions { - jvmTarget = JvmTarget.fromTarget(javaVersion) - } - } -} - -val changelogText = buildString { - append("# v${project.version}\n") - rootProject.file("changelog.md").readText().also(::append) -} - -val supportedMcVersions: List = - property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty) - -publishMods { - displayName = "v${project.version}" - file = tasks.remapJar.get().archiveFile - changelog = changelogText - type = if (beta != null) BETA else STABLE - modLoaders.addAll("fabric", "quilt") - - modrinth { - projectId = "LLfA8jAD" - accessToken = providers.environmentVariable("MODRINTH_API_KEY") - minecraftVersions.addAll(supportedMcVersions) - - requires { slug = "fabric-api" } - requires { slug = "yacl" } - requires { slug = "fabric-language-kotlin" } - optional { slug = "modmenu" } - } - - github { - repository = githubRepo - accessToken = providers.environmentVariable("GITHUB_TOKEN") - commitish = "master" - } -} - -publishing { - repositories { - maven { - name = "nyon" - url = uri("https://repo.nyon.dev/releases") - credentials { - username = providers.environmentVariable("NYON_USERNAME").orNull - password = providers.environmentVariable("NYON_PASSWORD").orNull - } - } - } - publications { - create("maven") { - groupId = "dev.nyon" - artifactId = "telekinesis" - version = project.version.toString() - from(components["java"]) - } - } -} - -java { - withSourcesJar() - - javaVersion.toInt().let { JavaVersion.values()[it - 1] }.let { - sourceCompatibility = it - targetCompatibility = it - } -} - -/* -signing { - val signingKey: String? by project - val signingPassword: String? by project - useGpgCmd() - if (signingKey != null && signingPassword != null) { - useInMemoryPgpKeys(signingKey, signingPassword) - } - sign(publishing.publications) -} - */ - diff --git a/telekinesis-paper/build.gradle.kts b/telekinesis-paper/build.gradle.kts deleted file mode 100644 index ae1fb0a..0000000 --- a/telekinesis-paper/build.gradle.kts +++ /dev/null @@ -1,142 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.nio.file.Path -import kotlin.io.path.notExists -import kotlin.io.path.readText - -plugins { - kotlin("jvm") - kotlin("plugin.serialization") - - id("com.modrinth.minotaur") - id("com.github.breadmoirai.github-release") - - id("io.papermc.paperweight.userdev") - id("xyz.jpenilla.run-paper") version "2.1.0" - - `maven-publish` - signing -} - -group = "dev.nyon" -val majorVersion = "2.3.2" -val mcVersion = "1.20.2" -version = "$majorVersion-$mcVersion" -description = "Adds an telekinesis enchantment to minecraft" -val projectAuthors = listOf("btwonion") -val githubRepo = "btwonion/telekinesis" - -repositories { - mavenCentral() -} - -dependencies { - paperweight.paperDevBundle("$mcVersion-R0.1-SNAPSHOT") - implementation("com.akuleshov7:ktoml-core-jvm:0.5.0") -} - -tasks { - register("releasePlugin") { - group = "publishing" - - dependsOn("modrinthSyncBody") - dependsOn("modrinth") - dependsOn("publish") - dependsOn("githubRelease") - } - - processResources { - val props = mapOf( - "name" to "telekinesis", - "version" to "'${project.version}'", - "main" to "dev.nyon.telekinesis.Main", - "description" to project.description, - "website" to "https://nyon.dev/discord", - "apiVersion" to "'1.20'", - "authors" to projectAuthors.joinToString("\n - ", "\n - "), - "foliaSupported" to true, - "loader" to "dev.nyon.telekinesis.PaperLoader" - ) - - inputs.properties(props) - filesMatching("paper-plugin.yml") { - expand(props) - } - } - - assemble { - dependsOn(reobfJar) - } - - withType { - options.encoding = "UTF-8" - options.release.set(17) - } - - withType { - kotlinOptions.jvmTarget = "17" - } - - runPaper.folia.registerTask() - runServer { - minecraftVersion("1.20.1") - } -} - -val changelogFile: Path = rootDir.toPath().resolve("changelogs/paper-$version.md") -val changelogText = if (changelogFile.notExists()) "" else changelogFile.readText() -val projectVersionName = "paper-${project.version}" - -modrinth { - token.set(findProperty("modrinth.token")?.toString()) - projectId.set("LLfA8jAD") - versionNumber.set(projectVersionName) - versionName.set(projectVersionName) - versionType.set("release") - uploadFile.set(tasks.reobfJar.get().outputJar) - gameVersions.set(listOf("1.20.2")) - loaders.set(listOf("paper", "folia")) - changelog.set(changelogText) - syncBodyFrom.set(file("../README.md").readText()) -} - -githubRelease { - token(findProperty("github.token")?.toString()) - - val split = githubRepo.split("/") - owner = split[0] - repo = split[1] - releaseName = projectVersionName - tagName = projectVersionName - body = changelogText - targetCommitish = "master" - setReleaseAssets(tasks.reobfJar.get().outputJar) -} - -publishing { - repositories { - maven { - name = "nyon" - url = uri("https://repo.nyon.dev/releases") - credentials(PasswordCredentials::class) - authentication { - create("basic") - } - } - } - publications { - create("maven") { - groupId = "dev.nyon" - artifactId = "telekinesis-paper" - version = project.version.toString() - from(components["java"]) - } - } -} - -signing { - sign(publishing.publications) -} - -java { - withSourcesJar() -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/java/dev/nyon/telekinesis/PaperLoader.java b/telekinesis-paper/src/main/java/dev/nyon/telekinesis/PaperLoader.java deleted file mode 100644 index a281941..0000000 --- a/telekinesis-paper/src/main/java/dev/nyon/telekinesis/PaperLoader.java +++ /dev/null @@ -1,22 +0,0 @@ -package dev.nyon.telekinesis; - -import io.papermc.paper.plugin.loader.PluginClasspathBuilder; -import io.papermc.paper.plugin.loader.PluginLoader; -import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.repository.RemoteRepository; -import org.jetbrains.annotations.NotNull; - -@SuppressWarnings("UnstableApiUsage") -public class PaperLoader implements PluginLoader { - @Override - public void classloader(@NotNull PluginClasspathBuilder classpathBuilder) { - MavenLibraryResolver resolver = new MavenLibraryResolver(); - resolver.addDependency(new Dependency(new DefaultArtifact("org.jetbrains.kotlin:kotlin-stdlib:1.9.0"), null)); - resolver.addDependency(new Dependency(new DefaultArtifact("com.akuleshov7:ktoml-core-jvm:0.5.0"), null)); - resolver.addRepository(new RemoteRepository.Builder("central", "default", "https://repo1.maven.org/maven2/").build()); - - classpathBuilder.addLibrary(resolver); - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/Main.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/Main.kt deleted file mode 100644 index 1d7e1f4..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/Main.kt +++ /dev/null @@ -1,82 +0,0 @@ -package dev.nyon.telekinesis - -import dev.nyon.telekinesis.listeners.initBlockListeners -import dev.nyon.telekinesis.listeners.initMobListeners -import net.minecraft.core.Holder -import net.minecraft.core.MappedRegistry -import net.minecraft.core.Registry -import net.minecraft.core.registries.Registries -import net.minecraft.resources.ResourceLocation -import org.bukkit.Bukkit -import org.bukkit.craftbukkit.v1_20_R2.CraftServer -import org.bukkit.enchantments.Enchantment -import org.bukkit.plugin.java.JavaPlugin -import kotlin.io.path.createFile -import kotlin.io.path.exists - -val bukkitEnchantment: Enchantment = BukkitTelekinesis() -val telekinesis = TelekinesisEnchantment() - -class Main : JavaPlugin() { - companion object { - lateinit var INSTANCE: Main; private set - } - - override fun onLoad() { - INSTANCE = this - configPath = Bukkit.getPluginsFolder().toPath().resolve("telekinesis.toml") - .also { if (!it.exists()) it.createFile() } - loadConfig() - if (dev.nyon.telekinesis.config.enchantment) { - addToBukkitRegistry() - addToMinecraftRegistry() - } - } - - override fun onEnable() { - initBlockListeners() - initMobListeners() - } -} - -private fun addToBukkitRegistry() { - val field = Enchantment::class.java.getDeclaredField("acceptingNew") - field.isAccessible = true - field.set(null, true) - Enchantment.registerEnchantment(BukkitTelekinesis()) - field.set(null, false) - field.isAccessible = true -} - -// Check the values with: https://mappings.cephx.dev/ -@Suppress("unchecked_cast") -private fun addToMinecraftRegistry() { - val server = (Bukkit.getServer() as CraftServer).server - val enchantmentRegistry = server.registryAccess().registryOrThrow(Registries.ENCHANTMENT) as MappedRegistry - val enchantmentRegistryClass = enchantmentRegistry.javaClass - val frozenField = enchantmentRegistryClass.getDeclaredField("l") // l - frozen MappedRegistry - frozenField.isAccessible = true - frozenField.set(enchantmentRegistry, false) - - Registry.register( - enchantmentRegistry, - ResourceLocation("telekinesis", "telekinesis"), - telekinesis - ) - - frozenField.set(enchantmentRegistry, true) - frozenField.isAccessible = false - - val byValueField = enchantmentRegistryClass.getDeclaredField("h") // h - byValue MappedRegistry - byValueField.isAccessible = true - val byValueMap = - byValueField.get(enchantmentRegistry) as Map<*, Holder.Reference<*>> - val value = byValueMap[telekinesis]!! - val method = value.javaClass.getDeclaredMethod("b", Any::class.java) - method.isAccessible = true - method.invoke(value, telekinesis) // b - bindValue Holder$Reference - method.isAccessible = false - byValueField.isAccessible = false -} - -val Plugin by lazy { Main.INSTANCE } \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt deleted file mode 100644 index 93a396f..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt +++ /dev/null @@ -1,75 +0,0 @@ -package dev.nyon.telekinesis - -import com.akuleshov7.ktoml.Toml -import com.akuleshov7.ktoml.TomlInputConfig -import com.akuleshov7.ktoml.annotations.TomlComments -import kotlinx.serialization.Serializable -import kotlinx.serialization.decodeFromString -import java.nio.file.Path -import kotlin.io.path.notExists -import kotlin.io.path.readText -import kotlin.io.path.writeText - -@Serializable -data class TelekinesisConfig( - @TomlComments( - "Uncomment the following values if you want to change them:", - "", - "Decides whether telekinesis can be used without the enchantment." - ) - var onByDefault: Boolean = false, - var onByDefaultPermissionRequirement: String? = null, - @TomlComments( - "Uncomment this to block functionality for those who don't have the required permission.", - "onByDefaultPermissionRequirement = 'permission'", - "", - "Decides whether players should be required to sneak to use telekinesis." - ) - var onlyOnSneak: Boolean = false, - @TomlComments( - "Decides whether telekinesis can be used for block drops." - ) - var blockDrops: Boolean = true, - var blockDropsPermissionRequirement: String? = null, - @TomlComments( - "blockDropsPermissionRequirement = 'permission'", - "", - "Decides whether telekinesis can be used for exp drops." - ) - var expDrops: Boolean = true, - var expDropsPermissionRequirement: String? = null, - @TomlComments( - "expDropsPermissionRequirement = 'permission'", - "", - "Decides whether telekinesis can be used for entity drops." - ) - var entityDrops: Boolean = true, - var entityDropsPermissionRequirement: String? = null, - @TomlComments( - "entityDropsPermissionRequirement = 'permission'", - "", - "Decides whether to add the enchantment to the game." - ) - var enchantment: Boolean = true, -) - -var config: TelekinesisConfig = TelekinesisConfig() -lateinit var configPath: Path -val toml = Toml( - inputConfig = TomlInputConfig(ignoreUnknownNames = true) -) - -fun saveConfig() = configPath.writeText(toml.encodeToString(TelekinesisConfig.serializer(), config)) - -fun loadConfig() { - if (configPath.notExists() || configPath.readText().isEmpty()) { - saveConfig() - return - } - - try { - config = toml.decodeFromString(configPath.readText()) - } catch (e: Exception) { - saveConfig() - } -} diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt deleted file mode 100644 index 3d4b664..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt +++ /dev/null @@ -1,72 +0,0 @@ -package dev.nyon.telekinesis - -import io.papermc.paper.enchantments.EnchantmentRarity -import net.kyori.adventure.text.format.TextColor -import net.minecraft.network.chat.Component -import net.minecraft.network.chat.Style -import net.minecraft.world.damagesource.DamageSource -import net.minecraft.world.entity.EquipmentSlot -import net.minecraft.world.entity.MobType -import net.minecraft.world.item.enchantment.Enchantment -import net.minecraft.world.item.enchantment.EnchantmentCategory -import org.bukkit.NamespacedKey -import org.bukkit.enchantments.EnchantmentTarget -import org.bukkit.entity.EntityCategory -import org.bukkit.inventory.ItemStack - -/** - * The telekinesis enchantment model - */ -class TelekinesisEnchantment : Enchantment( - Rarity.RARE, EnchantmentCategory.BREAKABLE, listOf(EquipmentSlot.OFFHAND, EquipmentSlot.MAINHAND).toTypedArray() -) { - - override fun getMinLevel(): Int = 1 - override fun getMaxLevel(): Int = 1 - - override fun getMinCost(i: Int): Int = 30 - override fun getMaxCost(i: Int): Int = 30 - - override fun getDamageProtection(i: Int, damageSource: DamageSource): Int = 0 - override fun getDamageBonus(i: Int, mobType: MobType): Float = 0F - - override fun getFullname(i: Int): Component = - Component.literal("Telekinesis").withStyle(Style.EMPTY.withColor(0xFFB64C)) -} - -class BukkitTelekinesis : org.bukkit.enchantments.Enchantment(NamespacedKey("telekinesis", "telekinesis")) { - override fun translationKey(): String = "telekinesis.telekinesis" - - @Deprecated("Deprecated in Java", ReplaceWith("\"Telekinesis\"")) - override fun getName(): String = "Telekinesis" - - override fun getMaxLevel(): Int = 1 - - override fun getStartLevel(): Int = 1 - - override fun getItemTarget(): EnchantmentTarget = EnchantmentTarget.BREAKABLE - - override fun isTreasure(): Boolean = false - - override fun isCursed(): Boolean = false - - override fun conflictsWith(other: org.bukkit.enchantments.Enchantment): Boolean = false - - override fun canEnchantItem(item: ItemStack): Boolean = true - - override fun displayName(level: Int): net.kyori.adventure.text.Component = - net.kyori.adventure.text.Component.text("Telekinesis").color( - TextColor.color(0xFFB64C) - ) - - override fun isTradeable(): Boolean = true - - override fun isDiscoverable(): Boolean = true - - override fun getRarity(): EnchantmentRarity = EnchantmentRarity.RARE - - override fun getDamageIncrease(level: Int, entityCategory: EntityCategory): Float = 0.0f - - override fun getActiveSlots(): MutableSet = - mutableSetOf(org.bukkit.inventory.EquipmentSlot.OFF_HAND, org.bukkit.inventory.EquipmentSlot.HAND) -} diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt deleted file mode 100644 index ff4b071..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.nyon.telekinesis - -enum class TelekinesisPolicy { - BlockDrops, - ExpDrops, - EntityDrops; - - fun isEnabled(): Boolean = when (this) { - BlockDrops -> config.blockDrops - ExpDrops -> config.expDrops - EntityDrops -> config.entityDrops - } - - fun associatedPermission(): String? = when (this) { - BlockDrops -> config.blockDropsPermissionRequirement - ExpDrops -> config.expDropsPermissionRequirement - EntityDrops -> config.entityDropsPermissionRequirement - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/BlockListeners.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/BlockListeners.kt deleted file mode 100644 index 50031a0..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/BlockListeners.kt +++ /dev/null @@ -1,30 +0,0 @@ -package dev.nyon.telekinesis.listeners - -import dev.nyon.telekinesis.TelekinesisPolicy -import dev.nyon.telekinesis.util.handleTelekinesis -import dev.nyon.telekinesis.util.listen -import org.bukkit.event.block.BlockBreakEvent -import org.bukkit.event.block.BlockDropItemEvent - -fun initBlockListeners() { - dropEvent - blockBreakEvent -} - -val dropEvent = listen { - player.handleTelekinesis(TelekinesisPolicy.BlockDrops, player.inventory.itemInMainHand) { - val copy = mutableListOf(items).flatten() - items.clear() - copy.forEach { - val result = inventory.addItem(it.itemStack) - if (result.isNotEmpty()) items.add(it) - } - } -} - -val blockBreakEvent = listen { - player.handleTelekinesis(TelekinesisPolicy.ExpDrops, null) { - giveExp(expToDrop) - expToDrop = 0 - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/MobListeners.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/MobListeners.kt deleted file mode 100644 index 590dfc2..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/MobListeners.kt +++ /dev/null @@ -1,34 +0,0 @@ -package dev.nyon.telekinesis.listeners - -import dev.nyon.telekinesis.TelekinesisPolicy -import dev.nyon.telekinesis.util.handleTelekinesis -import dev.nyon.telekinesis.util.listen -import org.bukkit.event.entity.EntityDeathEvent - -fun initMobListeners() { - mobDie - mobExpDie -} - -val mobDie = listen { - println(entityType.name) - val killer = this.entity.killer ?: return@listen - - killer.handleTelekinesis(TelekinesisPolicy.EntityDrops, null) { - val copy = mutableListOf(drops).flatten() - drops.clear() - copy.forEach { - val result = inventory.addItem(it) - if (result.isNotEmpty()) drops.add(it) - } - } -} - -val mobExpDie = listen { - val killer = this.entity.killer ?: return@listen - - killer.handleTelekinesis(TelekinesisPolicy.ExpDrops, null) { - giveExp(droppedExp, true) - droppedExp = 0 - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/Listeners.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/Listeners.kt deleted file mode 100644 index 2bee9b3..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/Listeners.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.nyon.telekinesis.util - -import dev.nyon.telekinesis.Plugin -import org.bukkit.Bukkit -import org.bukkit.event.Event -import org.bukkit.event.EventPriority -import org.bukkit.event.Listener - -abstract class SingleListener : Listener { - abstract fun onEvent(event: T) -} - -inline fun listen(crossinline eventCallback: T.() -> Unit) { - val listener = object : SingleListener() { - override fun onEvent(event: T) = eventCallback(event) - } - Bukkit.getPluginManager() - .registerEvent( - T::class.java, - listener, - EventPriority.NORMAL, - { _, event -> listener.onEvent(event as T) }, - Plugin - ) -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/TelekinesisCheck.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/TelekinesisCheck.kt deleted file mode 100644 index e8a2a34..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/TelekinesisCheck.kt +++ /dev/null @@ -1,45 +0,0 @@ -package dev.nyon.telekinesis.util - -import dev.nyon.telekinesis.TelekinesisPolicy -import dev.nyon.telekinesis.bukkitEnchantment -import dev.nyon.telekinesis.config -import org.bukkit.entity.Player -import org.bukkit.inventory.ItemStack - -fun ItemStack.hasTelekinesis(): Boolean = hasItemMeta() && itemMeta.enchants.contains(bukkitEnchantment) - -fun Player.handleTelekinesis(policy: TelekinesisPolicy, itemStack: ItemStack?, callback: Player.() -> Unit): Boolean { - if (!policy.isEnabled()) return false - if (!meetCondition(policy, itemStack)) return false - - callback() - return true -} - -private fun Player.meetCondition(policy: TelekinesisPolicy, itemStack: ItemStack?): Boolean { - fun Player.hasPermission(policy: TelekinesisPolicy): Boolean { - val permission = policy.associatedPermission() - return permission == null || this@hasPermission.hasPermission(permission) - } - - var conditionsMet: Boolean - - val isEnabledByDefault = config.onByDefault && - (config.onByDefaultPermissionRequirement == null || hasPermission(config.onByDefaultPermissionRequirement!!)) - - val hasArmorTelekinesis: Boolean = inventory.armorContents.all { it?.hasTelekinesis() == true } - val hasMainHandTelekinesis = - itemStack != null && itemStack.hasTelekinesis() || inventory.itemInMainHand.hasTelekinesis() - val hasOffHandTelekinesis = inventory.itemInOffHand.hasTelekinesis() - - conditionsMet = if (isEnabledByDefault) true else when (policy) { - TelekinesisPolicy.ExpDrops -> hasArmorTelekinesis || hasMainHandTelekinesis || hasOffHandTelekinesis - TelekinesisPolicy.EntityDrops -> hasMainHandTelekinesis || hasOffHandTelekinesis - TelekinesisPolicy.BlockDrops -> hasMainHandTelekinesis - } - - if (!hasPermission(policy)) conditionsMet = false - if (config.onlyOnSneak && !isSneaking) conditionsMet = false - - return conditionsMet -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/resources/paper-plugin.yml b/telekinesis-paper/src/main/resources/paper-plugin.yml deleted file mode 100644 index 724feb6..0000000 --- a/telekinesis-paper/src/main/resources/paper-plugin.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: $name -version: $version -main: $main -description: $description -authors: $authors -website: $website -api-version: $apiVersion -folia-supported: $foliaSupported -loader: $loader \ No newline at end of file diff --git a/telekinesis-fabric/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties similarity index 100% rename from telekinesis-fabric/versions/1.20.1/gradle.properties rename to versions/1.20.1/gradle.properties diff --git a/telekinesis-fabric/versions/1.20.4/gradle.properties b/versions/1.20.4/gradle.properties similarity index 100% rename from telekinesis-fabric/versions/1.20.4/gradle.properties rename to versions/1.20.4/gradle.properties diff --git a/telekinesis-fabric/versions/1.20.6/gradle.properties b/versions/1.20.6/gradle.properties similarity index 84% rename from telekinesis-fabric/versions/1.20.6/gradle.properties rename to versions/1.20.6/gradle.properties index 11dd997..a530c60 100644 --- a/telekinesis-fabric/versions/1.20.6/gradle.properties +++ b/versions/1.20.6/gradle.properties @@ -2,7 +2,7 @@ mcVersion=1.20.6 mcVersionRange=>=1.20.5 <=1.20.6 supportedMcVersions=1.20.5,1.20.6 -deps.parchment=1.20.6:2024.05.01 +deps.parchment= deps.fapi=0.100.0+1.20.6 deps.yacl=3.4.2+1.20.5-fabric deps.modMenu=10.0.0-beta.1 diff --git a/telekinesis-fabric/versions/1.21/gradle.properties b/versions/1.21/gradle.properties similarity index 100% rename from telekinesis-fabric/versions/1.21/gradle.properties rename to versions/1.21/gradle.properties