From 1917305f97416e8db24c3392f75aa41a8b739a46 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 14 Dec 2014 16:24:09 +0100 Subject: [PATCH] API for setting/removing hideflags on ItemStacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By: Fabian Faßbender --- .../java/org/bukkit/inventory/ItemFlag.java | 32 +++++++++++++++++++ .../org/bukkit/inventory/meta/ItemMeta.java | 31 ++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java b/paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java new file mode 100644 index 0000000000..2a8af7ba84 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java @@ -0,0 +1,32 @@ +package org.bukkit.inventory; + +/** + * A ItemFlag can hide some Attributes from ItemStacks + */ +public enum ItemFlag { + + /** + * Setting to show/hide enchants + */ + HIDE_ENCHANTS, + /** + * Setting to show/hide Attributes like Damage + */ + HIDE_ATTRIBUTES, + /** + * Setting to show/hide the unbreakable State + */ + HIDE_UNBREAKABLE, + /** + * Setting to show/hide what the ItemStack can break/destroy + */ + HIDE_DESTROYS, + /** + * Setting to show/hide where this ItemStack can be build/placed on + */ + HIDE_PLACED_ON, + /** + * Setting to show/hide potion effects on this ItemStack + */ + HIDE_POTION_EFFECTS; +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index 00f71ce2e9..459e09ca5a 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java @@ -2,9 +2,11 @@ package org.bukkit.inventory.meta; import java.util.List; import java.util.Map; +import java.util.Set; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; /** * This type represents the storage mechanism for auxiliary item data. @@ -124,6 +126,35 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { */ boolean hasConflictingEnchant(Enchantment ench); + /** + * Set itemflags which should be ignored when rendering a ItemStack in the Client. This Method does silently ignore double set itemFlags. + * + * @param itemFlags The hideflags which shouldn't be rendered + */ + void addItemFlags(ItemFlag... itemFlags); + + /** + * Remove specific set of itemFlags. This tells the Client it should render it again. This Method does silently ignore double removed itemFlags. + * + * @param itemFlags Hideflags which should be removed + */ + void removeItemFlags(ItemFlag... itemFlags); + + /** + * Get current set itemFlags. The collection returned is unmodifiable. + * + * @return A set of all itemFlags set + */ + Set getItemFlags(); + + /** + * Check if the specified flag is present on this item. + * + * @param flag the flag to check + * @return if it is present + */ + boolean hasItemFlag(ItemFlag flag); + @SuppressWarnings("javadoc") ItemMeta clone(); }