Skip to main content

Action Setups

onButtonClick()

the onButtonClick() is how you tell the button that you want to do something when its being clicked, we will show you how you can execute a command on left clicking example open a deluxemenu menu

Its important you make sure to put player menu clickType inside the ( ) of the onButtonClick(player, menu, clickType)

      local ClickType = import("org.bukkit.event.inventory.ClickType")
      local Bukkit =
      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

      local ClickType = import("org.bukkit.event.inventory.ClickType")
      local Bukkit =
      import("org.bukkit.Bukkit")
      
      function onButtonClick(player, menu, clickType)
         if clickType == ClickType.LEFT then
           menu:animateTitle("&cRight Clicked!")
         end
       end

ClickType checking

      local ClickType = import("org.bukkit.event.inventory.ClickType")
      local Bukkit =
      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.LEFT then
           Bukkit:dispatchCommand(console, "say &cYour name is:&6 " .. player:getName())
         end
       end