NextDevv's Docs Help

GuiBorder

data class GuiBorder( var leftOffset: Int = 0, var rightOffset: Int = 0, var topOffset: Int = 0, var bottomOffset: Int = 0, var leftItemStack: ItemStack? = null, var rightItemStack: ItemStack? = null, var topItemStack: ItemStack? = null, var bottomItemStack: ItemStack? = null, var defaultItemStack: ItemStack = KItemStack().builder() .setName(" ") .addItemFlag(ItemFlag.HIDE_UNBREAKABLE) .setMaterial(Material.STONE) .build() )

Description & Properties

The GuiBorder class is used to create a border around a GUI. It has the following properties:

  • leftOffset: The number of empty slots on the left side of the GUI.

  • rightOffset: The number of empty slots on the right side of the GUI.

  • topOffset: The number of empty slots on the top side of the GUI.

  • bottomOffset: The number of empty slots on the bottom side of the GUI.

  • leftItemStack: The item stack to use for the left border.

  • rightItemStack: The item stack to use for the right border.

  • topItemStack: The item stack to use for the top border.

  • bottomItemStack: The item stack to use for the bottom border.

  • defaultItemStack: The default item stack to use for the border if no specific item stack is provided.

Example

You can create a GuiBorder object and customize its appearance by setting the offsets and item stacks for each side of the GUI. The defaultItemStack property is used as a fallback if no specific item stack is provided for a side.

Here is an example of how to create a GuiBorder object in Kotlin:

kotlin

val border = GuiBorder() border.leftOffset = 1 border.rightOffset = 1 border.topOffset = 1 border.bottomOffset = 1 border.leftItemStack = ItemStack(Material.RED_STAINED_GLASS_PANE) border.rightItemStack = ItemStack(Material.RED_STAINED_GLASS_PANE) border.topItemStack = ItemStack(Material.RED_STAINED_GLASS_PANE) border.bottomItemStack = ItemStack(Material.RED_STAINED_GLASS_PANE) border.defaultItemStack = ItemStack(Material.GRAY_STAINED_GLASS_PANE) ...

In this example, we create a GuiBorder object with custom offsets and item stacks for each side of the GUI. The defaultItemStack property is set to a gray stained-glass pane, which will be used as the default item stack for the border.

You can then use this GuiBorder object when building a GUI to add a border around it. The border will be displayed using the specified item stacks and offsets, enhancing the visual appearance of the GUI.

... val kGui = KGui(PLUGIN) val inv = kGui.builder(PLAYER) .setTitle("My GUI") .setRows(6) .setBorder(border) .build()

In this code snippet, we create a KGui object and use its builder method to create a new inventory GUI. We set the title, number of rows, and border of the GUI using the setTitle, setRows, and setBorder methods, respectively. The build method is then called to create the inventory GUI with the specified properties, including the custom border.

Summary

The GuiBorder class provides a convenient way to add a border around a GUI in Minecraft. By customizing the offsets and item stacks for each side of the border, you can create visually appealing and interactive GUIs that enhance the gameplay experience for players.

Last modified: 03 July 2024