Gui

Discussion in 'Spigot Plugin Development' started by Deger, Jun 4, 2016.

  1. Hi
    I wanna get some tips om how to make one itemslot in a new inventory to hold many items, just like a kit hokds alot of items

    Can i on any which way make a itemstack into a array?
    I have no code bit this question about makkng itemstack array/list has bugged me alot

    Do i need to make a eventhandler class which has clickevent and when i click on a certian itel i get like a set of diamonds eq?
     
  2. Do you mean when a player clicks on a certain item, they receive multiple items pertaining to the clicked item?

    Example:
    A GUI with a sword labeled knight kit.
    Player clicks the item:
    They receive knight armor and such.
     
  3. @Deger

    U need create 2 events dude

    1st: The event is just and example, u can use other event

    Code (Text):

        @EventHandler
        public void playerInteract(PlayerInteractEvent e){

    //variables here!
                  Inventory inv = Bukkit.createInventory(null, 54, ChatColor.BLACK
                        + "Kit Armor");

                  ItemStack item = new ItemStack (Material.DIAMOND_CHESTPLATE);
                  ItemMeta itemMeta = item.getItemMeta();
                  itemMeta.setDisplayName(ChatColor.AQUA + "Equip Diamond Armor.");
                  item.setItemMeta(itemMeta);

                  inv.setItem(0, item1);
    2d:

    Code (Text):

      @EventHandler
      public void onInvClick(InventoryClickEvent e)
      {

            if(e.getSlot() == 0){

             //do stuff
     
     
  4. Just what i tought
     
  5. And on the InventoryClickEvent don't forget to cancel the event
     
  6. Yes