From a3c9b350b77ee91063a08dc3b7b9eb2472da5dc0 Mon Sep 17 00:00:00 2001 From: PQguanfang Date: Mon, 27 Nov 2023 08:23:07 +0800 Subject: [PATCH 1/2] Removed launch-at-location support for arrow, and added arrow_damage arg to shoot_arrow effect. --- .../com/willfp/libreforge/effects/impl/EffectShoot.kt | 2 +- .../com/willfp/libreforge/effects/impl/EffectShootArrow.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt index 93bd7fa56..26ee762aa 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt @@ -38,7 +38,7 @@ object EffectShoot : Effect("shoot") { player.launchProjectile(projectileClass as Class, velocity) } - if (config.getBool("launch-at-location") && data.location != null) { + if (config.getBool("launch-at-location") && data.location != null && projectile !is AbstractArrow) { projectile.teleportAsync(data.location) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt index 3cb4d89da..1d264b124 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt @@ -4,6 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.util.runExempted import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.Effect +import com.willfp.libreforge.getDoubleFromExpression +import com.willfp.libreforge.getOrNull import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.AbstractArrow @@ -27,8 +29,9 @@ object EffectShootArrow : Effect("shoot_arrow") { player.launchProjectile(Arrow::class.java, velocity) } - if (config.getBool("launch-at-location") && data.location != null) { - arrow.teleportAsync(data.location) + val damage = config.getOrNull("arrow_damage") { getDoubleFromExpression(it, data) } + if (damage != null) { + arrow.damage = damage } arrow.pickupStatus = AbstractArrow.PickupStatus.DISALLOWED From c623150d71436ea7e97b80a44316ec1615662cd6 Mon Sep 17 00:00:00 2001 From: PQguanfang Date: Mon, 27 Nov 2023 08:25:46 +0800 Subject: [PATCH 2/2] Added effect arg --- .../libreforge/effects/impl/EffectShootArrow.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt index 1d264b124..83069235c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShootArrow.kt @@ -5,12 +5,15 @@ import com.willfp.eco.util.runExempted import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getDoubleFromExpression +import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.getOrNull import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.AbstractArrow import org.bukkit.entity.Arrow import org.bukkit.event.entity.EntityShootBowEvent +import org.bukkit.potion.PotionEffect +import org.bukkit.potion.PotionEffectType object EffectShootArrow : Effect("shoot_arrow") { override val parameters = setOf( @@ -42,6 +45,20 @@ object EffectShootArrow : Effect("shoot_arrow") { if (config.getBool("no_source")) { arrow.shooter = null } + + if (config.getStringOrNull("effect") != null) { + arrow.addCustomEffect( + PotionEffect( + PotionEffectType.getByName(config.getString("effect").uppercase()) + ?: PotionEffectType.INCREASE_DAMAGE, + config.getIntFromExpression("duration", data), + config.getIntFromExpression("level", data) - 1, + true, + true, + true + ), false + ) + } } return true