Need Help Making a GUI plugin

Discussion in 'Plugin Development' started by TommyPlayzOG, Aug 3, 2018.

Thread Status:
Not open for further replies.
  1. Offline


    Im make a permissions plugin and I need help with making the GUI...
    Heres my code:

    package me.tommyplayzog;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    public class EasyPerms extends JavaPlugin implements Listener {
        public Inventory SelectPlayerMenu;
        public ItemStack SelectPlayer = new ItemStack(Material.EMERALD_BLOCK);
        public void onEnable() {
            getLogger().info("EasyPerms has been Enabled!");
            new PlayerListener(this);
        public void onDisable() {
            getLogger().info("EasyPerms has been Disabled. ):");
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            SelectPlayerMenu = Bukkit.createInventory(null, 27, ChatColor.RED + "Easy Perms Menu");
            ItemMeta SelectPlayerMeta = SelectPlayer.getItemMeta();
            SelectPlayerMeta.setDisplayName(ChatColor.GOLD + "Select Player" );
            SelectPlayerMenu.setItem(13, SelectPlayer);
            if (cmd.getName().equalsIgnoreCase("permmenu") && sender instanceof Player) {
                Player player = (Player) sender;
            return false;
        public void onInventoryClick(InventoryClickEvent event) {
        Player player = (Player) event.getWhoClicked();
        ItemStack clicked = event.getCurrentItem();
        Inventory inventory = event.getInventory();
        if (inventory.getName().equals(SelectPlayerMenu.getName())) {
        if (clicked.getType().equals(SelectPlayer)) {
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline


    I cant make it so they can't take items out of the gui
  4. You should generally explain what you've tried so far, what errors you get, and why you think you get those errors. People will generally be much faster to answer your post since they don't have to read through 200 lines of irrelevant code. Try reading "How to create a Minimal, Complete, and Verifiable example". Also, your code is not indented correctly.

    Firstly, your variables are wrongly named. SelectPlayerMenu should be selectPlayerMenu.
    SelectPlayer should be selectPlayer.

    ItemStack#getType() returns a Material, but you are comparing it to SelectPlayer, which is an ItemStack. In other words, you are checking if a Material is the same as an ItemStack. To fix this, do
    1. if (clicked.getType() == selectPlayer.getType())
    which checks if they share the same material. You can do == instead of .equals() because Material is an enum.
Thread Status:
Not open for further replies.

Share This Page