I was creating a tab GUI and the example worked great, I then tried just adding specific items using the addItems method instead of using the fill method and it would not add any items.
I stepped into the method below and the emptyIndex was constantly coming back as -1, why it was doing that I am not sure, since the GUI had not had any items added to it yet.
@Override
public void addItems(@NotNull Item... items) {
for (Item item : items) {
int emptyIndex = ArrayUtils.findFirstEmptyIndex(items);
if (emptyIndex == -1) break;
setItem(emptyIndex, item);
}
}
This is the code to reproduce the GUI that isnt working, this exact code works perfectly fine with using fill or setItem
GUI pickaxeTab = new SimpleGUI(9, 3);
GUI axeTab = new SimpleGUI(9, 3);
for (int i =0; i < 9; i++){
pickaxeTab.addItems(new SimpleItem(new ItemBuilder(Material.IRON_PICKAXE)));
axeTab.addItems(new SimpleItem(new ItemBuilder(Material.IRON_AXE)));
}
menu = new GUIBuilder<>(GUIType.TAB)
.setStructure(
"# # # 0 # 1 # # #",
"x x x x x x x x x",
"x x x x x x x x x",
"x x x x x x x x x")
.addIngredient('x', Markers.ITEM_LIST_SLOT_HORIZONTAL)
.addIngredient('#', Border::new)
.addIngredient('0', new PickTab(0))
.addIngredient('1', new AxeTab(1))
.setGUIs(Arrays.asList(pickaxeTab, axeTab))
.build();
}
Version 0.10
I was creating a tab GUI and the example worked great, I then tried just adding specific items using the addItems method instead of using the fill method and it would not add any items.
I stepped into the method below and the emptyIndex was constantly coming back as -1, why it was doing that I am not sure, since the GUI had not had any items added to it yet.
This is the code to reproduce the GUI that isnt working, this exact code works perfectly fine with using fill or setItem