Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for shoot and shoot_arrow effects. #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object EffectShoot : Effect<NoCompileData>("shoot") {
player.launchProjectile(projectileClass as Class<out Projectile>, 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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ 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.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<NoCompileData>("shoot_arrow") {
override val parameters = setOf(
Expand All @@ -27,8 +32,9 @@ object EffectShootArrow : Effect<NoCompileData>("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
Expand All @@ -39,6 +45,20 @@ object EffectShootArrow : Effect<NoCompileData>("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
Expand Down