@@ -1,76 +1,61 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
/**
|
||||
* Represents a smelting recipe.
|
||||
*/
|
||||
public class FurnaceRecipe implements Recipe {
|
||||
public class FurnaceRecipe implements Recipe, Keyed {
|
||||
private final NamespacedKey key;
|
||||
private ItemStack output;
|
||||
private ItemStack ingredient;
|
||||
private float experience;
|
||||
private int cookingTime;
|
||||
|
||||
/**
|
||||
* Create a furnace recipe to craft the specified ItemStack.
|
||||
*
|
||||
* @param result The item you want the recipe to create.
|
||||
* @param source The input material.
|
||||
*/
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, Material source) {
|
||||
this(result, source, 0, 0);
|
||||
this(NamespacedKey.randomKey(), result, source, 0, 0, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a furnace recipe to craft the specified ItemStack.
|
||||
*
|
||||
* @param result The item you want the recipe to create.
|
||||
* @param source The input material.
|
||||
*/
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, MaterialData source) {
|
||||
this(result, source.getItemType(), source.getData(), 0);
|
||||
this(NamespacedKey.randomKey(), result, source.getItemType(), source.getData(), 0, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a furnace recipe to craft the specified ItemStack.
|
||||
*
|
||||
* @param result The item you want the recipe to create.
|
||||
* @param source The input material.
|
||||
* @param experience The experience given by this recipe
|
||||
*/
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, MaterialData source, float experience) {
|
||||
this(result, source.getItemType(), source.getData(), experience);
|
||||
this(NamespacedKey.randomKey(), result, source.getItemType(), source.getData(), experience, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a furnace recipe to craft the specified ItemStack.
|
||||
*
|
||||
* @param result The item you want the recipe to create.
|
||||
* @param source The input material.
|
||||
* @param data The data value. (Note: This is currently ignored by the
|
||||
* CraftBukkit server.)
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, Material source, int data) {
|
||||
this(result, source, data, 0);
|
||||
this(NamespacedKey.randomKey(), result, source, data, 0, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a furnace recipe to craft the specified ItemStack.
|
||||
*
|
||||
* @param key The unique recipe key
|
||||
* @param result The item you want the recipe to create.
|
||||
* @param source The input material.
|
||||
* @param data The data value. (Note: This is currently ignored by the
|
||||
* CraftBukkit server.)
|
||||
* @param experience The experience given by this recipe
|
||||
* @deprecated Magic value
|
||||
* @param cookingTime The cooking time (in ticks)
|
||||
*/
|
||||
public FurnaceRecipe(NamespacedKey key, ItemStack result, Material source, float experience, int cookingTime) {
|
||||
this(key, result, source, 0, experience, cookingTime);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, Material source, int data, float experience) {
|
||||
public FurnaceRecipe(NamespacedKey key, ItemStack result, Material source, int data, float experience, int cookingTime) {
|
||||
this.key = key;
|
||||
this.output = new ItemStack(result);
|
||||
this.ingredient = new ItemStack(source, 1, (short) data);
|
||||
this.experience = experience;
|
||||
this.cookingTime = cookingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,4 +128,28 @@ public class FurnaceRecipe implements Recipe {
|
||||
public float getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cooking time for this recipe in ticks.
|
||||
*
|
||||
* @param cookingTime new cooking time
|
||||
*/
|
||||
public void setCookingTime(int cookingTime) {
|
||||
Preconditions.checkArgument(cookingTime >= 0, "cookingTime must be >= 0");
|
||||
this.cookingTime = cookingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cooking time for this recipe in ticks.
|
||||
*
|
||||
* @return cooking time
|
||||
*/
|
||||
public int getCookingTime() {
|
||||
return cookingTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,17 +157,6 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*/
|
||||
public void setStorageContents(ItemStack[] items) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains any ItemStacks with the given
|
||||
* materialId
|
||||
*
|
||||
* @param materialId The materialId to check for
|
||||
* @return true if an ItemStack in this inventory contains the materialId
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean contains(int materialId);
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains any ItemStacks with the given
|
||||
* material.
|
||||
@@ -191,19 +180,6 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*/
|
||||
public boolean contains(ItemStack item);
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains any ItemStacks with the given
|
||||
* materialId, adding to at least the minimum amount specified.
|
||||
*
|
||||
* @param materialId The materialId to check for
|
||||
* @param amount The minimum amount to look for
|
||||
* @return true if this contains any matching ItemStack with the given
|
||||
* materialId and amount
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean contains(int materialId, int amount);
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains any ItemStacks with the given
|
||||
* material, adding to at least the minimum amount specified.
|
||||
@@ -242,21 +218,6 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*/
|
||||
public boolean containsAtLeast(ItemStack item, int amount);
|
||||
|
||||
/**
|
||||
* Returns a HashMap with all slots and ItemStacks in the inventory with
|
||||
* given materialId.
|
||||
* <p>
|
||||
* The HashMap contains entries where, the key is the slot index, and the
|
||||
* value is the ItemStack in that slot. If no matching ItemStack with the
|
||||
* given materialId is found, an empty map is returned.
|
||||
*
|
||||
* @param materialId The materialId to look for
|
||||
* @return A HashMap containing the slot index, ItemStack pairs
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public HashMap<Integer, ? extends ItemStack> all(int materialId);
|
||||
|
||||
/**
|
||||
* Returns a HashMap with all slots and ItemStacks in the inventory with
|
||||
* the given Material.
|
||||
@@ -285,17 +246,6 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*/
|
||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack item);
|
||||
|
||||
/**
|
||||
* Finds the first slot in the inventory containing an ItemStack with the
|
||||
* given materialId.
|
||||
*
|
||||
* @param materialId The materialId to look for
|
||||
* @return The slot index of the given materialId or -1 if not found
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public int first(int materialId);
|
||||
|
||||
/**
|
||||
* Finds the first slot in the inventory containing an ItemStack with the
|
||||
* given material
|
||||
@@ -323,15 +273,6 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*/
|
||||
public int firstEmpty();
|
||||
|
||||
/**
|
||||
* Removes all stacks in the inventory matching the given materialId.
|
||||
*
|
||||
* @param materialId The material to remove
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public void remove(int materialId);
|
||||
|
||||
/**
|
||||
* Removes all stacks in the inventory matching the given material.
|
||||
*
|
||||
|
||||
@@ -121,4 +121,17 @@ public interface ItemFactory {
|
||||
* @return the default color for leather armor
|
||||
*/
|
||||
Color getDefaultLeatherColor();
|
||||
|
||||
/**
|
||||
* Apply a material change for an item meta. Do not use under any
|
||||
* circumstances.
|
||||
*
|
||||
* @param meta
|
||||
* @param material
|
||||
* @return updated material
|
||||
* @throws IllegalArgumentException
|
||||
* @deprecated for internal use only
|
||||
*/
|
||||
@Deprecated
|
||||
Material updateMaterial(final ItemMeta meta, final Material material) throws IllegalArgumentException;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Utility;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
@@ -17,26 +18,14 @@ import org.bukkit.material.MaterialData;
|
||||
* Represents a stack of items
|
||||
*/
|
||||
public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
private int type = 0;
|
||||
private Material type = Material.AIR;
|
||||
private int amount = 0;
|
||||
private MaterialData data = null;
|
||||
private short durability = 0;
|
||||
private ItemMeta meta;
|
||||
|
||||
@Utility
|
||||
protected ItemStack() {}
|
||||
|
||||
/**
|
||||
* Defaults stack size to 1, with no extra data
|
||||
*
|
||||
* @param type item material id
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack(final int type) {
|
||||
this(type, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults stack size to 1, with no extra data
|
||||
*
|
||||
@@ -46,18 +35,6 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
this(type, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* An item stack with no extra data
|
||||
*
|
||||
* @param type item material id
|
||||
* @param amount stack size
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack(final int type, final int amount) {
|
||||
this(type, amount, (short) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* An item stack with no extra data
|
||||
*
|
||||
@@ -65,22 +42,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param amount stack size
|
||||
*/
|
||||
public ItemStack(final Material type, final int amount) {
|
||||
this(type.getId(), amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* An item stack with the specified damage / durability
|
||||
*
|
||||
* @param type item material id
|
||||
* @param amount stack size
|
||||
* @param damage durability / damage
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack(final int type, final int amount, final short damage) {
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
this.durability = damage;
|
||||
this(type, amount, (short) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,25 +53,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param damage durability / damage
|
||||
*/
|
||||
public ItemStack(final Material type, final int amount, final short damage) {
|
||||
this(type.getId(), amount, damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type the raw type id
|
||||
* @param amount the amount in the stack
|
||||
* @param damage the damage value of the item
|
||||
* @param data the data value or null
|
||||
* @deprecated this method uses an ambiguous data byte object
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack(final int type, final int amount, final short damage, final Byte data) {
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
this.durability = damage;
|
||||
if (data != null) {
|
||||
createData(data);
|
||||
this.durability = data;
|
||||
}
|
||||
this(type, amount, damage, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +65,15 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack(final Material type, final int amount, final short damage, final Byte data) {
|
||||
this(type.getId(), amount, damage, data);
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
if (damage != 0) {
|
||||
setDurability(damage);
|
||||
}
|
||||
if (data != null) {
|
||||
createData(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,12 +85,11 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*/
|
||||
public ItemStack(final ItemStack stack) throws IllegalArgumentException {
|
||||
Validate.notNull(stack, "Cannot copy null stack");
|
||||
this.type = stack.getTypeId();
|
||||
this.type = stack.getType();
|
||||
this.amount = stack.getAmount();
|
||||
this.durability = stack.getDurability();
|
||||
this.data = stack.getData();
|
||||
if (stack.hasItemMeta()) {
|
||||
setItemMeta0(stack.getItemMeta(), getType0());
|
||||
setItemMeta0(stack.getItemMeta(), type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,16 +100,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*/
|
||||
@Utility
|
||||
public Material getType() {
|
||||
return getType0(getTypeId());
|
||||
}
|
||||
|
||||
private Material getType0() {
|
||||
return getType0(this.type);
|
||||
}
|
||||
|
||||
private static Material getType0(int id) {
|
||||
Material material = Material.getMaterial(id);
|
||||
return material == null ? Material.AIR : material;
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,35 +113,13 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
@Utility
|
||||
public void setType(Material type) {
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
setTypeId(type.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type id of this item
|
||||
*
|
||||
* @return Type Id of the items in this stack
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public int getTypeId() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type id of this item
|
||||
* <p>
|
||||
* Note that in doing so you will reset the MaterialData for this stack
|
||||
*
|
||||
* @param type New type id to set the items in this stack to
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTypeId(int type) {
|
||||
this.type = type;
|
||||
if (this.meta != null) {
|
||||
this.meta = Bukkit.getItemFactory().asMetaFor(meta, getType0());
|
||||
this.meta = Bukkit.getItemFactory().asMetaFor(meta, type);
|
||||
}
|
||||
if (type.isLegacy()) {
|
||||
createData((byte) 0);
|
||||
}
|
||||
createData((byte) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +146,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @return MaterialData for this item
|
||||
*/
|
||||
public MaterialData getData() {
|
||||
Material mat = getType();
|
||||
Material mat = Bukkit.getUnsafe().toLegacy(getType());
|
||||
if (data == null && mat != null && mat.getData() != null) {
|
||||
data = mat.getNewData((byte) this.getDurability());
|
||||
}
|
||||
@@ -240,7 +160,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param data New MaterialData for this item
|
||||
*/
|
||||
public void setData(MaterialData data) {
|
||||
Material mat = getType();
|
||||
Material mat = Bukkit.getUnsafe().toLegacy(getType());
|
||||
|
||||
if (data == null || mat == null || mat.getData() == null) {
|
||||
this.data = data;
|
||||
@@ -259,7 +179,11 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param durability Durability of this item
|
||||
*/
|
||||
public void setDurability(final short durability) {
|
||||
this.durability = durability;
|
||||
ItemMeta meta = getItemMeta();
|
||||
if (meta != null) {
|
||||
((Damageable) meta).setDamage(durability);
|
||||
setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +192,8 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @return Durability of this item
|
||||
*/
|
||||
public short getDurability() {
|
||||
return durability;
|
||||
ItemMeta meta = getItemMeta();
|
||||
return (meta == null) ? 0 : (short) ((Damageable) meta).getDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,13 +212,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
}
|
||||
|
||||
private void createData(final byte data) {
|
||||
Material mat = Material.getMaterial(type);
|
||||
|
||||
if (mat == null) {
|
||||
this.data = new MaterialData(type, data);
|
||||
} else {
|
||||
this.data = mat.getNewData(data);
|
||||
}
|
||||
this.data = type.getNewData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -335,7 +254,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
if (stack == this) {
|
||||
return true;
|
||||
}
|
||||
return getTypeId() == stack.getTypeId() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
|
||||
return getType()== stack.getType()&& getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -362,7 +281,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
|
||||
hash = hash * 31 + getTypeId();
|
||||
hash = hash * 31 + getType().hashCode();
|
||||
hash = hash * 31 + getAmount();
|
||||
hash = hash * 31 + (getDurability() & 0xffff);
|
||||
hash = hash * 31 + (hasItemMeta() ? (meta == null ? getItemMeta().hashCode() : meta.hashCode()) : 0);
|
||||
@@ -472,7 +391,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param level Level of the enchantment
|
||||
*/
|
||||
public void addUnsafeEnchantment(Enchantment ench, int level) {
|
||||
(meta == null ? meta = Bukkit.getItemFactory().getItemMeta(getType0()) : meta).addEnchant(ench, level, true);
|
||||
(meta == null ? meta = Bukkit.getItemFactory().getItemMeta(type) : meta).addEnchant(ench, level, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,12 +414,9 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
|
||||
result.put("v", Bukkit.getUnsafe().getDataVersion()); // Include version to indicate we are using modern material names (or LEGACY prefix)
|
||||
result.put("type", getType().name());
|
||||
|
||||
if (getDurability() != 0) {
|
||||
result.put("damage", getDurability());
|
||||
}
|
||||
|
||||
if (getAmount() != 1) {
|
||||
result.put("amount", getAmount());
|
||||
}
|
||||
@@ -521,7 +437,9 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @see ConfigurationSerializable
|
||||
*/
|
||||
public static ItemStack deserialize(Map<String, Object> args) {
|
||||
Material type = Material.getMaterial((String) args.get("type"));
|
||||
int version = (args.containsKey("v")) ? ((Number) args.get("v")).intValue() : -1;
|
||||
Material type = Material.getMaterial((String) args.get("type"), version < 0);
|
||||
|
||||
short damage = 0;
|
||||
int amount = 1;
|
||||
|
||||
@@ -556,6 +474,11 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
// Set damage again incase meta overwrote it
|
||||
if (args.containsKey("damage")) {
|
||||
result.setDurability(damage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -565,7 +488,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @return a copy of the current ItemStack's ItemData
|
||||
*/
|
||||
public ItemMeta getItemMeta() {
|
||||
return this.meta == null ? Bukkit.getItemFactory().getItemMeta(getType0()) : this.meta.clone();
|
||||
return this.meta == null ? Bukkit.getItemFactory().getItemMeta(this.type) : this.meta.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -587,7 +510,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* the {@link ItemFactory}
|
||||
*/
|
||||
public boolean setItemMeta(ItemMeta itemMeta) {
|
||||
return setItemMeta0(itemMeta, getType0());
|
||||
return setItemMeta0(itemMeta, type);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -602,6 +525,12 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
return false;
|
||||
}
|
||||
this.meta = Bukkit.getItemFactory().asMetaFor(itemMeta, material);
|
||||
|
||||
Material newType = Bukkit.getItemFactory().updateMaterial(meta, material);
|
||||
if (this.type != newType) {
|
||||
this.type = newType;
|
||||
}
|
||||
|
||||
if (this.meta == itemMeta) {
|
||||
this.meta = itemMeta.clone();
|
||||
}
|
||||
|
||||
@@ -197,18 +197,5 @@ public interface PlayerInventory extends Inventory {
|
||||
*/
|
||||
public void setHeldItemSlot(int slot);
|
||||
|
||||
/**
|
||||
* Clears all matching items from the inventory. Setting either value to
|
||||
* -1 will skip it's check, while setting both to -1 will clear all items
|
||||
* in your inventory unconditionally.
|
||||
*
|
||||
* @param id the id of the item you want to clear from the inventory
|
||||
* @param data the data of the item you want to clear from the inventory
|
||||
* @return The number of items cleared
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public int clear(int id, int data);
|
||||
|
||||
public HumanEntity getHolder();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents a book ({@link Material#BOOK_AND_QUILL} or {@link
|
||||
* Represents a book ({@link Material#WRITABLE_BOOK} or {@link
|
||||
* Material#WRITTEN_BOOK}) that can have a title, an author, and pages.
|
||||
*/
|
||||
public interface BookMeta extends ItemMeta {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
/**
|
||||
* Represents an item that has durability and can take damage.
|
||||
*/
|
||||
public interface Damageable {
|
||||
|
||||
/**
|
||||
* Checks to see if this item has damage
|
||||
*
|
||||
* @return true if this has damage
|
||||
*/
|
||||
boolean hasDamage();
|
||||
|
||||
/**
|
||||
* Gets the damage
|
||||
*
|
||||
* @return the damage
|
||||
*/
|
||||
int getDamage();
|
||||
|
||||
/**
|
||||
* Sets the damage
|
||||
*
|
||||
* @param damage item damage
|
||||
*/
|
||||
void setDamage(int damage);
|
||||
|
||||
Damageable clone();
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents a meta that can store a single FireworkEffect. An example
|
||||
* includes {@link Material#FIREWORK_CHARGE}.
|
||||
* includes {@link Material#FIREWORK_STAR}.
|
||||
*/
|
||||
public interface FireworkEffectMeta extends ItemMeta {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents a {@link Material#FIREWORK} and its effects.
|
||||
* Represents a {@link Material#FIREWORK_ROCKET} and its effects.
|
||||
*/
|
||||
public interface FireworkMeta extends ItemMeta {
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* Represents a skull ({@link Material#SKULL_ITEM}) that can have an owner.
|
||||
* Represents a skull that can have an owner.
|
||||
*/
|
||||
public interface SkullMeta extends ItemMeta {
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
/**
|
||||
* Represents a {@link Material#MONSTER_EGG} and it's spawned type.
|
||||
* Represents a spawn egg and it's spawned type.
|
||||
*/
|
||||
public interface SpawnEggMeta extends ItemMeta {
|
||||
|
||||
@@ -12,7 +11,9 @@ public interface SpawnEggMeta extends ItemMeta {
|
||||
* Get the type of entity this egg will spawn.
|
||||
*
|
||||
* @return The entity type. May be null for implementation specific default.
|
||||
* @deprecated different types are different items
|
||||
*/
|
||||
@Deprecated
|
||||
EntityType getSpawnedType();
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,9 @@ public interface SpawnEggMeta extends ItemMeta {
|
||||
*
|
||||
* @param type The entity type. May be null for implementation specific
|
||||
* default.
|
||||
* @deprecated different types are different items
|
||||
*/
|
||||
@Deprecated
|
||||
void setSpawnedType(EntityType type);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.TropicalFish;
|
||||
|
||||
/**
|
||||
* Represents a bucket of tropical fish.
|
||||
*/
|
||||
public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
|
||||
/**
|
||||
* Gets the color of the fish's pattern.
|
||||
* <p>
|
||||
* Plugins should check that hasVariant() returns <code>true</code> before
|
||||
* calling this method.
|
||||
*
|
||||
* @return pattern color
|
||||
*/
|
||||
DyeColor getPatternColor();
|
||||
|
||||
/**
|
||||
* Sets the color of the fish's pattern.
|
||||
* <p>
|
||||
* Setting this when hasVariant() returns <code>false</code> will initialize
|
||||
* all other values to unspecified defaults.
|
||||
*
|
||||
* @param color pattern color
|
||||
*/
|
||||
void setPatternColor(DyeColor color);
|
||||
|
||||
/**
|
||||
* Gets the color of the fish's body.
|
||||
* <p>
|
||||
* Plugins should check that hasVariant() returns <code>true</code> before
|
||||
* calling this method.
|
||||
*
|
||||
* @return pattern color
|
||||
*/
|
||||
DyeColor getBodyColor();
|
||||
|
||||
/**
|
||||
* Sets the color of the fish's body.
|
||||
* <p>
|
||||
* Setting this when hasVariant() returns <code>false</code> will initialize
|
||||
* all other values to unspecified defaults.
|
||||
*
|
||||
* @param color body color
|
||||
*/
|
||||
void setBodyColor(DyeColor color);
|
||||
|
||||
/**
|
||||
* Gets the fish's pattern.
|
||||
* <p>
|
||||
* Plugins should check that hasVariant() returns <code>true</code> before
|
||||
* calling this method.
|
||||
*
|
||||
* @return pattern
|
||||
*/
|
||||
TropicalFish.Pattern getPattern();
|
||||
|
||||
/**
|
||||
* Sets the fish's pattern.
|
||||
* <p>
|
||||
* Setting this when hasVariant() returns <code>false</code> will initialize
|
||||
* all other values to unspecified defaults.
|
||||
*
|
||||
* @param pattern new pattern
|
||||
*/
|
||||
void setPattern(TropicalFish.Pattern pattern);
|
||||
|
||||
/**
|
||||
* Checks for existence of a variant tag indicating a specific fish will be
|
||||
* spawned.
|
||||
*
|
||||
* @return if there is a variant
|
||||
*/
|
||||
boolean hasVariant();
|
||||
|
||||
TropicalFishBucketMeta clone();
|
||||
}
|
||||
Reference in New Issue
Block a user