From a9100a934888e931d7e34646dff3b6cb83f5428f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 17 Mar 2022 17:09:58 +0000 Subject: [PATCH] Fixed virtual crate opens --- .../src/main/kotlin/com/willfp/ecocrates/crate/Crate.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/crate/Crate.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/crate/Crate.kt index ef08f79..eb4615d 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/crate/Crate.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/crate/Crate.kt @@ -183,6 +183,7 @@ class Crate( onLeftClick { event, _, _ -> if (config.getBool("keygui.left-click-opens")) { val player = event.whoClicked as Player + player.closeInventory() openWithKey(player) } } @@ -252,10 +253,12 @@ class Crate( return false } + val loc = location ?: player.eyeLocation + val event = CrateOpenEvent(player, this, physicalKey, getRandomReward(player)) Bukkit.getPluginManager().callEvent(event) - val roll = makeRoll(player, location ?: player.location, event.reward) + val roll = makeRoll(player, loc, event.reward) var tick = 0 plugin.runnableFactory.create { @@ -266,7 +269,7 @@ class Crate( it.cancel() roll.onFinish() player.isOpeningCrate = false - this.handleFinish(player, roll, location ?: player.location) + this.handleFinish(player, roll, loc) } }.runTaskTimer(1, 1)