From be9f99c790e639390ed16ca72b039376c8a4bb64 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 4 Jul 2023 14:38:30 +0100 Subject: [PATCH] Moved rapid to be libreforge-based --- .../ecoenchants/enchants/EcoEnchants.kt | 1 - .../enchants/impl/EnchantmentRapid.kt | 51 ------------------- .../src/main/resources/enchants/rapid.yml | 7 ++- 3 files changed, 5 insertions(+), 54 deletions(-) delete mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt index ad668086..f0d0e321 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt @@ -5,7 +5,6 @@ import com.google.common.collect.ImmutableSet import com.willfp.eco.core.config.interfaces.Config import com.willfp.ecoenchants.EcoEnchantsPlugin import com.willfp.ecoenchants.enchants.impl.EnchantmentPermanenceCurse -import com.willfp.ecoenchants.enchants.impl.EnchantmentRapid import com.willfp.ecoenchants.enchants.impl.EnchantmentRepairing import com.willfp.ecoenchants.enchants.impl.EnchantmentReplenish import com.willfp.ecoenchants.enchants.impl.EnchantmentSoulbound diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt deleted file mode 100644 index 82f2f5e5..00000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentRapid.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.willfp.ecoenchants.enchants.impl - -import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.target.EnchantLookup.getActiveEnchantLevel -import com.willfp.ecoenchants.target.EnchantLookup.getEnchantLevel -import org.bukkit.entity.Player -import org.bukkit.event.EventHandler -import org.bukkit.event.EventPriority -import org.bukkit.event.Listener -import org.bukkit.event.entity.EntityShootBowEvent -import kotlin.math.min - -class EnchantmentRapid( - plugin: EcoEnchantsPlugin -) : EcoEnchant( - "rapid", - plugin, - force = false -) { - override fun onInit() { - this.registerListener(RapidHandler(this)) - } - - private class RapidHandler( - private val enchant: EcoEnchant - ) : Listener { - @EventHandler( - priority = EventPriority.LOW, - ignoreCancelled = true - ) - fun handle(event: EntityShootBowEvent) { - val player = event.entity as? Player ?: return - - val level = player.getActiveEnchantLevel(enchant) - - val multiplier = 1 - enchant.config.getDouble("percent-faster-per-level") * level / 100 - - if (event.force < multiplier) { - return - } - - val force = min(1.0 / event.force, Double.MAX_VALUE) - var velocity = event.projectile.velocity.multiply(force) - if (velocity.length() > 3) { - velocity = velocity.normalize().multiply(3) - } - event.projectile.velocity = velocity - } - } -} diff --git a/eco-core/core-plugin/src/main/resources/enchants/rapid.yml b/eco-core/core-plugin/src/main/resources/enchants/rapid.yml index 2a933ef6..61bad374 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/rapid.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/rapid.yml @@ -13,6 +13,9 @@ tradeable: true discoverable: true enchantable: true -conditions: [ ] +effects: + - id: rapid_bows + args: + percent_faster: "15 * %level%" -percent-faster-per-level: 15 +conditions: [ ]