Hey, I was wondering how to open a virtual chest/inventory, if there's a tutorial anywhere that I've missed please link me. Thanks.
Idk about the tutorial but I think that you do Bukkit.getServer().createInventory or something like that, check that on bukkits docs about it!
@davejavu Create an inventory like gjossep said and store it somewhere so that you can call it up when you need. Code: public class VirtualInventory { Inventory inventory; Player owner; String name; public VirtualInventory(Player p, String name) { this.inventory = Bukkit.createInventory(p, 27, name); this.owner = player; this.name = name; } public Inventory getInventory() { return this.inventory(); } public Player getOwner() { return this.name; } public String getName() { return this.title; } Then to create a new instance of this object and save it, you would do something like: Code: public Inventory createInventory(player, name) { VirtualInventory vi = new VirtualInventory(player, name); return vi; } HashMap<Player, VirtualInventory> inventories = new HashMap<Player, VirtualInventory>(); public void saveInventory(Player player, VirtualInventory vi) { inventories.put(player, vi); } Then to call up an inventory, you would do: Code: player.openInventory(inventories.get(player).getInventory()); I made the VirtualInventory class because you might need to add your own methods in there. If you don't, you can simply create the inventories and store them in the hashmap and call them up when you need.
Hup hup, now, havent we already said it enought times that you should never store the player object? Store the name as a reference, that way you can get the player object by calling: server.getPlayer(playername);
@r0306 Thanks for the help so far, it's epic. Now how would I say, open an inventory and put items in it that the player CANNOT remove?
@davejavu If you want to disallow the player from changing the WHOLE inventory, you can simply cancel the event if the inventory matches: Code: @EventHandler public void inventoryClick(InventoryClickEvent event) { if (event.getInventory().getName().equalsIgnoreCase("the other inventory name")) event.setCancelled(true); }