Comments (4)
EDIT: the Item is not "removed" from the pages, but is duplicated. But the Click Listener overrides the clicklistener of the toolbar, so the problem remains.
from spigui.
Interesting... might be a case of a <=
instead of a <
.
Are you able to share some code for the inventory (quick n' dirty is fine!) to reproduce the issue?
from spigui.
Yes of cause, I can paste the code when im home again :)
from spigui.
This is the breakdown of my code. If i left something Project-Specific in there im sorry :'D
private void openJoinInventory(Player player){
SGMenu menu = getMessageMenu("§aJoin Messages", player, CustomMessageType.JOIN);
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1);
player.openInventory(menu.getInventory());
}
private SGMenu getMessageMenu(String title, Player player){
List<String> messages = new ArrayList<>();
for(int i = 0; i<50; i++){
messages.add("String " + i);
}
SGMenu menu = this.gui.create(title, 6);
menu.setAutomaticPaginationEnabled(true);
menu.setRowsPerPage(5);
for(String msg : messages){
ItemStack msgStack = new ItemBuilder(Material.PAPER).name(msg).build();
SGButton messageButton = new SGButton(msgStack).withListener(event -> {
Player clicker = (Player) event.getWhoClicked();
clicker.playSound(clicker.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
});
menu.addButton(messageButton);
}
setupToolBar(menu, CustomMessageType.JOIN);
return menu;
}
private void setupToolBar(SGMenu menu){
menu.setToolbarBuilder((slot, page, buttonType, sgMenu) -> switch (buttonType) {
case CURRENT_BUTTON -> new SGButton(new ItemBuilder(Material.NAME_TAG)
.name("&7&lSeite " + (menu.getCurrentPage() + 1) + " von " + menu.getMaxPage())
.build()
).withListener(event -> event.setResult(Event.Result.DENY));
case NEXT_BUTTON -> {
if (page == menu.getMaxPage()) yield null;
if (menu.getCurrentPage() < menu.getMaxPage() - 1) {
yield new SGButton(new ItemBuilder(NEXT_SKULL)
.name("&a&lNächste Seite →")
.build()
).withListener(event -> {
event.setResult(Event.Result.DENY);
menu.nextPage(event.getWhoClicked());
Player player = (Player) event.getWhoClicked();
player.playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1, 1);
});
}
yield null;
}
case PREV_BUTTON -> {
if (page == 0) yield null;
if (menu.getCurrentPage() > 0) {
yield new SGButton(new ItemBuilder(BACK_SKULL)
.name("&a&l← Vorherige Seite").build()
).withListener(event -> {
event.setResult(Event.Result.DENY);
menu.previousPage(event.getWhoClicked());
Player player = (Player) event.getWhoClicked();
player.playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1, 1);
});
}
yield null;
}
case UNASSIGNED -> {
if(slot == 1) {
yield new SGButton(HOME_SKULL)
.withListener(event -> {
Player player = (Player) event.getWhoClicked();
player.closeInventory();
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
});
} else if(slot == 7) {
yield new SGButton(
new ItemBuilder(Material.LAVA_BUCKET).name("§cClear Message").build()
).withListener(event -> {
Player player = (Player) event.getWhoClicked();
player.closeInventory();
player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_BURN, 1, 1);
});
}
yield null;
}
});
}
from spigui.
Related Issues (20)
- SGMenuListener does not handle InventoryDragEvent HOT 3
- Add or change some PaginationButtons HOT 2
- No items in close event HOT 7
- Add ChatComponent support HOT 5
- Remove Page Buttons HOT 2
- Plugin does not check if the clicked inventory is the actual GUI HOT 4
- [QUESTION TO USERS] What Minecraft versions are this library being used with? HOT 6
- Block unrealistic interactions to avoid getting items from gui HOT 6
- Customizing Toolbar (Pagination) buttons HOT 2
- does this plugin have docs? HOT 3
- No way to remove the current page item HOT 2
- ClassNotFound error with Gradle HOT 7
- how do i get it to list player heads in a gui for every player on the server HOT 3
- Need a Support quickly HOT 1
- Please Write Docs! HOT 5
- InventoryClickEvent click types HOT 2
- Bottom inventory event
- Toolbar Button and Menu Slots
- Shift + click not firing Listener
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spigui.