From add89bc675b1d09c89320f3c8e75a577ddaa9e58 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 15 May 2022 19:33:03 -0700 Subject: [PATCH] deprecate old MaterialData api (#7585) --- .../api/Fix-Spigot-annotation-mistakes.patch | 288 ++++++++++++++++++ 1 file changed, 288 insertions(+) diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index db866cebe4..720fd6689d 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -42,6 +42,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static Tag getTag(@NotNull String registry, @NotNull NamespacedKey tag, @NotNull Class clazz) { return server.getTag(registry, tag, clazz); } +diff --git a/src/main/java/org/bukkit/GrassSpecies.java b/src/main/java/org/bukkit/GrassSpecies.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/GrassSpecies.java ++++ b/src/main/java/org/bukkit/GrassSpecies.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + + /** + * Represents the different types of grass. ++ * @deprecated use {@link org.bukkit.block.data.BlockData} + */ ++@Deprecated // Paper + public enum GrassSpecies { + + /** diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Location.java @@ -91,6 +105,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public boolean isLegacy() { return legacy; } +@@ -0,0 +0,0 @@ public enum Material implements Keyed { + * Gets the MaterialData class associated with this Material + * + * @return MaterialData associated with this Material ++ * @deprecated use {@link #createBlockData()} + */ + @NotNull ++ @Deprecated // Paper + public Class getData() { + Validate.isTrue(legacy, "Cannot get data class of Modern Material"); + return ctor.getDeclaringClass(); diff --git a/src/main/java/org/bukkit/NamespacedKey.java b/src/main/java/org/bukkit/NamespacedKey.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/NamespacedKey.java @@ -112,6 +137,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public NamespacedKey(@NotNull String namespace, @NotNull String key) { Preconditions.checkArgument(namespace != null && VALID_NAMESPACE.matcher(namespace).matches(), "Invalid namespace. Must be [a-z0-9._-]: %s", namespace); Preconditions.checkArgument(key != null && VALID_KEY.matcher(key).matches(), "Invalid key. Must be [a-z0-9/._-]: %s", key); +diff --git a/src/main/java/org/bukkit/NetherWartsState.java b/src/main/java/org/bukkit/NetherWartsState.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/NetherWartsState.java ++++ b/src/main/java/org/bukkit/NetherWartsState.java +@@ -0,0 +0,0 @@ + package org.bukkit; + ++// Paper start ++/** ++ * @deprecated use {@link org.bukkit.block.data.BlockData} and {@link org.bukkit.block.data.Ageable} ++ */ ++@Deprecated ++// Paper end + public enum NetherWartsState { + + /** +diff --git a/src/main/java/org/bukkit/SandstoneType.java b/src/main/java/org/bukkit/SandstoneType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/SandstoneType.java ++++ b/src/main/java/org/bukkit/SandstoneType.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + + /** + * Represents the three different types of Sandstone ++ * @deprecated use {@link org.bukkit.block.data.BlockData} + */ ++@Deprecated // Paper + public enum SandstoneType { + CRACKED(0x0), + GLYPHED(0x1), diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java @@ -151,6 +206,66 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + //@Deprecated // Paper public boolean refreshChunk(int x, int z); + /** +@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient + * @return The spawned {@link FallingBlock} instance + * @throws IllegalArgumentException if {@link Location} or {@link + * MaterialData} are null or {@link Material} of the {@link MaterialData} is not a block ++ * @deprecated use {@link #spawnFallingBlock(Location, BlockData)} + */ + @NotNull ++ @Deprecated // Paper + public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException; + + /** +diff --git a/src/main/java/org/bukkit/block/BlockState.java b/src/main/java/org/bukkit/block/BlockState.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/BlockState.java ++++ b/src/main/java/org/bukkit/block/BlockState.java +@@ -0,0 +0,0 @@ public interface BlockState extends Metadatable { + * Gets the metadata for this block state. + * + * @return block specific metadata ++ * @deprecated use {@link #getBlockData()} + */ + @NotNull ++ @Deprecated // Paper + MaterialData getData(); + + /** +@@ -0,0 +0,0 @@ public interface BlockState extends Metadatable { + * Sets the metadata for this block state. + * + * @param data New block specific metadata ++ * @deprecated use {@link #setBlockData(BlockData)} + */ ++ @Deprecated // Paper + void setData(@NotNull MaterialData data); + + /** +diff --git a/src/main/java/org/bukkit/entity/Enderman.java b/src/main/java/org/bukkit/entity/Enderman.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/Enderman.java ++++ b/src/main/java/org/bukkit/entity/Enderman.java +@@ -0,0 +0,0 @@ public interface Enderman extends Monster { + * Gets the id and data of the block that the Enderman is carrying. + * + * @return MaterialData containing the id and data of the block ++ * @deprecated use {@link #getCarriedBlock()} + */ + @NotNull ++ @Deprecated // Paper + public MaterialData getCarriedMaterial(); + + /** + * Sets the id and data of the block that the Enderman is carrying. + * + * @param material data to set the carried block to ++ * @deprecated use {@link #setCarriedBlock(BlockData)} + */ ++ @Deprecated // Paper + public void setCarriedMaterial(@NotNull MaterialData material); + /** diff --git a/src/main/java/org/bukkit/entity/LingeringPotion.java b/src/main/java/org/bukkit/entity/LingeringPotion.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -162,6 +277,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ +@Deprecated // Paper public interface LingeringPotion extends ThrownPotion { } +diff --git a/src/main/java/org/bukkit/entity/Minecart.java b/src/main/java/org/bukkit/entity/Minecart.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/Minecart.java ++++ b/src/main/java/org/bukkit/entity/Minecart.java +@@ -0,0 +0,0 @@ public interface Minecart extends Vehicle { + * Passing a null value will set the minecart to have no display block. + * + * @param material the material to set as display block. ++ * @deprecated use {@link #setDisplayBlockData(BlockData)} + */ ++ @Deprecated // Paper + public void setDisplayBlock(@Nullable MaterialData material); + + /** +@@ -0,0 +0,0 @@ public interface Minecart extends Vehicle { + * This function will return the type AIR if none is set. + * + * @return the block displayed by this minecart. ++ * @deprecated use {@link #getDisplayBlockData()} + */ + @NotNull ++ @Deprecated // Paper + public MaterialData getDisplayBlock(); + + /** diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Player.java @@ -260,6 +400,41 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Warning(false) public class PlayerShowEntityEvent extends PlayerEvent { +diff --git a/src/main/java/org/bukkit/generator/ChunkGenerator.java b/src/main/java/org/bukkit/generator/ChunkGenerator.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/generator/ChunkGenerator.java ++++ b/src/main/java/org/bukkit/generator/ChunkGenerator.java +@@ -0,0 +0,0 @@ public abstract class ChunkGenerator { + * @param y the y location in the chunk from minHeight (inclusive) - maxHeight (exclusive) + * @param z the z location in the chunk from 0-15 inclusive + * @param material the type to set the block to ++ * @deprecated use {@link #setBlock(int, int, int, BlockData)} + */ ++ @Deprecated // Paper + public void setBlock(int x, int y, int z, @NotNull MaterialData material); + + /** +@@ -0,0 +0,0 @@ public abstract class ChunkGenerator { + * @param yMax maximum y location (exclusive) in the chunk to set + * @param zMax maximum z location (exclusive) in the chunk to set + * @param material the type to set the blocks to ++ * @deprecated use {@link #setRegion(int, int, int, int, int, int, BlockData)} + */ ++ @Deprecated // Paper + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material); + + /** +@@ -0,0 +0,0 @@ public abstract class ChunkGenerator { + * @param y the y location in the chunk from minHeight (inclusive) - maxHeight (exclusive) + * @param z the z location in the chunk from 0-15 inclusive + * @return the type and data of the block or the MaterialData for air if x, y or z are outside the chunk's bounds ++ * @deprecated use {@link #getBlockData(int, int, int)} + */ + @NotNull ++ @Deprecated // Paper + public MaterialData getTypeAndData(int x, int y, int z); + + /** diff --git a/src/main/java/org/bukkit/inventory/CraftingInventory.java b/src/main/java/org/bukkit/inventory/CraftingInventory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/CraftingInventory.java @@ -283,6 +458,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Get the current recipe formed on the crafting inventory, if any. +diff --git a/src/main/java/org/bukkit/inventory/FurnaceRecipe.java b/src/main/java/org/bukkit/inventory/FurnaceRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/FurnaceRecipe.java ++++ b/src/main/java/org/bukkit/inventory/FurnaceRecipe.java +@@ -0,0 +0,0 @@ public class FurnaceRecipe extends CookingRecipe { + * + * @param input The input material. + * @return The changed recipe, so you can chain calls. ++ * @deprecated use {@link #setInputChoice(RecipeChoice)} + */ + @NotNull ++ @Deprecated + public FurnaceRecipe setInput(@NotNull MaterialData input) { + return setInput(input.getItemType(), input.getData()); + } diff --git a/src/main/java/org/bukkit/inventory/Inventory.java b/src/main/java/org/bukkit/inventory/Inventory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/Inventory.java @@ -358,6 +548,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public ItemStack(@NotNull final Material type, final int amount, final short damage) { this(type, amount, damage, null); } +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor + * Gets the MaterialData for this stack of items + * + * @return MaterialData for this item ++ * @deprecated cast to {@link org.bukkit.inventory.meta.BlockDataMeta} and use {@link org.bukkit.inventory.meta.BlockDataMeta#getBlockData(Material)} + */ + @Nullable ++ @Deprecated // Paper + public MaterialData getData() { + Material mat = Bukkit.getUnsafe().toLegacy(getType()); + if (data == null && mat != null && mat.getData() != null) { +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor + * Sets the MaterialData for this stack of items + * + * @param data New MaterialData for this item ++ * @deprecated cast to {@link org.bukkit.inventory.meta.BlockDataMeta} and use {@link org.bukkit.inventory.meta.BlockDataMeta#setBlockData(org.bukkit.block.data.BlockData)} + */ ++ @Deprecated // Paper + public void setData(@Nullable MaterialData data) { + if (data == null) { + this.data = data; @@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor * * @return a copy of the current ItemStack's ItemData @@ -403,6 +614,69 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public ItemStack getItem(@NotNull EquipmentSlot slot); /** +diff --git a/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/src/main/java/org/bukkit/inventory/ShapedRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java ++++ b/src/main/java/org/bukkit/inventory/ShapedRecipe.java +@@ -0,0 +0,0 @@ public class ShapedRecipe implements Recipe, Keyed { + * @param key The character that represents the ingredient in the shape. + * @param ingredient The ingredient. + * @return The changed recipe, so you can chain calls. ++ * @deprecated use {@link #setIngredient(char, RecipeChoice)} + */ + @NotNull ++ @Deprecated // Paper + public ShapedRecipe setIngredient(char key, @NotNull MaterialData ingredient) { + return setIngredient(key, ingredient.getItemType(), ingredient.getData()); + } +diff --git a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java ++++ b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java +@@ -0,0 +0,0 @@ public class ShapelessRecipe implements Recipe, Keyed { + * + * @param ingredient The ingredient to add. + * @return The changed recipe, so you can chain calls. ++ * @deprecated use {@link #addIngredient(RecipeChoice)} + */ + @NotNull ++ @Deprecated + public ShapelessRecipe addIngredient(@NotNull MaterialData ingredient) { + return addIngredient(1, ingredient); + } +@@ -0,0 +0,0 @@ public class ShapelessRecipe implements Recipe, Keyed { + * @param count How many to add (can't be more than 9!) + * @param ingredient The ingredient to add. + * @return The changed recipe, so you can chain calls. ++ * @deprecated use {@link #addIngredient(int, Material)} + */ + @NotNull ++ @Deprecated // Paper + public ShapelessRecipe addIngredient(int count, @NotNull MaterialData ingredient) { + return addIngredient(count, ingredient.getItemType(), ingredient.getData()); + } +@@ -0,0 +0,0 @@ public class ShapelessRecipe implements Recipe, Keyed { + * + * @param ingredient The ingredient to remove + * @return The changed recipe. ++ * @deprecated use {@link #removeIngredient(Material)} + */ + @NotNull ++ @Deprecated // Paper + public ShapelessRecipe removeIngredient(@NotNull MaterialData ingredient) { + return removeIngredient(ingredient.getItemType(), ingredient.getData()); + } +@@ -0,0 +0,0 @@ public class ShapelessRecipe implements Recipe, Keyed { + * @param count The number of copies to remove. + * @param ingredient The ingredient to remove. + * @return The changed recipe. ++ * @deprecated use {@link #removeIngredient(int, Material)} + */ + @NotNull ++ @Deprecated // Paper + public ShapelessRecipe removeIngredient(int count, @NotNull MaterialData ingredient) { + return removeIngredient(count, ingredient.getItemType(), ingredient.getData()); + } diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java @@ -451,3 +725,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override protected int getTextureIndex() { return getData() & 0x7; +diff --git a/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java b/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java ++++ b/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + + /** + * Represents the different textured blocks of mushroom. ++ * @deprecated use BlockData + */ ++@Deprecated // Paper + public enum MushroomBlockTexture { + + /**