TJGames
TJGames

Reputation: 33

Minecraft Spigot create a New PlayerInventory

So I want to create a new PlayerInventory, and am not sure if this is the way to go about it.

PlayerInventory inv = (PlayerInventory) Bukkit.createInventory(null, InventoryType.PLAYER);

Upvotes: 0

Views: 1714

Answers (1)

A1trdX
A1trdX

Reputation: 345

I wanted to ask you: "And what's your problem?" If you exactly want to create player's inventory, then you're right. But I can't imagine why you want players inventory. If you mean to open inventory to player like a chest, then you can use another Bukkit method:

// Bukkit.createInventory(InventoryHolder owner, int size, String title);
// size = 9 * rows
Inventory inv = Bukkit.createInventory(null, 27, "Title");
player.openInventory(inv);

If you just want to get inventory and change it, then:

Inventory inv = player.getInventory();

Upvotes: 2

Related Questions