mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-01-12 10:41:29 +01:00
fix page errors when less than a full page
This commit is contained in:
parent
721ad26106
commit
493ee0a0e6
@ -46,7 +46,7 @@ public class SongodaCore {
|
||||
* Whenever we make a major change to the core GUI, updater,
|
||||
* or other function used by the core, increment this number
|
||||
*/
|
||||
private final static int coreRevision = 4;
|
||||
private final static int coreRevision = 5;
|
||||
private final static int updaterVersion = 1;
|
||||
|
||||
private final static Set<PluginInfo> registeredPlugins = new HashSet<>();
|
||||
|
@ -636,7 +636,7 @@ public class Gui {
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
int lastPage = page;
|
||||
int lastPage = this.page;
|
||||
this.page = Math.max(1, Math.min(pages, page));
|
||||
if(pager != null && this.page != lastPage) {
|
||||
pager.onPageChange(new GuiPageEvent(this, guiManager, lastPage, page));
|
||||
|
@ -7,7 +7,6 @@ import com.songoda.core.gui.methods.Clickable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -134,14 +133,14 @@ public class SimplePagedGui extends Gui {
|
||||
rowsPerPage = useHeader ? 4 : 5;
|
||||
maxCellSlot = (this.cellItems.isEmpty() ? 0 : this.cellItems.keySet().stream().max(Integer::compare).get()) + 1;
|
||||
int maxRows = (int) Math.ceil(maxCellSlot / 9.);
|
||||
pages = (int) Math.ceil(maxRows / rowsPerPage);
|
||||
pages = (int) Math.max(1, Math.ceil(maxRows / (double) rowsPerPage));
|
||||
this.setRows(maxRows + (useHeader ? 1 : 0));
|
||||
|
||||
// create inventory view
|
||||
createInventory();
|
||||
|
||||
// populate and return the display inventory
|
||||
page = Math.min(page, pages);
|
||||
setPage(Math.min(page, pages));
|
||||
update();
|
||||
return inventory;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user