Added rapid
This commit is contained in:
@@ -13,6 +13,7 @@ import com.willfp.ecoenchants.display.EnchantDisplay
|
||||
import com.willfp.ecoenchants.enchants.EcoEnchants
|
||||
import com.willfp.ecoenchants.enchants.LoreConversion
|
||||
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.EnchantmentTelekinesis
|
||||
import com.willfp.ecoenchants.enchants.registerVanillaEnchants
|
||||
@@ -50,6 +51,7 @@ class EcoEnchantsPlugin : LibReforgePlugin() {
|
||||
EnchantmentTelekinesis(this)
|
||||
EnchantmentPermanenceCurse(this)
|
||||
EnchantmentRepairing(this)
|
||||
EnchantmentRapid(this)
|
||||
|
||||
registerVanillaEnchants(this)
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.willfp.ecoenchants.enchants.impl
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin
|
||||
import com.willfp.ecoenchants.enchants.EcoEnchant
|
||||
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
|
||||
|
||||
class EnchantmentRapid(
|
||||
plugin: EcoEnchantsPlugin
|
||||
) : EcoEnchant(
|
||||
"rapid",
|
||||
plugin,
|
||||
force = false
|
||||
) {
|
||||
init {
|
||||
this.registerListener(RapidHandler(this))
|
||||
}
|
||||
|
||||
private class RapidHandler(
|
||||
private val enchant: EcoEnchant
|
||||
) : Listener {
|
||||
@EventHandler(
|
||||
priority = EventPriority.HIGH,
|
||||
ignoreCancelled = true
|
||||
)
|
||||
fun handle(event: EntityShootBowEvent) {
|
||||
val player = event.entity as? Player ?: return
|
||||
|
||||
val level = player.getEnchantLevel(enchant)
|
||||
|
||||
val multiplier = 1 - enchant.config.getDouble("percent-faster-per-level") * level / 100
|
||||
|
||||
if (event.force < multiplier) {
|
||||
return
|
||||
}
|
||||
|
||||
val force = 1 / event.force
|
||||
event.projectile.velocity = event.projectile.velocity.multiply(force)
|
||||
}
|
||||
}
|
||||
}
|
||||
18
eco-core/core-plugin/src/main/resources/enchants/rapid.yml
Normal file
18
eco-core/core-plugin/src/main/resources/enchants/rapid.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
display-name: "Rapid"
|
||||
description: "Lets you shoot full speed arrows with the bow at &a%placeholder%%&8 tension"
|
||||
placeholder: "1 - (15 * %level%)"
|
||||
type: normal
|
||||
|
||||
targets:
|
||||
- bow
|
||||
conflicts: [ ]
|
||||
rarity: epic
|
||||
max-level: 6
|
||||
|
||||
tradeable: true
|
||||
discoverable: true
|
||||
enchantable: true
|
||||
|
||||
conditions: [ ]
|
||||
|
||||
percent-faster-per-level: 15
|
||||
Reference in New Issue
Block a user