Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I open my own inventory via a Event?

I am trying to open up my inventory whenever I pick up an item. This is in Bukkit.

Here is the event so far, the arguments for player.openInventory are empty.

@EventHandler
public void blank(PlayerDropItemEvent e){
    Player player = e.getPlayer();
    player.openInventory();
}
like image 647
Mark Johnson Avatar asked Apr 23 '15 00:04

Mark Johnson


People also ask

How do you create an inventory system?

The following are the key elements to a well organized inventory tracking system. Create well designed location names and clearly label all locations where items may be stored. Use well organized, consistent, and unique descriptions of your items, starting with nouns. Keep item identifiers (part numbers, sku's, etc..)

What are the 4 types of inventory management?

The 4 Types of Inventory Management The types of inventory management are Raw Materials, Works-In-Process, Maintenance, Repair and Operations or MRO and Finished Goods.

What are the 3 major inventory management techniques?

In this article we'll dive into the three most common inventory management strategies that most manufacturers operate by: the pull strategy, the push strategy, and the just in time (JIT) strategy.


2 Answers

Try using player.getInventory() to retrieve their inventory then using player.openInventory(inventory) to open it.

@EventHandler
public void blank(PlayerDropItemEvent e) {
    Player player = e.getPlayer();
    Inventory inventory = player.getInventory();
    player.openInventory(inventory);
}
like image 54
Rishaan Gupta Avatar answered Oct 17 '22 21:10

Rishaan Gupta


To get a player's inventory, you could use:

player.getInventory();

If you wanted to open the player's inventory, you could use:

player.openInventory(player.getInventory());

So, your code could look something like this:

@EventHandler
public void dropItem(PlayerDropItemEvent e){
    Player player = e.getPlayer(); //get the player that dropped the item
    player.openInventory(player.getInventory()); //open the player's inventory
}
like image 26
Jojodmo Avatar answered Oct 17 '22 20:10

Jojodmo