Java Code Examples for org.bukkit.entity.HumanEntity#openInventory()
The following examples show how to use
org.bukkit.entity.HumanEntity#openInventory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Gui.java From IF with The Unlicense | 6 votes |
/** * Shows a gui to a player * * @param humanEntity the human entity to show the gui to */ public void show(@NotNull HumanEntity humanEntity) { inventory.clear(); //set the state to the top, so in case there are no longer any bottom part panes, their inventory will be shown again setState(State.TOP); humanEntityCache.storeAndClear(humanEntity); //initialize the inventory first panes.stream().filter(Pane::isVisible).forEach(pane -> pane.display(this, inventory, humanEntity.getInventory(), 0, 0, 9, getRows() + 4)); //ensure that the inventory is cached before being overwritten and restore it if we end up not needing the bottom part after all if (state == State.TOP) { humanEntityCache.restoreAndForget(humanEntity); } humanEntity.openInventory(inventory); }
Example 2
Source File: IconInventory.java From UHC with MIT License | 6 votes |
public void showTo(HumanEntity entity) { // how many icons do we want to show final int iconCount = icons.size(); // how many slots are required, in increments of 9, min 9, max 54 final int slotsRequired = Math.max( 9, Math.min( 54, INVENTORY_WIDTH * ((iconCount + INVENTORY_WIDTH - 1) / INVENTORY_WIDTH) ) ); // Create and render inventory final Inventory inventory = Bukkit.createInventory(null, slotsRequired, title); final ItemStack[] contents = new ItemStack[slotsRequired]; for (int i = 0; i < icons.size(); i++) { contents[i] = icons.get(i); } inventory.setContents(contents); // Show to player entity.openInventory(inventory); openedInventories.add(inventory); }
Example 3
Source File: GuiWindow.java From FunnyGuilds with Apache License 2.0 | 4 votes |
public void open(HumanEntity entity) { Inventory inv = Bukkit.createInventory(entity, this.wrap().getSize(), this.name); inv.setContents(this.wrap().getContents()); entity.openInventory(inv); }
Example 4
Source File: PaginatedGUI.java From SpigotPaginatedGUI with MIT License | 2 votes |
/** * Simply an alias that executes {@link HumanEntity#closeInventory()} and then * {@link HumanEntity#openInventory(Inventory)}. * * @param holder The HumanEntity that you wish to refresh the inventory for. */ public void refreshInventory(HumanEntity holder){ holder.closeInventory(); holder.openInventory(getInventory()); }
Example 5
Source File: PaginatedGUI.java From Statz with GNU General Public License v3.0 | 2 votes |
/** * Simply an alias that executes {@link HumanEntity#closeInventory()} and then * {@link HumanEntity#openInventory(Inventory)}. * * @param holder The HumanEntity that you wish to refresh the inventory for. */ public void refreshInventory(HumanEntity holder) { holder.closeInventory(); holder.openInventory(getInventory()); }