Solved Skipping certain slots in custom GUI

Discussion in 'Spigot Plugin Development' started by antSTAR, Jun 15, 2021.

  1. Hello Spigot,

    I'm currently coding a challenge system where players can create a challenge and then others can request to be added to the challenge, if the request is being accepted a 1vs1 will begin. My problem is that I'm kind of new to making GUI's and that's why I'm here asking for help or advices.

    My problem is that I want to skip certain slots from being used.
    This is my code for adding the challengers into the Join GUI:
    Code (Java):
                int count = 0;
                for(String challengers : Main.getInstance().getChallengeManager().getChallengers()) {
                    ItemStack challenger = new ItemStack(Material.WOOL, 1);
                    ItemMeta challengerMeta = challenger.getItemMeta();
                    challengerMeta.setDisplayName(challengers);
                    challenger.setItemMeta(challengerMeta);
                    joinGUI.setItem(count, challenger);
                    count++;
                }
    What I want to make is that so it would look something like this:
    [​IMG]
    As you can see, the slots 8, 17, 18, 26 and 27 is not being used.
    How would I do this?
     
  2. Maybe (add it to the beggining of the for loop):
    Code (Java):
    if (count%7 == 0)
      count += 2;
     
  3. You can iterate through all of 26 slots, and if the slot number is 8/17/18/26/27, then do nothing, otherwise fill it with that block. But @Tomasan7 's suggestion is better.
     
  4. Get the remainder after dividing the [ slotIndex + 1 ] with 9. If the remainder is less or equals to 7, you can place an item there.
     
    • Funny Funny x 1
  5. Are you sure it works with 1.8.8, which is the version that OP uses? I am asking since most apis don't.
     
  6. Thank you, it works!
     
  7. Instead of just adding the item to an inventory include an int location of were to want it to go
     
  8. He is doing that...