mirror of
https://github.com/Auxilor/EcoMenus.git
synced 2025-12-19 15:09:20 +00:00
Improved menu closing
This commit is contained in:
@@ -5,6 +5,7 @@ import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.eco.core.gui.addPage
|
||||
import com.willfp.eco.core.gui.menu
|
||||
import com.willfp.eco.core.gui.menu.Menu
|
||||
import com.willfp.eco.core.gui.onClose
|
||||
import com.willfp.eco.core.gui.page.PageChanger
|
||||
import com.willfp.eco.core.gui.slot.FillerMask
|
||||
import com.willfp.eco.core.gui.slot.MaskItems
|
||||
@@ -96,5 +97,10 @@ fun buildMenu(plugin: EcoPlugin, menu: EcoMenu, config: Config): Menu {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClose { event, menu ->
|
||||
val player = event.player as Player
|
||||
menu.close(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ import org.bukkit.event.inventory.InventoryClickEvent
|
||||
|
||||
object SlotTypeClose : SlotType("close") {
|
||||
override fun create(config: Config, plugin: EcoPlugin, context: ViolationContext): SlotFunction {
|
||||
return object : SlotFunction {
|
||||
override fun execute(player: Player, event: InventoryClickEvent, slot: Slot, menu: Menu) {
|
||||
menu.close(player)
|
||||
}
|
||||
return CloseSlotFunction
|
||||
}
|
||||
|
||||
private object CloseSlotFunction : SlotFunction {
|
||||
override fun execute(player: Player, event: InventoryClickEvent, slot: Slot, menu: Menu) {
|
||||
menu.close(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user