From 07c364103b55453ee081dadc244d8bf807ff8c29 Mon Sep 17 00:00:00 2001 From: Will FP Date: Wed, 6 Dec 2023 23:45:14 +0000 Subject: [PATCH] Fixed move trigger and updated kotlin and eco --- build.gradle.kts | 4 +-- core/build.gradle.kts | 2 +- .../libreforge/triggers/impl/TriggerMove.kt | 30 +++++++++++++++++++ gradle.properties | 2 +- loader/build.gradle.kts | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3795533c8..2aef1b64a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") } } @@ -39,7 +39,7 @@ allprojects { dependencies { compileOnly("org.jetbrains:annotations:23.0.0") - compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.7.10") + compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.9.20") compileOnly(fileTree("lib") { include("*.jar") }) } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 3d95f2e85..d9b086706 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -3,7 +3,7 @@ dependencies { isTransitive = false } - compileOnly("com.willfp:eco:6.65.0") + compileOnly("com.willfp:eco:6.67.0") compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("net.kyori:adventure-text-minimessage:4.14.0") diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt index 8c290cfe5..d0d3206dc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt @@ -8,6 +8,7 @@ import com.willfp.libreforge.triggers.TriggerParameter import io.papermc.paper.event.entity.EntityMoveEvent import org.bukkit.entity.Player import org.bukkit.event.EventHandler +import org.bukkit.event.player.PlayerMoveEvent object TriggerMove : Trigger("move") { override val parameters = setOf( @@ -46,4 +47,33 @@ object TriggerMove : Trigger("move") { ) ) } + + @EventHandler(ignoreCancelled = true) + fun handle(event: PlayerMoveEvent) { + val player = event.player + + if (Prerequisite.HAS_PAPER.isMet) { + if (!event.hasChangedBlock()) { + return + } + } + + val distance = if (event.to.world == event.from.world) { + event.to.distance(event.from) + } else { + 0.0 + } + + this.dispatch( + player.toDispatcher(), + TriggerData( + player = player, + location = player.location, + velocity = player.velocity, + event = event, + item = player.equipment.itemInMainHand, + value = distance + ) + ) + } } diff --git a/gradle.properties b/gradle.properties index 7d227c032..c3fe60e41 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 4.48.0 +version = 4.48.1 kotlin.code.style = official \ No newline at end of file diff --git a/loader/build.gradle.kts b/loader/build.gradle.kts index cb543a56b..69a61e9bc 100644 --- a/loader/build.gradle.kts +++ b/loader/build.gradle.kts @@ -1,7 +1,7 @@ dependencies { compileOnly(project(":core")) - compileOnly("com.willfp:eco:6.55.2") + compileOnly("com.willfp:eco:6.67.0") compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT") }