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

Stop SlotIterator #203

Open
ElseJunsuk opened this issue Dec 30, 2021 · 8 comments
Open

Stop SlotIterator #203

ElseJunsuk opened this issue Dec 30, 2021 · 8 comments

Comments

@ElseJunsuk
Copy link

I want to get the current column and row.

@Leguan16
Copy link

Leguan16 commented Jan 2, 2022

Did you never use an iterator? Or an InputStream?

@ElseJunsuk
Copy link
Author

sorry. I changed the question. I tried to list online players' skulls in the GUI using SlotIterator, but the last created player's skull is added to all slots. How can I stop this?

@ElseJunsuk ElseJunsuk changed the title How to use 'SlotIterator.get()' method? Stop SlotIterator Jan 4, 2022
@ElseJunsuk
Copy link
Author

code:

for (Player all : Bukkit.getOnlinePlayers()) {
    iter.set(ClickableItem.of(skull, e -> {
        . . .
    }));
}

@Leguan16
Copy link

Leguan16 commented Jan 4, 2022

I would recommend using pages:

Get the pagination with contents.getPagination() and then add the array with

pagination​.​setItems(playerArray); 
pagination​.​setItemsPerPage(​2​ ​*​ ​9​);  //this depends on what your inventory size is.
pagination​.​addToIterator(contents​.​newIterator(​SlotIterator​.​Type​.​HORIZONTAL​, ​0​, ​0​));

I would recommend adding another item to switch the pages. But just read through the documentation for this.

@ElseJunsuk
Copy link
Author

Very nice! Thanks for your support!

@ElseJunsuk ElseJunsuk reopened this Jan 5, 2022
@ElseJunsuk
Copy link
Author

I would recommend using pages:

Get the pagination with contents.getPagination() and then add the array with

pagination​.​setItems(playerArray); 
pagination​.​setItemsPerPage(​2​ ​*​ ​9​);  //this depends on what your inventory size is.
pagination​.​addToIterator(contents​.​newIterator(​SlotIterator​.​Type​.​HORIZONTAL​, ​0​, ​0​));

I would recommend adding another item to switch the pages. But just read through the documentation for this.

Excuse, do you know how to stop appending at a specific row or column in the current page?

@Leguan16
Copy link

Leguan16 commented Jan 5, 2022

What do you mean?

@ElseJunsuk
Copy link
Author

Due to the addToIterator method, the number of players is added from slot 0 to the last slot in the inventory. But I want to add the player's head only up to the 4th row and start from the next page after the 4th row.

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

2 participants