Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem With FillBorders #220

Open
DizzyMontage13 opened this issue Jul 15, 2023 · 3 comments
Open

Problem With FillBorders #220

DizzyMontage13 opened this issue Jul 15, 2023 · 3 comments

Comments

@DizzyMontage13
Copy link

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;
}

}

image

@DizzyMontage13
Copy link
Author

The items put in borders maybe iterrator is wrong or something can someone give me a resollution ?

@NightLabMC
Copy link

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);

@MinusKube
Copy link
Owner

You can also use iter.allowOverride(false) so the iterator will skip non-empty slots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants