Improve ItemMeta#hasCustomModelData compatibility (#12414)

Ports the follow commits from spigot to paper.
All credits to go the respective commit authors listed below.

Bukkit: 47480cd07c0957a94b220f3087b851594b063e54
CraftBukkit: c6c8165aa0d5679b9b015b209c1645a222f8c3a6
CraftBukkit: d275d3b96e041f6421f3bb7de1e6022ea8be5456

By: md_5 <git@md-5.net>
By: Doc <nachito94@msn.com>
This commit is contained in:
Bjarne Koll
2025-04-14 13:23:39 +02:00
committed by GitHub
parent 121a7bf4eb
commit 7d5695d774
3 changed files with 50 additions and 20 deletions

View File

@@ -321,7 +321,12 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* custom item model.
*
* @return true if this has custom model data
* @deprecated more complex custom model data can be specified with
* {@link #hasCustomModelDataComponent()}. Integers from the old custom
* model data are equivalent to a single float in the
* {@link CustomModelDataComponent#getFloats()} list.
*/
@Deprecated(since = "1.21.5")
boolean hasCustomModelData();
/**
@@ -334,7 +339,12 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* before calling this method.
*
* @return the custom model data that is set
* @deprecated more complex custom model data can be specified with
* {@link #getCustomModelDataComponent()}. Integers from the old custom
* model data are equivalent to a single float in the
* {@link CustomModelDataComponent#getFloats()} list.
*/
@Deprecated(since = "1.21.5")
int getCustomModelData();
/**
@@ -359,9 +369,21 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* custom item model.
*
* @param data the data to set, or null to clear
* @deprecated more complex custom model data can be specified with
* {@link #setCustomModelDataComponent(org.bukkit.inventory.meta.components.CustomModelDataComponent)}.
* Integers from the old custom model data are equivalent to a single float
* in the {@link CustomModelDataComponent#setFloats(java.util.List)} list.
*/
@Deprecated(since = "1.21.5")
void setCustomModelData(@Nullable Integer data);
/**
* Checks if the custom model data component is set.
*
* @return if a custom model data component is set
*/
boolean hasCustomModelDataComponent();
/**
* Sets the custom model data component.
*

View File

@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
public interface CustomModelDataComponent extends ConfigurationSerializable {
/**
* Gets a list of the custom floats.
* Gets a list of the floats for the range_dispatch model type.
*
* @return unmodifiable list
*/
@@ -21,14 +21,14 @@ public interface CustomModelDataComponent extends ConfigurationSerializable {
List<Float> getFloats();
/**
* Sets a list of the custom floats.
* Sets a list of the floats for the range_dispatch model type.
*
* @param floats new list
*/
void setFloats(@NotNull List<Float> floats);
/**
* Gets a list of the custom flags.
* Gets a list of the booleans for the condition model type.
*
* @return unmodifiable list
*/
@@ -36,14 +36,14 @@ public interface CustomModelDataComponent extends ConfigurationSerializable {
List<Boolean> getFlags();
/**
* Sets a list of the custom flags.
* Sets a list of the booleans for the condition model type.
*
* @param flags new list
*/
void setFlags(@NotNull List<Boolean> flags);
/**
* Gets a list of the custom strings.
* Gets a list of strings for the select model type.
*
* @return unmodifiable list
*/
@@ -51,14 +51,14 @@ public interface CustomModelDataComponent extends ConfigurationSerializable {
List<String> getStrings();
/**
* Sets a list of the custom strings.
* Sets a list of strings for the select model type.
*
* @param strings new list
*/
void setStrings(@NotNull List<String> strings);
/**
* Gets a list of the custom colors.
* Gets a list of colors for the model type's tints.
*
* @return unmodifiable list
*/
@@ -66,7 +66,7 @@ public interface CustomModelDataComponent extends ConfigurationSerializable {
List<Color> getColors();
/**
* Sets a list of the custom colors.
* Sets a list of colors for the model type's tints.
*
* @param colors new list
*/