Custom Buttons
A guide on how to make a custom button in our main set menu. Mainly used to open menus that are not part of our system like deluxemenus etc
Setting up a button
- First open up the main-set-menu.yml in a text editor
- Now navigate down to the
Custom_Buttons: []
and remove the square brackets - Then go to the line under it and go in by 2 spaces
-
Now add the things bellow
- Icon: SPRUCE_DOOR Display_Name: "&c&lExample" Slot: 35 Lore: - "" - "&7➥ Example action" - "" Action: |-
You now have a custom button ready to be used however click it does not do anything right now.
Importing Java Classes
To import Java classes in to your project is very simple, in this example we will show you how to execute a command
by importing the Bukkit class from the server
import "org.bukkit.Bukkit"
Now that Bukkit has been imported you can find a list of methods you can execute Bukkit class now lets execute a command
import "org.bukkit.Bukkit"
local consoleSender = Bukkit:getConsoleSender() --Getting the console as a sender
Bukkit:dispatchCommand(consoleSender, "say this is an example message.")
Now this may be a little hard to figure out if you have never coded anything, so keeping it simple for now.
Action Setups
onButtonClick()
Its important you make sure to put player menu clickType inside the ( ) of the onButtonClick(player, menu, clickType)
import "org.bukkit.event.inventory.ClickType"
import "org.bukkit.Bukkit"
function onButtonClick(player, menu, clickType)
if clickType == ClickType.LEFT then
Bukkit:dispatchCommand(player, "dm open example")
end
end
Animating the title
Animate the title you can show a temporary title when a button is clicked
However its important you dont animate the title if you are opening another menu with a command, just keep that in mind
import "org.bukkit.event.inventory.ClickType"
function onButtonClick(player, menu, clickType)
if clickType == ClickType.LEFT then
menu:animateTitle("&cRight Clicked!")
end
end
ClickType checking
import "org.bukkit.event.inventory.ClickType"
import "org.bukkit.Bukkit"
local console = Bukkit:getConsoleSender()
function onButtonClick(player, menu, clickType)
if clickType == ClickType.Left then
menu:animateTitle("&cLeft Clicked!")
elseif clickType == ClickType.RIGHT then
menu:animateTitle("&cRight Clicked!")
end
end