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

Improved _example.yml, fixed slot conditions

This commit is contained in:
Auxilor
2023-06-05 14:39:42 +01:00
parent e81771916e
commit e5f5ca4d7f
3 changed files with 47 additions and 8 deletions

View File

@@ -84,7 +84,7 @@ class ConfigurableSlot(
action,
plugin,
context.with(section).with(typeName)
)?.toSlotAction() ?: continue
)?.toSlotAction(conditions) ?: continue
onClick(clickType, function)
}

View File

@@ -3,11 +3,17 @@ package com.willfp.ecomenus.slots
import com.willfp.eco.core.gui.menu.Menu
import com.willfp.eco.core.gui.slot.Slot
import com.willfp.ecomponent.SlotAction
import com.willfp.libreforge.EmptyProvidedHolder
import com.willfp.libreforge.conditions.ConditionList
import org.bukkit.entity.Player
import org.bukkit.event.inventory.InventoryClickEvent
interface SlotFunction {
fun execute(player: Player, event: InventoryClickEvent, slot: Slot, menu: Menu)
fun toSlotAction(): SlotAction = this::execute
fun toSlotAction(conditions: ConditionList): SlotAction = { player, event, slot, menu ->
if (conditions.areMet(player, EmptyProvidedHolder)) {
this.execute(player, event, slot, menu)
}
}
}

View File

@@ -35,15 +35,15 @@ forwards-arrow:
item: arrow name:"&fNext Page"
enabled: true
location:
row: 3
column: 6
row: 6
column: 8
backwards-arrow:
item: arrow name:"&fPrevious Page"
enabled: true
location:
row: 3
column: 4
row: 6
column: 2
pages:
- page: 1
@@ -68,6 +68,18 @@ pages:
- "210010012"
- "211111112"
- "211101112"
- page: 2
mask:
items:
- gray_stained_glass_pane
- red_stained_glass_pane
pattern:
- "211101112"
- "211111112"
- "210000012"
- "210010012"
- "211111112"
- "211101112"
slots:
- item: barrier name:"&cClose"
@@ -88,7 +100,7 @@ slots:
conditions: [ ]
# If the item should be shown if the conditions are not met
show-if-not-met: true
show-if-not-met: false
left-click:
- type: effects
@@ -97,7 +109,7 @@ slots:
args:
message: "&cYou clicked the close button!"
- type: command
- type: close
commands: [ ]
- type: menu
@@ -106,3 +118,24 @@ slots:
- type: console_command
commands:
- "eco give %player% 100"
- item: player_head head:%player% name:"&f%player%"
location:
row: 1
column: 5
page: 1
# Read https://plugins.auxilor.io/effects/configuring-a-condition
# The conditions required to click the item
conditions: [ ]
# If the item should be shown if the conditions are not met
show-if-not-met: true
left-click:
- type: menu
menu: other_example_menu
- type: console_command
commands:
- "eco give %player% 100"