SmartInvs
SmartInvs copied to clipboard
Problem With FillBorders
The code public class AuctionsInventory implements InventoryProvider {
private final UserEngine userEngine;
private final ItemsEngine itemsEngine;
private final SmartInventory inventory;
public AuctionsInventory(UserEngine userEngine, ItemsEngine itemsEngine) {
this.userEngine = userEngine;
this.itemsEngine = itemsEngine;
this.inventory = SmartInventory.builder()
.id("myInventory")
.provider(this)
.size(6, 9)
.title(ChatUtil.fixColor("&6&lMARKET"))
.build();
}
@Override
public void init(Player player, InventoryContents inventoryContents) {
Pagination pagination = inventoryContents.pagination();
ClickableItem[] items = new ClickableItem[50];
for(int i = 0; i < 50; i++)
items[i] = ClickableItem.empty(new ItemStack(Material.CARROT_ITEM));
pagination.setItems(items);
pagination.setItemsPerPage(28);
inventoryContents.fillBorders(ClickableItem.empty(new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (byte) 15).toItemStack()));
pagination.addToIterator(inventoryContents.newIterator(SlotIterator.Type.HORIZONTAL, SlotPos.of(1,1 )));
inventoryContents.set(5,3,ClickableItem.of(
new ItemBuilder(Material.ARROW).setName("&fPoprzednia Strona").toItemStack(),
event -> this.inventory.open(player, pagination.previous().getPage())));
inventoryContents.set(5,4, ClickableItem.empty(
new ItemBuilder(Material.CAULDRON).setName("&7INFORMACJE")
.setLore(Arrays.asList("","")).toItemStack()));
inventoryContents.set(5,5,ClickableItem.of(
new ItemBuilder(Material.ARROW).setName("&fNastępna Strona").toItemStack(),
event -> this.inventory.open(player, pagination.next().getPage())));
}
@Override
public void update(Player player, InventoryContents inventoryContents) {
}
public SmartInventory getInventory() {
return this.inventory;
}
}
The items put in borders maybe iterrator is wrong or something can someone give me a resollution ?
Use version 1.3 you won't need this normally, but in your case create Iterator and add the desired slot in blacklist like that :
SlotIterator iter = contents.newIterator(SlotIterator.Type.HORIZONTAL, 1, 1);
iter.blacklist(1,8);
iter.blacklist(2,0);
iter.blacklist(2,8);
iter.blacklist(3,0);
iter.blacklist(3,8);
iter.blacklist(4,0);
iter.blacklist(4,8);
pagination.addToIterator(iter);
You can also use iter.allowOverride(false) so the iterator will skip non-empty slots