From b3582c4d9245fe0d59438d9f1c78ebf486ea9e4f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 31 Aug 2021 13:39:10 +0100 Subject: [PATCH] Hopefully fixed spelunking --- .../effects/effects/EffectSpelunking.kt | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt index 79f8f98..201a522 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt @@ -12,7 +12,6 @@ import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.block.BlockBreakEvent import org.bukkit.event.block.BlockDropItemEvent -import java.util.* class EffectSpelunking : Effect( "spelunking" @@ -58,41 +57,33 @@ class EffectSpelunking : Effect( val chance = getChance(level) - val multiplier = getMultiplier(level) + var bonus = getMultiplier(level) - 2 - if (multiplier == 1) { + if (bonus <= 0) { return } - var amount = 0 - - if (multiplier > 2) { - for (i in 2 until multiplier) { - amount++ - } - } if (NumberUtils.randFloat(0.0, 100.0) < chance) { - amount++ + bonus++ } - val dropEvent = BlockDropItemEvent(block, block.state, player, event.items.map { item -> - val stack = item.itemStack - stack.amount = stack.amount * amount - if (stack.type == Material.AIR || stack.amount <= 0) { - return@map null + val dropEvent = BlockDropItemEvent(block, block.state, player, event.items.map { + it.itemStack = it.itemStack.apply { + this.amount *= bonus } - item.itemStack = stack - item - }.filter { Objects.nonNull(it) }.toMutableList()) - noRepeat.add(dropEvent) + it + }) + + Bukkit.getPluginManager().callEvent(dropEvent) if (dropEvent.items.isEmpty() || dropEvent.isCancelled) { return } - Bukkit.getPluginManager().callEvent(dropEvent) + + noRepeat.add(dropEvent) DropQueue(player) - .addItems(*dropEvent.items.map { item -> item.itemStack }) + .addItems(*dropEvent.items.map { it.itemStack }) .push() }