Steve's Series | Gui Library icon

Steve's Series | Gui Library -----

The most advanced (or at least I think) GUI management library.



[​IMG]
> Gui Library <
THIS PLUGIN REQUIRES Steve's Series | Kotlin
The most (or at least one of) advanced GUI management library. Unlike other GUI libraries, SS-GuiLibrary supports any kind of GUI, in addition to inventory GUIs, while not currently supported by the library itself, it is entirely possible to create a kind of GUI that would use books instead, as an example. SS-GuiLibrary uses Kotlin for most of it's functions, while it is possible to use it from Java, I highly recommend Kotlin as there are a lot of things with this plugin that would not be as clean of solutions in Java as they can be in Kotlin. The most powerful part of this library is the GuiComponents with their state management.

There are multiple ways in which you can create a chest GUI with this library:

  • Using InventoryGuiController (I do not know any cases in which you would want to use this, unless building a custom solution):
    Code (Kotlin):
    class TestGui : InventoryGuiController ( ) {
        override fun createInventory ( ) = this. player. server. createInventory ( null, 9, "Test GUI" )
       
        override fun update ( ) {
            val stack = ItemStack (Material. EMERALD_BLOCK )
           
            val meta = stack. itemMeta
            meta. setDisplayName ( "Test" )
            stack. itemMeta = meta
           
            this. inventory. setItem ( 0, stack )
        }

        override fun onClick (event : InventoryClickEvent ) {
            event. isCancelled = true
           
            if (event. clickedInventory != this. inventory || event. click == ClickType. DOUBLE_CLICK ) {
                return
            }
           
            if (event. click. isLeftClick && event. slot == 0 ) {
                this. player. sendMessage ( "Hello, world!" )
            }
        }

        override fun onDrag (event : InventoryDragEvent ) {
            event. isCancelled = true
        }
    }
  • Using GridInventoryGui (best for simple GUIs):
    Code (Kotlin):
    class TestGui : GridInventoryGui ( ) {
        override fun getSize ( ) = GridInventorySize. GENERIC_9X1
        override fun getTitle ( ) = "Test GUI"

        override fun render (canvas : ItemCanvas ) {
            canvas. item ( 0, 0 ) {
                stack { type = Material. EMERALD_BLOCK }
                meta <ItemMeta > { setDisplayName ( "Test" ) }

                leftClick { _, _, _, _ ->
                    this@TestGui. player. sendMessage ( "Hello, world!" )
                }
            }
        }
    }
  • Using ComponentGui and GuiComponents (best solution, but less performant than the previous two):
    Code (Kotlin):
    class TestGui : GuiComponent ( ), RootComponent {
        override fun getSize ( ) = GridInventorySize. GENERIC_9X1
        override fun getTitle ( ) = "Test GUI"

        override fun ComponentCanvas. render ( ) {
            item ( 0, 0 ) {
                stack { type = Material. EMERALD_BLOCK }
                meta <ItemMeta > { setDisplayName ( "Test" ) }

                leftClick { _, _, _, _ ->
                    this@TestGui. gui. player. sendMessage ( "Hello, world!" )
                }
            }
        }
    }
Here's a more advanced example of the GuiComponents:
Code (Kotlin):
class PlayerInfoComponent (
    private val player : Player
) : GuiComponent ( ) {
    private fun getMaxHealth ( ) =
        this@PlayerInfoComponent. player. getAttribute ( Attribute. GENERIC_MAX_HEALTH ) ?. value
 
    override fun ComponentCanvas. render ( ) {
        val playerName = this@PlayerInfoComponent. player. name // The name of a player cannot change, no need to watch it.
        val playerHealth = watch { this@PlayerInfoComponent. player. health }
        val playerMaxHealth = watch { this@PlayerInfoComponent. getMaxHealth ( ) }
 
        item ( 0, 0 ) {
            stack { type = Material. PLAYER_HEAD }
            meta <SkullMeta > {
                setDisplayName ( "${ChatColor.WHITE}$playerName" )
                lore = listOf (
                    "",
                    "${ChatColor.GRAY}Health: ${ChatColor.YELLOW}$playerHealth/${ChatColor.YELLOW}$playerMaxHealth"
                )
            }
        }
    }
}

class SelfInfoComponent : GuiComponent ( ), RootComponent {
    override fun getSize ( ) = GridInventorySize. HOPPER
    override fun getTitle ( ) = "Your Player Info"
 
    override fun ComponentCanvas. render ( ) {
        val player = this@SelfInfoComponent. gui. player
        component ( 2, 0, 1, 1, PlayerInfoComponent (player ) )
    }
}

Resource Information
Author:
----------
Total Downloads: 468
First Release: Oct 25, 2020
Last Update: Apr 26, 2022
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings