Finished GUI
This commit is contained in:
@@ -72,6 +72,7 @@ class EcoMenu(
|
||||
|
||||
override fun getCaptiveItems(player: Player): MutableList<ItemStack> {
|
||||
val inventory = MenuHandler.getExtendedInventory(player.openInventory.topInventory)
|
||||
inventory ?: return ArrayList()
|
||||
return inventory.captiveItems
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ object MenuHandler {
|
||||
return MENUS[INVS[inventory]]
|
||||
}
|
||||
|
||||
fun getExtendedInventory(inventory: Inventory): ExtendedInventory {
|
||||
return INVS[inventory]!!
|
||||
fun getExtendedInventory(inventory: Inventory): ExtendedInventory? {
|
||||
return INVS[inventory]
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,6 @@ class EcoFillerSlot(itemStack: ItemStack) : EcoSlot(
|
||||
{ _, _, _ -> },
|
||||
{ _, _, _ -> },
|
||||
{ _, _, _ -> },
|
||||
{ _, _, _ -> },
|
||||
{ _, _, _ -> }
|
||||
)
|
||||
@@ -47,7 +47,9 @@ open class EcoSlot(
|
||||
player: Player,
|
||||
menu: Menu
|
||||
): ItemStack {
|
||||
return provider.provide(player, menu)
|
||||
val prev = provider.provide(player, menu)
|
||||
modifier.provide(player, menu, prev)
|
||||
return prev
|
||||
}
|
||||
|
||||
override fun isCaptive(): Boolean {
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.willfp.eco.spigot.display.*
|
||||
import com.willfp.eco.spigot.drops.CollatedRunnable
|
||||
import com.willfp.eco.spigot.eventlisteners.*
|
||||
import com.willfp.eco.spigot.gui.GUIListener
|
||||
import com.willfp.eco.spigot.gui.GUITester
|
||||
import com.willfp.eco.spigot.integrations.anticheat.*
|
||||
import com.willfp.eco.spigot.integrations.antigrief.*
|
||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsOraxen
|
||||
@@ -142,8 +141,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
PlayerJumpListeners(),
|
||||
GUIListener(this),
|
||||
ArrowDataListener(this),
|
||||
ArmorChangeEventListeners(this),
|
||||
GUITester(this)
|
||||
ArmorChangeEventListeners(this)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class GUIListener(plugin: EcoPlugin) : PluginDependent<EcoPlugin>(plugin), Liste
|
||||
event.isCancelled = true
|
||||
ecoSlot.handleInventoryClick(event, menu)
|
||||
|
||||
plugin.scheduler.run{ MenuHandler.getExtendedInventory(event.clickedInventory!!).refresh(player) }
|
||||
plugin.scheduler.run{ MenuHandler.getExtendedInventory(event.clickedInventory!!)!!.refresh(player) }
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -46,7 +46,7 @@ class GUIListener(plugin: EcoPlugin) : PluginDependent<EcoPlugin>(plugin), Liste
|
||||
|
||||
val menu = MenuHandler.getMenu(player.openInventory.topInventory) ?: return
|
||||
|
||||
plugin.scheduler.run{ MenuHandler.getExtendedInventory(player.openInventory.topInventory).refresh(player) }
|
||||
plugin.scheduler.run{ MenuHandler.getExtendedInventory(player.openInventory.topInventory)!!.refresh(player) }
|
||||
plugin.scheduler.runLater({ Bukkit.getLogger().info(menu.getCaptiveItems(player).toString()) }, 1)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.willfp.eco.spigot.gui
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.PluginDependent
|
||||
import com.willfp.eco.core.gui.menu.Menu
|
||||
import com.willfp.eco.core.gui.slot.FillerMask
|
||||
import com.willfp.eco.core.gui.slot.Slot
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class GUITester(plugin: EcoPlugin) : PluginDependent<EcoPlugin>(plugin), Listener {
|
||||
private val menu: Menu = Menu.builder(3)
|
||||
.setMask(
|
||||
FillerMask(
|
||||
Material.BLACK_STAINED_GLASS_PANE,
|
||||
"111111111",
|
||||
"100000001",
|
||||
"111111111"
|
||||
)
|
||||
).setSlot(
|
||||
2, 2,
|
||||
Slot.builder()
|
||||
.setCaptive()
|
||||
.build()
|
||||
).modfiy { builder ->
|
||||
run {
|
||||
val slot = Slot.builder(ItemStack(Material.RED_STAINED_GLASS_PANE))
|
||||
.setModifier{ player, menu, prev -> run {
|
||||
if (menu.getCaptiveItems(player).isNotEmpty()) {
|
||||
prev.type = Material.GREEN_STAINED_GLASS_PANE
|
||||
}
|
||||
}}
|
||||
.build()
|
||||
for (i in 3..8) {
|
||||
builder.setSlot(2, i, slot)
|
||||
}
|
||||
}
|
||||
}.build()
|
||||
|
||||
@EventHandler
|
||||
fun test(event: AsyncPlayerChatEvent) {
|
||||
if (!event.message.equals("testgui", true)) {
|
||||
return
|
||||
}
|
||||
|
||||
plugin.scheduler.run { menu.open(event.player) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user