Add a method on InventoryView to get the MenuType (#12193)

Since there is a new (better) way to create views for players using MenuType, it would be nice to also be able to get it back from InventoryView after creating.
This commit is contained in:
Glicz
2025-05-01 03:43:51 +02:00
committed by GitHub
parent 0e9b94d533
commit 835b955913
4 changed files with 25 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package org.bukkit.inventory;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -321,4 +322,16 @@ public interface InventoryView {
*/
@Deprecated(since = "1.21.1") // Paper
public void setTitle(@NotNull String title);
/**
* Gets the menu type of the inventory view if applicable.
* <p>
* Some inventory types do not support a menu type. In such cases, this method
* returns null. This typically applies to inventories belonging to entities
* like players or animals (e.g., a horse).
*
* @return the menu type of the inventory view or null if not applicable
*/
@ApiStatus.Experimental
@Nullable MenuType getMenuType();
}