9
0
mirror of https://github.com/Auxilor/EcoMenus.git synced 2025-12-19 15:09:20 +00:00

Many fixes

This commit is contained in:
Auxilor
2023-06-04 12:15:28 +01:00
parent 5b0bb4e54d
commit b594e08bdb
3 changed files with 5 additions and 7 deletions

View File

@@ -28,7 +28,7 @@ class ConfigurableSlot(
override val column: Int = config.getInt("location.column") override val column: Int = config.getInt("location.column")
val page: Int = config.getInt("location.page") val page: Int = config.getInt("location.page")
override val layer = runCatching { enumValueOf<MenuLayer>(config.getString("layer")) } override val layer = runCatching { enumValueOf<MenuLayer>(config.getString("location.layer").uppercase()) }
.getOrElse { MenuLayer.MIDDLE } .getOrElse { MenuLayer.MIDDLE }
private val context = baseContext.with("slot at row ${row}, column $column, page $page") private val context = baseContext.with("slot at row ${row}, column $column, page $page")
@@ -84,13 +84,11 @@ class ConfigurableSlot(
return slot return slot
} }
fun <T : PageBuilder> add(builder: T): T { fun add(builder: PageBuilder) {
try { try {
builder.addComponent(this) builder.addComponent(this)
} catch (e: Exception) { } catch (e: Exception) {
context.log(ConfigViolation("location", "Invalid location!")) context.log(ConfigViolation("location", "Invalid location!"))
} }
return builder
} }
} }

View File

@@ -39,7 +39,7 @@ fun buildMenu(plugin: EcoPlugin, menu: EcoMenu, config: Config): Menu {
val slots = mutableListOf<ConfigurableSlot>() val slots = mutableListOf<ConfigurableSlot>()
for (slotConfig in config.getSubsections("slot_templates")) { for (slotConfig in config.getSubsections("slots")) {
val slot = ConfigurableSlot( val slot = ConfigurableSlot(
plugin, plugin,
ViolationContext(plugin, "menu ${menu.id}"), ViolationContext(plugin, "menu ${menu.id}"),
@@ -93,7 +93,7 @@ fun buildMenu(plugin: EcoPlugin, menu: EcoMenu, config: Config): Menu {
onClose { event, menu -> onClose { event, menu ->
val player = event.player as Player val player = event.player as Player
menu.close(player) menu.previousMenus[player].popOrNull()?.open(player)
} }
} }
} }

View File

@@ -2,4 +2,4 @@
#Sat Jun 03 15:45:10 BST 2023 #Sat Jun 03 15:45:10 BST 2023
kotlin.code.style=official kotlin.code.style=official
libreforge-version=4.17.2 libreforge-version=4.17.2
version=1.0.0 version=0.0.1-ALPHA