[HELP] Adding more of the same item to a gui!

Discussion in 'Spigot Plugin Development' started by JoshhCraft, Jun 28, 2015.

  1. So I have some code (shown below) and I want to add another chest item in my inv that I created but how would I separate it so that the commands were different if I clicked on, So say I wanted 1 chest to send a message saying hi, but the other chest to say hello, but the chest have different names to define them in the inventory, now would I need to define them by the name, if so, how?

    Code (Text):
    case CHEST:
           //commands and stuff go here
                    }
                }
                break;
            default:
                player.closeInventory();
                break;
     
  2. you could change the name of the item to different things...
     
  3. Code (Text):
    // Inventory

    inv.setItem(1, new ItemStack(Material.CHEST));
    inv.setItem(4, new ItemStack(Material.CHEST));

    // Inventory Click Event

    if(event.getSlot == 1){
    // the first chest
    }else if(event.getSlot == 4){
    // the second chest
    }
     
  4. Thank you, much appreciated! :D