Replaced Menu data with Menu state

This commit is contained in:
Auxilor
2022-04-27 16:07:38 +01:00
parent 11c49a543f
commit fb240bfd0a
3 changed files with 60 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@@ -59,6 +60,37 @@ public interface Menu {
*/
List<ItemStack> getCaptiveItems(@NotNull Player player);
/**
* Add state for a player.
*
* @param player The player.
* @param key The key.
* @param value The state.
*/
void addState(@NotNull Player player,
@NotNull String key,
@Nullable Object value);
/**
* Get state for a player.
*
* @param player The player.
* @param key The key.
* @param <T> The type of state.
* @return The value.
*/
@Nullable <T> T getState(@NotNull Player player,
@NotNull String key);
/**
* Get state for a player.
*
* @param player The player.
* @return The state.
*/
Map<String, Object> getState(@NotNull Player player);
/**
* Write data.
*
@@ -68,7 +100,9 @@ public interface Menu {
* @param value The value.
* @param <T> The type.
* @param <Z> The type.
* @deprecated Use addState instead.
*/
@Deprecated(since = "6.35.0", forRemoval = true)
<T, Z> void writeData(@NotNull Player player,
@NotNull NamespacedKey key,
@NotNull PersistentDataType<T, Z> type,
@@ -83,7 +117,9 @@ public interface Menu {
* @param <T> The type.
* @param <Z> The type.
* @return The data.
* @deprecated Use getState instead.
*/
@Deprecated(since = "6.35.0", forRemoval = true)
@Nullable <T, Z> T readData(@NotNull Player player,
@NotNull NamespacedKey key,
@NotNull PersistentDataType<T, Z> type);
@@ -93,7 +129,9 @@ public interface Menu {
*
* @param player The player.
* @return The keys.
* @deprecated Use getState instead.
*/
@Deprecated(since = "6.35.0", forRemoval = true)
Set<NamespacedKey> getKeys(@NotNull Player player);
/**