mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-19 05:01:40 +01:00
Moved rapid to be libreforge-based
This commit is contained in:
parent
298f8b7f5a
commit
be9f99c790
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -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: [ ]
|
||||
|
Loading…
Reference in New Issue
Block a user