How do I open a GUI?

Discussion in 'Plugin Development' started by Begamus, Jul 26, 2020.

  1. Offline


    I wanted to aks how I open a GUI with a command. I want to make a prefix plugin so if you execute the command "/prefix" a GUI shell open so you can cange your PermissionsEX-prefix. Bot idk how to open a GUI with a command.

  2. Offline


    Create a class named as you want, in this case I will call it TutorialGUI and add the following within it:

    public void PrefixGUI (Player player) {
    Inventory MyGUI = Bukkit.createInventory (null, NumberSlots, Title);
    // Then place the items, you have tutorials to create a GUI
    player.openInventory (MyGUI);
    Then go to the method where you have the command and add this:

    // This makes the GUI open for the player to execute the command if so desired
    TutorialGUI MyGUI = new TutorialGUI (plugin);
    MyGUI.PrefixGUI (sender);
    And that should work
  3. Offline


    Well, you would create an Inventory then do playerObject#openInventory(inventoryObject). If you are trying to get text input though, you'd want to use an anvil GUI or the like. Personally, I find it a lot simpler when I need text input to just have the plugin tell the user to put their input into chat then intercept it.

Share This Page