add getters and setters and returning single page inventory if amount of items is small enough
This commit is contained in:
@@ -7,13 +7,93 @@ public class GUI implements InventoryHolder {
|
||||
public static final int MAX_INVENTORY_SIZE = 54; // max size of inventory before pages are needed
|
||||
public static final int MAX_PAGE_INVENTORY_SIZE = 45; // max amount of items on a page
|
||||
|
||||
/**
|
||||
* Inventory that will be displayed
|
||||
*/
|
||||
private Inventory inventory;
|
||||
|
||||
/**
|
||||
* Current page being displayed
|
||||
*/
|
||||
private int currentPage;
|
||||
|
||||
/**
|
||||
* Items to be displayed in the GUI. This is the full list of items that can be displayed across all pages.
|
||||
*/
|
||||
private List<ItemStack> items;
|
||||
|
||||
/**
|
||||
* Number of items per page
|
||||
*/
|
||||
private int pageSize;
|
||||
|
||||
/**
|
||||
* Gets the current page being displayed
|
||||
* @return the current page number
|
||||
*/
|
||||
public int getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current page to be displayed
|
||||
* @param currentPage the page number to set
|
||||
*/
|
||||
public void setCurrentPage(int currentPage) {
|
||||
this.currentPage = currentPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of items to be displayed in the GUI
|
||||
* @return the list of items
|
||||
*/
|
||||
public List<ItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of items to be displayed in the GUI
|
||||
* @param items the list of items to set
|
||||
*/
|
||||
public void setItems(List<ItemStack> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of items per page
|
||||
* @return the page size
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of items per page
|
||||
* @param pageSize the page size to set
|
||||
*/
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the inventory to be displayed
|
||||
* @param inventory the inventory to set
|
||||
*/
|
||||
public void setInventory(Inventory inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getInventory'");
|
||||
if (items.size() <= MAX_INVENTORY_SIZE) {
|
||||
inventory = Bukkit.createInventory(this, MAX_INVENTORY_SIZE, "Coordinates Menu");
|
||||
for (ItemStack item : items) {
|
||||
inventory.addItem(item);
|
||||
}
|
||||
return inventory;
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Paged inventory not yet implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user