diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt index a0e258ec71..fe64669f48 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/EcoEnchantsPlugin.kt @@ -65,7 +65,7 @@ class EcoEnchantsPlugin : LibreforgePlugin() { registerPlayerRefreshFunction { it.clearEnchantCache() } registerHolderPlaceholderProvider { it, _ -> listOf( - NamedValue("level", it.level), + NamedValue("level", it.level.level), NamedValue("active_level", it.activeLevel) ) } 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 c74e51b020..ed525d9700 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 @@ -3,14 +3,11 @@ package com.willfp.ecoenchants.enchants import com.google.common.collect.HashBiMap import com.google.common.collect.ImmutableSet import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.config.updating.ConfigUpdater 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 -import com.willfp.ecoenchants.enchants.impl.EnchantmentTelekinesis import com.willfp.ecoenchants.integrations.EnchantRegistrations import com.willfp.ecoenchants.rarity.EnchantmentRarities import com.willfp.ecoenchants.target.EnchantmentTargets @@ -20,7 +17,6 @@ import com.willfp.libreforge.loader.configs.ConfigCategory import org.bukkit.ChatColor import org.bukkit.NamespacedKey import org.bukkit.enchantments.Enchantment -import org.bukkit.event.Listener @Suppress("UNUSED") object EcoEnchants : ConfigCategory("enchant", "enchants") { @@ -195,10 +191,8 @@ object EcoEnchants : ConfigCategory("enchant", "enchants") { private fun registerHardcodedEnchantments( plugin: EcoEnchantsPlugin ) { - EnchantmentTelekinesis(plugin) EnchantmentPermanenceCurse(plugin) EnchantmentRepairing(plugin) - EnchantmentRapid(plugin) EnchantmentReplenish(plugin) EnchantmentSoulbound(plugin) } 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 82f2f5e56f..0000000000 --- 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/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentTelekinesis.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentTelekinesis.kt deleted file mode 100644 index d810a1a0eb..0000000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/impl/EnchantmentTelekinesis.kt +++ /dev/null @@ -1,125 +0,0 @@ -package com.willfp.ecoenchants.enchants.impl - -import com.willfp.eco.core.drops.DropQueue -import com.willfp.eco.core.events.EntityDeathByEntityEvent -import com.willfp.eco.core.integrations.antigrief.AntigriefManager -import com.willfp.eco.util.TelekinesisUtils -import com.willfp.eco.util.tryAsPlayer -import com.willfp.ecoenchants.EcoEnchantsPlugin -import com.willfp.ecoenchants.enchants.EcoEnchant -import com.willfp.ecoenchants.target.EnchantLookup.hasEnchant -import com.willfp.ecoenchants.target.EnchantLookup.hasEnchantActive -import org.bukkit.GameMode -import org.bukkit.Material -import org.bukkit.entity.Player -import org.bukkit.event.EventHandler -import org.bukkit.event.EventPriority -import org.bukkit.event.Listener -import org.bukkit.event.block.BlockBreakEvent -import org.bukkit.event.block.BlockDropItemEvent - -class EnchantmentTelekinesis( - plugin: EcoEnchantsPlugin -) : EcoEnchant( - "telekinesis", - plugin, - force = false -) { - override fun onInit() { - this.registerListener(TelekinesisHandler(this)) - TelekinesisUtils.registerTest { it.hasEnchantActive(this) } - } - - private class TelekinesisHandler( - private val enchant: EcoEnchant - ) : Listener { - @EventHandler( - priority = EventPriority.HIGH, - ignoreCancelled = true - ) - fun handle(event: BlockDropItemEvent) { - val player = event.player - val block = event.block - - if (!AntigriefManager.canBreakBlock(player, block)) { - return - } - - val drops = event.items.map { it.itemStack } - event.items.clear() - - DropQueue(player) - .setLocation(block.location) - .addItems(drops) - .push() - } - - @EventHandler( - priority = EventPriority.HIGH, - ignoreCancelled = true - ) - fun handle(event: BlockBreakEvent) { - val player = event.player - val block = event.block - - if (!player.hasEnchantActive(enchant)) { - return - } - - if (!AntigriefManager.canBreakBlock(player, block)) { - return - } - - if (player.gameMode == GameMode.CREATIVE || player.gameMode == GameMode.SPECTATOR) { - return - } - - // Filter out telekinesis spawner xp to prevent dupe - if (block.type == Material.SPAWNER && player.hasEnchant(enchant)) { - event.expToDrop = 0 - } - - DropQueue(player) - .setLocation(block.location) - .addXP(event.expToDrop) - .push() - - event.expToDrop = 0 - } - - - @EventHandler( - priority = EventPriority.HIGH, - ignoreCancelled = true - ) - fun handle(event: EntityDeathByEntityEvent) { - val victim = event.victim - - if (victim is Player && enchant.config.getBool("not-on-players")) { - return - } - - val player = event.killer.tryAsPlayer() ?: return - - // Only DropQueue-ify entity drops with telekinesis - if (!player.hasEnchantActive(enchant)) { - return - } - - val xp = event.xp - val drops = event.drops - - drops.removeAll { it == null } - - DropQueue(player) - .addItems(drops) - .setLocation(victim.location) - .addXP(xp) - .forceTelekinesis() - .push() - - event.deathEvent.droppedExp = 0 - event.deathEvent.drops.clear() - } - } -} 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 2a933ef679..61bad374e0 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: [ ] diff --git a/eco-core/core-plugin/src/main/resources/enchants/telekinesis.yml b/eco-core/core-plugin/src/main/resources/enchants/telekinesis.yml index 3b368120f7..1399ac94d9 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/telekinesis.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/telekinesis.yml @@ -14,6 +14,7 @@ tradeable: true discoverable: true enchantable: true -conditions: [ ] +effects: + - id: telekinesis -not-on-players: true +conditions: [ ] diff --git a/gradle.properties b/gradle.properties index 8a0ebc42ea..89e5ce89c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ #libreforge-updater -#Wed Jun 21 10:23:37 BST 2023 +#Sun Jul 09 17:24:20 BST 2023 kotlin.code.style=official -libreforge-version=4.20.1 -version=10.20.1 +libreforge-version=4.22.0 +version=10.22.0