Plugin command w/ MenuBuilder API

Discussion in 'Spigot Plugin Help' started by Jenots, Mar 16, 2019.

Thread Status:
Not open for further replies.
  1. So earlier today i started creating one command ( /servers ) that when entered opens up GUI with options, but i ran into problem...

    Code (Java):
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
                new InventoryMenuBuilder().withSize(36).withTitle("&2&lSelect server!").withItem(11, new ItemStack(Material.STONE), new ItemListener() {
                    @Override
                    public void onInteract(Player player, ClickType action, ItemStack item) {
                        player.sendMessage("Skyblock");
                    }
                }, ClickType.LEFT).show(player);
                .withItem(20, new ItemStack(Material.STONE), new ItemListener() {
                    @Override
                    public void onInteract(Player player, ClickType action, ItemStack item) {
                        player.sendMessage("survival");
                    }
                }, ClickType.LEFT).show(player);
                .withItem(22, new ItemStack(Material.STONE), new ItemListener() {
                    @Override
                    public void onInteract(Player player, ClickType action, ItemStack item) {
                        player.sendMessage("soon");
                    }
                }, ClickType.LEFT).show(player);
                .withItem(15, new ItemStack(Material.STONE), new ItemListener() {
                    @Override
                    public void onInteract(Player player, ClickType action, ItemStack item) {
                        player.sendMessage("construction");
                    }
                }, ClickType.LEFT).show(player);
            }
    What is my mistake and whi i have errors and how to fix them?
    Thanks for any help,
    Best regards, Jenots!
     
  2. What happens? What errors?

    We cannot help you when you are missing the errors and description of your problem.
    What happens?
    What should happen?
     
  3. I'm so sorry, i forgot importing one class. :oops:
    Now, when i run the command, it just sends me back command name in the chat...
     
  4. When you return false it automatically shows the usage of the command. Return true else.
     
    • Agree Agree x 1
  5. Thanks, it works now! :)
     
Thread Status:
Not open for further replies.

Share This Page