SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An interface to the inventory of an {@link AbstractHorse}.
|
||||
@@ -12,6 +13,7 @@ public interface AbstractHorseInventory extends Inventory {
|
||||
*
|
||||
* @return the saddle item
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getSaddle();
|
||||
|
||||
/**
|
||||
@@ -19,5 +21,5 @@ public interface AbstractHorseInventory extends Inventory {
|
||||
*
|
||||
* @param stack the new item
|
||||
*/
|
||||
void setSaddle(ItemStack stack);
|
||||
void setSaddle(@Nullable ItemStack stack);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the inventory of an Anvil.
|
||||
*/
|
||||
@@ -11,6 +13,7 @@ public interface AnvilInventory extends Inventory {
|
||||
*
|
||||
* @return the rename text
|
||||
*/
|
||||
@Nullable
|
||||
String getRenameText();
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the inventory of a Beacon.
|
||||
*/
|
||||
@@ -10,12 +12,13 @@ public interface BeaconInventory extends Inventory {
|
||||
*
|
||||
* @param item The new item
|
||||
*/
|
||||
void setItem(ItemStack item);
|
||||
void setItem(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Get the item powering the beacon.
|
||||
*
|
||||
* @return The current item.
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getItem();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.inventory;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BrewingStand;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the inventory of a Brewing Stand.
|
||||
@@ -13,6 +14,7 @@ public interface BrewerInventory extends Inventory {
|
||||
*
|
||||
* @return The ingredient.
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getIngredient();
|
||||
|
||||
/**
|
||||
@@ -20,13 +22,14 @@ public interface BrewerInventory extends Inventory {
|
||||
*
|
||||
* @param ingredient The ingredient
|
||||
*/
|
||||
void setIngredient(ItemStack ingredient);
|
||||
void setIngredient(@Nullable ItemStack ingredient);
|
||||
|
||||
/**
|
||||
* Get the current fuel for brewing.
|
||||
*
|
||||
* @return The fuel
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getFuel();
|
||||
|
||||
/**
|
||||
@@ -35,7 +38,8 @@ public interface BrewerInventory extends Inventory {
|
||||
*
|
||||
* @param fuel The fuel
|
||||
*/
|
||||
void setFuel(ItemStack fuel);
|
||||
void setFuel(@Nullable ItemStack fuel);
|
||||
|
||||
@Nullable
|
||||
BrewingStand getHolder();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the crafting inventories
|
||||
*/
|
||||
@@ -10,13 +13,15 @@ public interface CraftingInventory extends Inventory {
|
||||
*
|
||||
* @return The result item.
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getResult();
|
||||
|
||||
/**
|
||||
* Get the contents of the crafting matrix.
|
||||
*
|
||||
* @return The contents.
|
||||
* @return The contents. Individual entries may be null.
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack[] getMatrix();
|
||||
|
||||
/**
|
||||
@@ -24,16 +29,16 @@ public interface CraftingInventory extends Inventory {
|
||||
*
|
||||
* @param newResult The new result item.
|
||||
*/
|
||||
void setResult(ItemStack newResult);
|
||||
void setResult(@Nullable ItemStack newResult);
|
||||
|
||||
/**
|
||||
* Replace the contents of the crafting matrix
|
||||
*
|
||||
* @param contents The new contents.
|
||||
* @param contents The new contents. Individual entries may be null.
|
||||
* @throws IllegalArgumentException if the length of contents is greater
|
||||
* than the size of the crafting matrix.
|
||||
*/
|
||||
void setMatrix(ItemStack[] contents);
|
||||
void setMatrix(@NotNull ItemStack[] contents);
|
||||
|
||||
/**
|
||||
* Get the current recipe formed on the crafting inventory, if any.
|
||||
@@ -41,5 +46,6 @@ public interface CraftingInventory extends Inventory {
|
||||
* @return The recipe, or null if the current contents don't match any
|
||||
* recipe.
|
||||
*/
|
||||
@Nullable
|
||||
Recipe getRecipe();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the inventory of a Double Chest.
|
||||
@@ -12,6 +14,7 @@ public interface DoubleChestInventory extends Inventory {
|
||||
*
|
||||
* @return The left side inventory
|
||||
*/
|
||||
@NotNull
|
||||
Inventory getLeftSide();
|
||||
|
||||
/**
|
||||
@@ -19,7 +22,9 @@ public interface DoubleChestInventory extends Inventory {
|
||||
*
|
||||
* @return The right side inventory
|
||||
*/
|
||||
@NotNull
|
||||
Inventory getRightSide();
|
||||
|
||||
@Nullable
|
||||
DoubleChest getHolder();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the inventory of an Enchantment Table.
|
||||
*/
|
||||
@@ -10,13 +12,14 @@ public interface EnchantingInventory extends Inventory {
|
||||
*
|
||||
* @param item The new item
|
||||
*/
|
||||
void setItem(ItemStack item);
|
||||
void setItem(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Get the item being enchanted.
|
||||
*
|
||||
* @return The current item.
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getItem();
|
||||
|
||||
/**
|
||||
@@ -24,12 +27,13 @@ public interface EnchantingInventory extends Inventory {
|
||||
*
|
||||
* @param item The new item
|
||||
*/
|
||||
void setSecondary(ItemStack item);
|
||||
void setSecondary(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Get the secondary item being used for the enchant.
|
||||
*
|
||||
* @return The second item
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getSecondary();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An interface to a creatures inventory
|
||||
@@ -13,6 +15,7 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @return the currently held item
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack getItemInMainHand();
|
||||
|
||||
/**
|
||||
@@ -20,7 +23,7 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param item The item to put into the entities hand
|
||||
*/
|
||||
void setItemInMainHand(ItemStack item);
|
||||
void setItemInMainHand(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Gets a copy of the item the entity is currently holding
|
||||
@@ -28,6 +31,7 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @return the currently held item
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack getItemInOffHand();
|
||||
|
||||
/**
|
||||
@@ -35,7 +39,7 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param item The item to put into the entities hand
|
||||
*/
|
||||
void setItemInOffHand(ItemStack item);
|
||||
void setItemInOffHand(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Gets a copy of the item the entity is currently holding
|
||||
@@ -47,6 +51,7 @@ public interface EntityEquipment {
|
||||
* @return the currently held item
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
ItemStack getItemInHand();
|
||||
|
||||
/**
|
||||
@@ -59,13 +64,14 @@ public interface EntityEquipment {
|
||||
* @param stack The item to put into the entities hand
|
||||
*/
|
||||
@Deprecated
|
||||
void setItemInHand(ItemStack stack);
|
||||
void setItemInHand(@Nullable ItemStack stack);
|
||||
|
||||
/**
|
||||
* Gets a copy of the helmet currently being worn by the entity
|
||||
*
|
||||
* @return The helmet being worn
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getHelmet();
|
||||
|
||||
/**
|
||||
@@ -73,13 +79,14 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param helmet The helmet to put on the entity
|
||||
*/
|
||||
void setHelmet(ItemStack helmet);
|
||||
void setHelmet(@Nullable ItemStack helmet);
|
||||
|
||||
/**
|
||||
* Gets a copy of the chest plate currently being worn by the entity
|
||||
*
|
||||
* @return The chest plate being worn
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getChestplate();
|
||||
|
||||
/**
|
||||
@@ -87,13 +94,14 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param chestplate The chest plate to put on the entity
|
||||
*/
|
||||
void setChestplate(ItemStack chestplate);
|
||||
void setChestplate(@Nullable ItemStack chestplate);
|
||||
|
||||
/**
|
||||
* Gets a copy of the leggings currently being worn by the entity
|
||||
*
|
||||
* @return The leggings being worn
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getLeggings();
|
||||
|
||||
/**
|
||||
@@ -101,13 +109,14 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param leggings The leggings to put on the entity
|
||||
*/
|
||||
void setLeggings(ItemStack leggings);
|
||||
void setLeggings(@Nullable ItemStack leggings);
|
||||
|
||||
/**
|
||||
* Gets a copy of the boots currently being worn by the entity
|
||||
*
|
||||
* @return The boots being worn
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getBoots();
|
||||
|
||||
/**
|
||||
@@ -115,21 +124,22 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param boots The boots to put on the entity
|
||||
*/
|
||||
void setBoots(ItemStack boots);
|
||||
void setBoots(@Nullable ItemStack boots);
|
||||
|
||||
/**
|
||||
* Gets a copy of all worn armor
|
||||
*
|
||||
* @return The array of worn armor
|
||||
* @return The array of worn armor. Individual items may be null.
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack[] getArmorContents();
|
||||
|
||||
/**
|
||||
* Sets the entities armor to the provided array of ItemStacks
|
||||
*
|
||||
* @param items The items to set the armor as
|
||||
* @param items The items to set the armor as. Individual items may be null.
|
||||
*/
|
||||
void setArmorContents(ItemStack[] items);
|
||||
void setArmorContents(@NotNull ItemStack[] items);
|
||||
|
||||
/**
|
||||
* Clears the entity of all armor and held items
|
||||
@@ -319,5 +329,6 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @return the entity this EntityEquipment belongs to
|
||||
*/
|
||||
@Nullable
|
||||
Entity getHolder();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the inventory of a Furnace.
|
||||
@@ -12,6 +13,7 @@ public interface FurnaceInventory extends Inventory {
|
||||
*
|
||||
* @return The item
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getResult();
|
||||
|
||||
/**
|
||||
@@ -19,6 +21,7 @@ public interface FurnaceInventory extends Inventory {
|
||||
*
|
||||
* @return The item
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getFuel();
|
||||
|
||||
/**
|
||||
@@ -26,6 +29,7 @@ public interface FurnaceInventory extends Inventory {
|
||||
*
|
||||
* @return The item
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getSmelting();
|
||||
|
||||
/**
|
||||
@@ -33,21 +37,22 @@ public interface FurnaceInventory extends Inventory {
|
||||
*
|
||||
* @param stack The item
|
||||
*/
|
||||
void setFuel(ItemStack stack);
|
||||
void setFuel(@Nullable ItemStack stack);
|
||||
|
||||
/**
|
||||
* Set the current item in the result slot.
|
||||
*
|
||||
* @param stack The item
|
||||
*/
|
||||
void setResult(ItemStack stack);
|
||||
void setResult(@Nullable ItemStack stack);
|
||||
|
||||
/**
|
||||
* Set the item currently smelting.
|
||||
*
|
||||
* @param stack The item
|
||||
*/
|
||||
void setSmelting(ItemStack stack);
|
||||
void setSmelting(@Nullable ItemStack stack);
|
||||
|
||||
@Nullable
|
||||
Furnace getHolder();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.Keyed;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a smelting recipe.
|
||||
@@ -19,22 +20,22 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
private String group = "";
|
||||
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, Material source) {
|
||||
public FurnaceRecipe(@NotNull ItemStack result, @NotNull Material source) {
|
||||
this(NamespacedKey.randomKey(), result, source, 0, 0, 200);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, MaterialData source) {
|
||||
public FurnaceRecipe(@NotNull ItemStack result, @NotNull MaterialData source) {
|
||||
this(NamespacedKey.randomKey(), result, source.getItemType(), source.getData(), 0, 200);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, MaterialData source, float experience) {
|
||||
public FurnaceRecipe(@NotNull ItemStack result, @NotNull MaterialData source, float experience) {
|
||||
this(NamespacedKey.randomKey(), result, source.getItemType(), source.getData(), experience, 200);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FurnaceRecipe(ItemStack result, Material source, int data) {
|
||||
public FurnaceRecipe(@NotNull ItemStack result, @NotNull Material source, int data) {
|
||||
this(NamespacedKey.randomKey(), result, source, data, 0, 200);
|
||||
}
|
||||
|
||||
@@ -47,12 +48,12 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
* @param experience The experience given by this recipe
|
||||
* @param cookingTime The cooking time (in ticks)
|
||||
*/
|
||||
public FurnaceRecipe(NamespacedKey key, ItemStack result, Material source, float experience, int cookingTime) {
|
||||
public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) {
|
||||
this(key, result, source, 0, experience, cookingTime);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FurnaceRecipe(NamespacedKey key, ItemStack result, Material source, int data, float experience, int cookingTime) {
|
||||
public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, int data, float experience, int cookingTime) {
|
||||
this(key, result, new RecipeChoice.MaterialChoice(Collections.singletonList(source)), experience, cookingTime);
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
* @param experience The experience given by this recipe
|
||||
* @param cookingTime The cooking time (in ticks)
|
||||
*/
|
||||
public FurnaceRecipe(NamespacedKey key, ItemStack result, RecipeChoice input, float experience, int cookingTime) {
|
||||
public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) {
|
||||
this.key = key;
|
||||
this.output = new ItemStack(result);
|
||||
this.ingredient = input;
|
||||
@@ -79,7 +80,8 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
* @param input The input material.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public FurnaceRecipe setInput(MaterialData input) {
|
||||
@NotNull
|
||||
public FurnaceRecipe setInput(@NotNull MaterialData input) {
|
||||
return setInput(input.getItemType(), input.getData());
|
||||
}
|
||||
|
||||
@@ -89,7 +91,8 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
* @param input The input material.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public FurnaceRecipe setInput(Material input) {
|
||||
@NotNull
|
||||
public FurnaceRecipe setInput(@NotNull Material input) {
|
||||
return setInput(input, 0);
|
||||
}
|
||||
|
||||
@@ -103,7 +106,8 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public FurnaceRecipe setInput(Material input, int data) {
|
||||
@NotNull
|
||||
public FurnaceRecipe setInput(@NotNull Material input, int data) {
|
||||
this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input));
|
||||
return this;
|
||||
}
|
||||
@@ -113,6 +117,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return The input material.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getInput() {
|
||||
return this.ingredient.getItemStack();
|
||||
}
|
||||
@@ -123,7 +128,8 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
* @param input The input choice.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public FurnaceRecipe setInputChoice(RecipeChoice input) {
|
||||
@NotNull
|
||||
public FurnaceRecipe setInputChoice(@NotNull RecipeChoice input) {
|
||||
this.ingredient = input;
|
||||
return this;
|
||||
}
|
||||
@@ -133,6 +139,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return The input choice.
|
||||
*/
|
||||
@NotNull
|
||||
public RecipeChoice getInputChoice() {
|
||||
return this.ingredient.clone();
|
||||
}
|
||||
@@ -142,6 +149,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return The resulting stack.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getResult() {
|
||||
return output.clone();
|
||||
}
|
||||
@@ -183,6 +191,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
return cookingTime;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
@@ -194,6 +203,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return recipe group. An empty string denotes no group. May not be null.
|
||||
*/
|
||||
@NotNull
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
@@ -205,7 +215,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
|
||||
* @param group recipe group. An empty string denotes no group. May not be
|
||||
* null.
|
||||
*/
|
||||
public void setGroup(String group) {
|
||||
public void setGroup(@NotNull String group) {
|
||||
Preconditions.checkArgument(group != null, "group");
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An interface to the inventory of a Horse.
|
||||
*/
|
||||
@@ -10,6 +12,7 @@ public interface HorseInventory extends AbstractHorseInventory {
|
||||
*
|
||||
* @return the armor item
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getArmor();
|
||||
|
||||
/**
|
||||
@@ -17,5 +20,5 @@ public interface HorseInventory extends AbstractHorseInventory {
|
||||
*
|
||||
* @param stack the new item
|
||||
*/
|
||||
void setArmor(ItemStack stack);
|
||||
void setArmor(@Nullable ItemStack stack);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the various inventories. Behavior relating to {@link
|
||||
@@ -66,6 +69,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @see InventoryView#getTitle()
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
@@ -74,6 +78,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @param index The index of the Slot's ItemStack to return
|
||||
* @return The ItemStack in the slot
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getItem(int index);
|
||||
|
||||
/**
|
||||
@@ -82,7 +87,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @param index The index where to put the ItemStack
|
||||
* @param item The ItemStack to set
|
||||
*/
|
||||
public void setItem(int index, ItemStack item);
|
||||
public void setItem(int index, @Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Stores the given ItemStacks in the inventory. This will try to fill
|
||||
@@ -108,7 +113,8 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @return A HashMap containing items that didn't fit.
|
||||
* @throws IllegalArgumentException if items or any element in it is null
|
||||
*/
|
||||
public HashMap<Integer, ItemStack> addItem(ItemStack... items) throws IllegalArgumentException;
|
||||
@NotNull
|
||||
public HashMap<Integer, ItemStack> addItem(@NotNull ItemStack... items) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Removes the given ItemStacks from the inventory.
|
||||
@@ -129,13 +135,15 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @return A HashMap containing items that couldn't be removed.
|
||||
* @throws IllegalArgumentException if items is null
|
||||
*/
|
||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) throws IllegalArgumentException;
|
||||
@NotNull
|
||||
public HashMap<Integer, ItemStack> removeItem(@NotNull ItemStack... items) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns all ItemStacks from the inventory
|
||||
*
|
||||
* @return An array of ItemStacks from the inventory.
|
||||
* @return An array of ItemStacks from the inventory. Individual items may be null.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack[] getContents();
|
||||
|
||||
/**
|
||||
@@ -147,7 +155,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @throws IllegalArgumentException If the array has more items than the
|
||||
* inventory.
|
||||
*/
|
||||
public void setContents(ItemStack[] items) throws IllegalArgumentException;
|
||||
public void setContents(@NotNull ItemStack[] items) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Return the contents from the section of the inventory where items can
|
||||
@@ -158,8 +166,9 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* It is these contents which will be used for add / contains / remove
|
||||
* methods which look for a specific stack.
|
||||
*
|
||||
* @return inventory storage contents
|
||||
* @return inventory storage contents. Individual items may be null.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack[] getStorageContents();
|
||||
|
||||
/**
|
||||
@@ -169,7 +178,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @throws IllegalArgumentException If the array has more items than the
|
||||
* inventory.
|
||||
*/
|
||||
public void setStorageContents(ItemStack[] items) throws IllegalArgumentException;
|
||||
public void setStorageContents(@NotNull ItemStack[] items) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains any ItemStacks with the given
|
||||
@@ -179,7 +188,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @return true if an ItemStack is found with the given Material
|
||||
* @throws IllegalArgumentException if material is null
|
||||
*/
|
||||
public boolean contains(Material material) throws IllegalArgumentException;
|
||||
public boolean contains(@NotNull Material material) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains any ItemStacks matching the given
|
||||
@@ -192,7 +201,8 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @return false if item is null, true if any exactly matching ItemStacks
|
||||
* were found
|
||||
*/
|
||||
public boolean contains(ItemStack item);
|
||||
@Contract("null -> false")
|
||||
public boolean contains(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains any ItemStacks with the given
|
||||
@@ -204,7 +214,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* found to add to the given amount
|
||||
* @throws IllegalArgumentException if material is null
|
||||
*/
|
||||
public boolean contains(Material material, int amount) throws IllegalArgumentException;
|
||||
public boolean contains(@NotNull Material material, int amount) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains at least the minimum amount specified
|
||||
@@ -219,7 +229,8 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* amount of exactly matching ItemStacks were found
|
||||
* @see #containsAtLeast(ItemStack, int)
|
||||
*/
|
||||
public boolean contains(ItemStack item, int amount);
|
||||
@Contract("null, _ -> false")
|
||||
public boolean contains(@Nullable ItemStack item, int amount);
|
||||
|
||||
/**
|
||||
* Checks if the inventory contains ItemStacks matching the given
|
||||
@@ -230,7 +241,8 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @return false if item is null, true if amount less than 1, true if
|
||||
* enough ItemStacks were found to add to the given amount
|
||||
*/
|
||||
public boolean containsAtLeast(ItemStack item, int amount);
|
||||
@Contract("null, _ -> false")
|
||||
public boolean containsAtLeast(@Nullable ItemStack item, int amount);
|
||||
|
||||
/**
|
||||
* Returns a HashMap with all slots and ItemStacks in the inventory with
|
||||
@@ -244,7 +256,8 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @return A HashMap containing the slot index, ItemStack pairs
|
||||
* @throws IllegalArgumentException if material is null
|
||||
*/
|
||||
public HashMap<Integer, ? extends ItemStack> all(Material material) throws IllegalArgumentException;
|
||||
@NotNull
|
||||
public HashMap<Integer, ? extends ItemStack> all(@NotNull Material material) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Finds all slots in the inventory containing any ItemStacks with the
|
||||
@@ -258,7 +271,8 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @param item The ItemStack to match against
|
||||
* @return A map from slot indexes to item at index
|
||||
*/
|
||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack item);
|
||||
@NotNull
|
||||
public HashMap<Integer, ? extends ItemStack> all(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Finds the first slot in the inventory containing an ItemStack with the
|
||||
@@ -268,7 +282,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @return The slot index of the given Material or -1 if not found
|
||||
* @throws IllegalArgumentException if material is null
|
||||
*/
|
||||
public int first(Material material) throws IllegalArgumentException;
|
||||
public int first(@NotNull Material material) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the first slot in the inventory containing an ItemStack with
|
||||
@@ -278,7 +292,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @param item The ItemStack to match against
|
||||
* @return The slot index of the given ItemStack or -1 if not found
|
||||
*/
|
||||
public int first(ItemStack item);
|
||||
public int first(@NotNull ItemStack item);
|
||||
|
||||
/**
|
||||
* Returns the first empty Slot.
|
||||
@@ -293,7 +307,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @param material The material to remove
|
||||
* @throws IllegalArgumentException if material is null
|
||||
*/
|
||||
public void remove(Material material) throws IllegalArgumentException;
|
||||
public void remove(@NotNull Material material) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Removes all stacks in the inventory matching the given stack.
|
||||
@@ -303,7 +317,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*
|
||||
* @param item The ItemStack to match against
|
||||
*/
|
||||
public void remove(ItemStack item);
|
||||
public void remove(@NotNull ItemStack item);
|
||||
|
||||
/**
|
||||
* Clears out a particular slot in the index.
|
||||
@@ -328,6 +342,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*
|
||||
* @return A list of HumanEntities who are viewing this Inventory.
|
||||
*/
|
||||
@NotNull
|
||||
public List<HumanEntity> getViewers();
|
||||
|
||||
/**
|
||||
@@ -338,6 +353,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @see InventoryView#getTitle()
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public String getTitle();
|
||||
|
||||
/**
|
||||
@@ -345,6 +361,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*
|
||||
* @return The InventoryType representing the type of inventory.
|
||||
*/
|
||||
@NotNull
|
||||
public InventoryType getType();
|
||||
|
||||
/**
|
||||
@@ -352,8 +369,10 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*
|
||||
* @return The holder of the inventory; null if it has no holder.
|
||||
*/
|
||||
@Nullable
|
||||
public InventoryHolder getHolder();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator();
|
||||
|
||||
@@ -366,6 +385,7 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
* @param index The index.
|
||||
* @return An iterator.
|
||||
*/
|
||||
@NotNull
|
||||
public ListIterator<ItemStack> iterator(int index);
|
||||
|
||||
/**
|
||||
@@ -374,5 +394,6 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*
|
||||
* @return location or null if not applicable.
|
||||
*/
|
||||
@Nullable
|
||||
public Location getLocation();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface InventoryHolder {
|
||||
|
||||
/**
|
||||
@@ -7,5 +9,6 @@ public interface InventoryHolder {
|
||||
*
|
||||
* @return The inventory.
|
||||
*/
|
||||
@NotNull
|
||||
public Inventory getInventory();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.inventory;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a view linking two inventories and a single player (whose
|
||||
@@ -99,11 +101,12 @@ public abstract class InventoryView {
|
||||
REPAIR_COST(0, InventoryType.ANVIL);
|
||||
int id;
|
||||
InventoryType style;
|
||||
private Property(int id, InventoryType appliesTo) {
|
||||
private Property(int id, @NotNull InventoryType appliesTo) {
|
||||
this.id = id;
|
||||
style = appliesTo;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public InventoryType getType() {
|
||||
return style;
|
||||
}
|
||||
@@ -123,6 +126,7 @@ public abstract class InventoryView {
|
||||
*
|
||||
* @return the inventory
|
||||
*/
|
||||
@NotNull
|
||||
public abstract Inventory getTopInventory();
|
||||
|
||||
/**
|
||||
@@ -130,6 +134,7 @@ public abstract class InventoryView {
|
||||
*
|
||||
* @return the inventory
|
||||
*/
|
||||
@NotNull
|
||||
public abstract Inventory getBottomInventory();
|
||||
|
||||
/**
|
||||
@@ -137,6 +142,7 @@ public abstract class InventoryView {
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
@NotNull
|
||||
public abstract HumanEntity getPlayer();
|
||||
|
||||
/**
|
||||
@@ -146,6 +152,7 @@ public abstract class InventoryView {
|
||||
*
|
||||
* @return the inventory type
|
||||
*/
|
||||
@NotNull
|
||||
public abstract InventoryType getType();
|
||||
|
||||
/**
|
||||
@@ -157,11 +164,11 @@ public abstract class InventoryView {
|
||||
* @param slot The ID as returned by InventoryClickEvent.getRawSlot()
|
||||
* @param item The new item to put in the slot, or null to clear it.
|
||||
*/
|
||||
public void setItem(int slot, ItemStack item) {
|
||||
public void setItem(int slot, @Nullable ItemStack item) {
|
||||
Inventory inventory = getInventory(slot);
|
||||
if (inventory != null) {
|
||||
inventory.setItem(convertSlot(slot), item);
|
||||
} else {
|
||||
} else if (item != null) {
|
||||
getPlayer().getWorld().dropItemNaturally(getPlayer().getLocation(), item);
|
||||
}
|
||||
}
|
||||
@@ -172,6 +179,7 @@ public abstract class InventoryView {
|
||||
* @param slot The ID as returned by InventoryClickEvent.getRawSlot()
|
||||
* @return The item currently in the slot.
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getItem(int slot) {
|
||||
Inventory inventory = getInventory(slot);
|
||||
return (inventory == null) ? null : inventory.getItem(convertSlot(slot));
|
||||
@@ -183,7 +191,7 @@ public abstract class InventoryView {
|
||||
* @param item The item to put on the cursor, or null to remove the item
|
||||
* on their cursor.
|
||||
*/
|
||||
public final void setCursor(ItemStack item) {
|
||||
public final void setCursor(@Nullable ItemStack item) {
|
||||
getPlayer().setItemOnCursor(item);
|
||||
}
|
||||
|
||||
@@ -193,6 +201,7 @@ public abstract class InventoryView {
|
||||
* @return The item on the player's cursor, or null if they aren't holding
|
||||
* one.
|
||||
*/
|
||||
@Nullable
|
||||
public final ItemStack getCursor() {
|
||||
return getPlayer().getItemOnCursor();
|
||||
}
|
||||
@@ -209,6 +218,7 @@ public abstract class InventoryView {
|
||||
* @param rawSlot The raw slot ID.
|
||||
* @return corresponding inventory, or null
|
||||
*/
|
||||
@Nullable
|
||||
public final Inventory getInventory(int rawSlot) {
|
||||
// Slot may be -1 if not properly detected due to client bug
|
||||
// e.g. dropping an item into part of the enchantment list section of an enchanting table
|
||||
@@ -310,6 +320,7 @@ public abstract class InventoryView {
|
||||
* @param slot The raw slot ID
|
||||
* @return the slot type
|
||||
*/
|
||||
@NotNull
|
||||
public final InventoryType.SlotType getSlotType(int slot) {
|
||||
InventoryType.SlotType type = InventoryType.SlotType.CONTAINER;
|
||||
if (slot >= 0 && slot < this.getTopInventory().getSize()) {
|
||||
@@ -406,7 +417,7 @@ public abstract class InventoryView {
|
||||
* @return true if the property was updated successfully, false if the
|
||||
* property is not supported by that inventory
|
||||
*/
|
||||
public final boolean setProperty(Property prop, int value) {
|
||||
public final boolean setProperty(@NotNull Property prop, int value) {
|
||||
return getPlayer().setWindowProperty(prop, value);
|
||||
}
|
||||
|
||||
@@ -415,6 +426,7 @@ public abstract class InventoryView {
|
||||
*
|
||||
* @return The title.
|
||||
*/
|
||||
@NotNull
|
||||
public final String getTitle() {
|
||||
return getTopInventory().getTitle();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import org.bukkit.Server;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An instance of the ItemFactory can be obtained with {@link
|
||||
@@ -23,7 +25,8 @@ public interface ItemFactory {
|
||||
* @return a new ItemMeta that could be applied to an item stack of the
|
||||
* specified material
|
||||
*/
|
||||
ItemMeta getItemMeta(final Material material);
|
||||
@Nullable
|
||||
ItemMeta getItemMeta(@NotNull final Material material);
|
||||
|
||||
/**
|
||||
* This method checks the item meta to confirm that it is applicable (no
|
||||
@@ -39,7 +42,7 @@ public interface ItemFactory {
|
||||
* @throws IllegalArgumentException if the meta was not created by this
|
||||
* factory
|
||||
*/
|
||||
boolean isApplicable(final ItemMeta meta, final ItemStack stack) throws IllegalArgumentException;
|
||||
boolean isApplicable(@Nullable final ItemMeta meta, @Nullable final ItemStack stack) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* This method checks the item meta to confirm that it is applicable (no
|
||||
@@ -55,7 +58,7 @@ public interface ItemFactory {
|
||||
* @throws IllegalArgumentException if the meta was not created by this
|
||||
* factory
|
||||
*/
|
||||
boolean isApplicable(final ItemMeta meta, final Material material) throws IllegalArgumentException;
|
||||
boolean isApplicable(@Nullable final ItemMeta meta, @Nullable final Material material) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* This method is used to compare two item meta data objects.
|
||||
@@ -68,7 +71,7 @@ public interface ItemFactory {
|
||||
* @throws IllegalArgumentException if either meta was not created by this
|
||||
* factory
|
||||
*/
|
||||
boolean equals(final ItemMeta meta1, final ItemMeta meta2) throws IllegalArgumentException;
|
||||
boolean equals(@Nullable final ItemMeta meta1, @Nullable final ItemMeta meta2) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns an appropriate item meta for the specified stack.
|
||||
@@ -91,7 +94,8 @@ public interface ItemFactory {
|
||||
* @throws IllegalArgumentException if the specified meta was not created
|
||||
* by this factory
|
||||
*/
|
||||
ItemMeta asMetaFor(final ItemMeta meta, final ItemStack stack) throws IllegalArgumentException;
|
||||
@Nullable
|
||||
ItemMeta asMetaFor(@NotNull final ItemMeta meta, @NotNull final ItemStack stack) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns an appropriate item meta for the specified material.
|
||||
@@ -113,13 +117,15 @@ public interface ItemFactory {
|
||||
* @throws IllegalArgumentException if the specified meta was not created
|
||||
* by this factory
|
||||
*/
|
||||
ItemMeta asMetaFor(final ItemMeta meta, final Material material) throws IllegalArgumentException;
|
||||
@Nullable
|
||||
ItemMeta asMetaFor(@NotNull final ItemMeta meta, @NotNull final Material material) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the default color for all leather armor.
|
||||
*
|
||||
* @return the default color for leather armor
|
||||
*/
|
||||
@NotNull
|
||||
Color getDefaultLeatherColor();
|
||||
|
||||
/**
|
||||
@@ -133,5 +139,6 @@ public interface ItemFactory {
|
||||
* @deprecated for internal use only
|
||||
*/
|
||||
@Deprecated
|
||||
Material updateMaterial(final ItemMeta meta, final Material material) throws IllegalArgumentException;
|
||||
@NotNull
|
||||
Material updateMaterial(@NotNull final ItemMeta meta, @NotNull final Material material) throws IllegalArgumentException;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a stack of items
|
||||
@@ -31,7 +33,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @param type item material
|
||||
*/
|
||||
public ItemStack(final Material type) {
|
||||
public ItemStack(@NotNull final Material type) {
|
||||
this(type, 1);
|
||||
}
|
||||
|
||||
@@ -41,7 +43,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param type item material
|
||||
* @param amount stack size
|
||||
*/
|
||||
public ItemStack(final Material type, final int amount) {
|
||||
public ItemStack(@NotNull final Material type, final int amount) {
|
||||
this(type, amount, (short) 0);
|
||||
}
|
||||
|
||||
@@ -53,7 +55,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param damage durability / damage
|
||||
* @deprecated see {@link #setDurability(short)}
|
||||
*/
|
||||
public ItemStack(final Material type, final int amount, final short damage) {
|
||||
public ItemStack(@NotNull final Material type, final int amount, final short damage) {
|
||||
this(type, amount, damage, null);
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @deprecated this method uses an ambiguous data byte object
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack(final Material type, final int amount, final short damage, final Byte data) {
|
||||
public ItemStack(@NotNull final Material type, final int amount, final short damage, @Nullable final Byte data) {
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
@@ -84,7 +86,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @throws IllegalArgumentException if the specified stack is null or
|
||||
* returns an item meta not created by the item factory
|
||||
*/
|
||||
public ItemStack(final ItemStack stack) throws IllegalArgumentException {
|
||||
public ItemStack(@NotNull final ItemStack stack) throws IllegalArgumentException {
|
||||
Validate.notNull(stack, "Cannot copy null stack");
|
||||
this.type = stack.getType();
|
||||
this.amount = stack.getAmount();
|
||||
@@ -100,6 +102,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @return Type of the items in this stack
|
||||
*/
|
||||
@Utility
|
||||
@NotNull
|
||||
public Material getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -112,7 +115,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param type New type to set the items in this stack to
|
||||
*/
|
||||
@Utility
|
||||
public void setType(Material type) {
|
||||
public void setType(@NotNull Material type) {
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
this.type = type;
|
||||
if (this.meta != null) {
|
||||
@@ -148,6 +151,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return MaterialData for this item
|
||||
*/
|
||||
@Nullable
|
||||
public MaterialData getData() {
|
||||
Material mat = Bukkit.getUnsafe().toLegacy(getType());
|
||||
if (data == null && mat != null && mat.getData() != null) {
|
||||
@@ -162,7 +166,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @param data New MaterialData for this item
|
||||
*/
|
||||
public void setData(MaterialData data) {
|
||||
public void setData(@Nullable MaterialData data) {
|
||||
Material mat = Bukkit.getUnsafe().toLegacy(getType());
|
||||
|
||||
if (data == null || mat == null || mat.getData() == null) {
|
||||
@@ -258,7 +262,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @return true if the two stacks are equal, ignoring the amount
|
||||
*/
|
||||
@Utility
|
||||
public boolean isSimilar(ItemStack stack) {
|
||||
public boolean isSimilar(@Nullable ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -269,6 +273,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
return comparisonType == stack.getType() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack clone() {
|
||||
try {
|
||||
@@ -307,7 +312,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param ench Enchantment to test
|
||||
* @return True if this has the given enchantment
|
||||
*/
|
||||
public boolean containsEnchantment(Enchantment ench) {
|
||||
public boolean containsEnchantment(@NotNull Enchantment ench) {
|
||||
return meta == null ? false : meta.hasEnchant(ench);
|
||||
}
|
||||
|
||||
@@ -317,7 +322,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param ench Enchantment to check
|
||||
* @return Level of the enchantment, or 0
|
||||
*/
|
||||
public int getEnchantmentLevel(Enchantment ench) {
|
||||
public int getEnchantmentLevel(@NotNull Enchantment ench) {
|
||||
return meta == null ? 0 : meta.getEnchantLevel(ench);
|
||||
}
|
||||
|
||||
@@ -326,6 +331,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return Map of enchantments.
|
||||
*/
|
||||
@NotNull
|
||||
public Map<Enchantment, Integer> getEnchantments() {
|
||||
return meta == null ? ImmutableMap.<Enchantment, Integer>of() : meta.getEnchants();
|
||||
}
|
||||
@@ -344,7 +350,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* exception is thrown.
|
||||
*/
|
||||
@Utility
|
||||
public void addEnchantments(Map<Enchantment, Integer> enchantments) {
|
||||
public void addEnchantments(@NotNull Map<Enchantment, Integer> enchantments) {
|
||||
Validate.notNull(enchantments, "Enchantments cannot be null");
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
addEnchantment(entry.getKey(), entry.getValue());
|
||||
@@ -363,7 +369,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* not applicable
|
||||
*/
|
||||
@Utility
|
||||
public void addEnchantment(Enchantment ench, int level) {
|
||||
public void addEnchantment(@NotNull Enchantment ench, int level) {
|
||||
Validate.notNull(ench, "Enchantment cannot be null");
|
||||
if ((level < ench.getStartLevel()) || (level > ench.getMaxLevel())) {
|
||||
throw new IllegalArgumentException("Enchantment level is either too low or too high (given " + level + ", bounds are " + ench.getStartLevel() + " to " + ench.getMaxLevel() + ")");
|
||||
@@ -384,7 +390,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param enchantments Enchantments to add
|
||||
*/
|
||||
@Utility
|
||||
public void addUnsafeEnchantments(Map<Enchantment, Integer> enchantments) {
|
||||
public void addUnsafeEnchantments(@NotNull Map<Enchantment, Integer> enchantments) {
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
addUnsafeEnchantment(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@@ -402,8 +408,11 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param ench Enchantment to add
|
||||
* @param level Level of the enchantment
|
||||
*/
|
||||
public void addUnsafeEnchantment(Enchantment ench, int level) {
|
||||
(meta == null ? meta = Bukkit.getItemFactory().getItemMeta(type) : meta).addEnchant(ench, level, true);
|
||||
public void addUnsafeEnchantment(@NotNull Enchantment ench, int level) {
|
||||
ItemMeta itemMeta = (meta == null ? meta = Bukkit.getItemFactory().getItemMeta(type) : meta);
|
||||
if (itemMeta != null) {
|
||||
itemMeta.addEnchant(ench, level, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,7 +422,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @param ench Enchantment to remove
|
||||
* @return Previous level, or 0
|
||||
*/
|
||||
public int removeEnchantment(Enchantment ench) {
|
||||
public int removeEnchantment(@NotNull Enchantment ench) {
|
||||
int level = getEnchantmentLevel(ench);
|
||||
if (level == 0 || meta == null) {
|
||||
return level;
|
||||
@@ -422,6 +431,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
return level;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Utility
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
@@ -448,7 +458,8 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @return deserialized item stack
|
||||
* @see ConfigurationSerializable
|
||||
*/
|
||||
public static ItemStack deserialize(Map<String, Object> args) {
|
||||
@NotNull
|
||||
public static ItemStack deserialize(@NotNull Map<String, Object> args) {
|
||||
int version = (args.containsKey("v")) ? ((Number) args.get("v")).intValue() : -1;
|
||||
short damage = 0;
|
||||
int amount = 1;
|
||||
@@ -461,7 +472,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
if (version < 0) {
|
||||
type = Material.getMaterial(Material.LEGACY_PREFIX + (String) args.get("type"));
|
||||
|
||||
byte dataVal = (type.getMaxDurability() == 0) ? (byte) damage : 0; // Actually durable items get a 0 passed into conversion
|
||||
byte dataVal = (type != null && type.getMaxDurability() == 0) ? (byte) damage : 0; // Actually durable items get a 0 passed into conversion
|
||||
type = Bukkit.getUnsafe().fromLegacy(new MaterialData(type, dataVal), true);
|
||||
|
||||
// We've converted now so the data val isn't a thing and can be reset
|
||||
@@ -514,6 +525,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return a copy of the current ItemStack's ItemData
|
||||
*/
|
||||
@Nullable
|
||||
public ItemMeta getItemMeta() {
|
||||
return this.meta == null ? Bukkit.getItemFactory().getItemMeta(this.type) : this.meta.clone();
|
||||
}
|
||||
@@ -536,14 +548,14 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* @throws IllegalArgumentException if the item meta was not created by
|
||||
* the {@link ItemFactory}
|
||||
*/
|
||||
public boolean setItemMeta(ItemMeta itemMeta) {
|
||||
public boolean setItemMeta(@Nullable ItemMeta itemMeta) {
|
||||
return setItemMeta0(itemMeta, type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cannot be overridden, so it's safe for constructor call
|
||||
*/
|
||||
private boolean setItemMeta0(ItemMeta itemMeta, Material material) {
|
||||
private boolean setItemMeta0(@Nullable ItemMeta itemMeta, @NotNull Material material) {
|
||||
if (itemMeta == null) {
|
||||
this.meta = null;
|
||||
return true;
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An interface to the inventory of a {@link Llama}.
|
||||
*/
|
||||
public interface LlamaInventory extends AbstractHorseInventory {
|
||||
|
||||
/*
|
||||
/**
|
||||
* Gets the item in the llama's decor slot.
|
||||
*
|
||||
* @return the decor item
|
||||
*/
|
||||
@Nullable
|
||||
ItemStack getDecor();
|
||||
|
||||
/**
|
||||
@@ -19,5 +21,5 @@ public interface LlamaInventory extends AbstractHorseInventory {
|
||||
*
|
||||
* @param stack the new item
|
||||
*/
|
||||
void setDecor(ItemStack stack);
|
||||
void setDecor(@Nullable ItemStack stack);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.inventory;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a merchant. A merchant is a special type of inventory which can
|
||||
@@ -15,6 +17,7 @@ public interface Merchant {
|
||||
*
|
||||
* @return an immutable list of trades
|
||||
*/
|
||||
@NotNull
|
||||
List<MerchantRecipe> getRecipes();
|
||||
|
||||
/**
|
||||
@@ -25,7 +28,7 @@ public interface Merchant {
|
||||
*
|
||||
* @param recipes a list of recipes
|
||||
*/
|
||||
void setRecipes(List<MerchantRecipe> recipes);
|
||||
void setRecipes(@NotNull List<MerchantRecipe> recipes);
|
||||
|
||||
/**
|
||||
* Get the recipe at a certain index of this merchant's trade list.
|
||||
@@ -34,6 +37,7 @@ public interface Merchant {
|
||||
* @return the recipe
|
||||
* @throws IndexOutOfBoundsException
|
||||
*/
|
||||
@NotNull
|
||||
MerchantRecipe getRecipe(int i) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
@@ -43,7 +47,7 @@ public interface Merchant {
|
||||
* @param recipe the recipe
|
||||
* @throws IndexOutOfBoundsException
|
||||
*/
|
||||
void setRecipe(int i, MerchantRecipe recipe) throws IndexOutOfBoundsException;
|
||||
void setRecipe(int i, @NotNull MerchantRecipe recipe) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Get the number of trades this merchant currently has available.
|
||||
@@ -65,5 +69,6 @@ public interface Merchant {
|
||||
*
|
||||
* @return the trader, or null
|
||||
*/
|
||||
@Nullable
|
||||
HumanEntity getTrader();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a trading inventory between a player and a merchant.
|
||||
* <br>
|
||||
@@ -26,5 +28,6 @@ public interface MerchantInventory extends Inventory {
|
||||
*
|
||||
* @return the currently active recipe
|
||||
*/
|
||||
@Nullable
|
||||
MerchantRecipe getSelectedRecipe();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,7 +10,7 @@ import java.util.List;
|
||||
* Represents a merchant's trade.
|
||||
*
|
||||
* Trades can take one or two ingredients, and provide one result. The
|
||||
* ingredients' Itemstack amounts are respected in the trade.
|
||||
* ingredients' ItemStack amounts are respected in the trade.
|
||||
* <br>
|
||||
* A trade has a limited number of uses, after which the trade can no longer be
|
||||
* used, unless the player uses a different trade, which will cause its maximum
|
||||
@@ -26,23 +28,24 @@ public class MerchantRecipe implements Recipe {
|
||||
private int maxUses;
|
||||
private boolean experienceReward;
|
||||
|
||||
public MerchantRecipe(ItemStack result, int maxUses) {
|
||||
public MerchantRecipe(@NotNull ItemStack result, int maxUses) {
|
||||
this(result, 0, maxUses, false);
|
||||
}
|
||||
|
||||
public MerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward) {
|
||||
public MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward) {
|
||||
this.result = result;
|
||||
this.uses = uses;
|
||||
this.maxUses = maxUses;
|
||||
this.experienceReward = experienceReward;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addIngredient(ItemStack item) {
|
||||
public void addIngredient(@NotNull ItemStack item) {
|
||||
Preconditions.checkState(ingredients.size() < 2, "MerchantRecipe can only have maximum 2 ingredients");
|
||||
ingredients.add(item.clone());
|
||||
}
|
||||
@@ -51,7 +54,7 @@ public class MerchantRecipe implements Recipe {
|
||||
ingredients.remove(index);
|
||||
}
|
||||
|
||||
public void setIngredients(List<ItemStack> ingredients) {
|
||||
public void setIngredients(@NotNull List<ItemStack> ingredients) {
|
||||
Preconditions.checkState(ingredients.size() <= 2, "MerchantRecipe can only have maximum 2 ingredients");
|
||||
this.ingredients = new ArrayList<ItemStack>();
|
||||
for (ItemStack item : ingredients) {
|
||||
@@ -59,6 +62,7 @@ public class MerchantRecipe implements Recipe {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<ItemStack> getIngredients() {
|
||||
List<ItemStack> copy = new ArrayList<ItemStack>();
|
||||
for (ItemStack item : ingredients) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to the inventory of a Player, including the four armor slots and any extra slots.
|
||||
@@ -10,8 +12,9 @@ public interface PlayerInventory extends Inventory {
|
||||
/**
|
||||
* Get all ItemStacks from the armor slots
|
||||
*
|
||||
* @return All the ItemStacks from the armor slots
|
||||
* @return All the ItemStacks from the armor slots. Individual items can be null.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack[] getArmorContents();
|
||||
|
||||
/**
|
||||
@@ -21,8 +24,9 @@ public interface PlayerInventory extends Inventory {
|
||||
* will not be contained within {@link #getStorageContents()} or
|
||||
* {@link #getArmorContents()}
|
||||
*
|
||||
* @return All additional ItemStacks
|
||||
* @return All additional ItemStacks. Individual items can be null.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack[] getExtraContents();
|
||||
|
||||
/**
|
||||
@@ -30,6 +34,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @return The ItemStack in the helmet slot
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getHelmet();
|
||||
|
||||
/**
|
||||
@@ -37,6 +42,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @return The ItemStack in the chestplate slot
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getChestplate();
|
||||
|
||||
/**
|
||||
@@ -44,6 +50,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @return The ItemStack in the leg slot
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getLeggings();
|
||||
|
||||
/**
|
||||
@@ -51,6 +58,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @return The ItemStack in the boots slot
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getBoots();
|
||||
|
||||
/**
|
||||
@@ -79,14 +87,14 @@ public interface PlayerInventory extends Inventory {
|
||||
* @see #setItemInOffHand(ItemStack)
|
||||
*/
|
||||
@Override
|
||||
public void setItem(int index, ItemStack item);
|
||||
public void setItem(int index, @Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Put the given ItemStacks into the armor slots
|
||||
*
|
||||
* @param items The ItemStacks to use as armour
|
||||
*/
|
||||
public void setArmorContents(ItemStack[] items);
|
||||
public void setArmorContents(@Nullable ItemStack[] items);
|
||||
|
||||
/**
|
||||
* Put the given ItemStacks into the extra slots
|
||||
@@ -95,7 +103,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @param items The ItemStacks to use as extra
|
||||
*/
|
||||
public void setExtraContents(ItemStack[] items);
|
||||
public void setExtraContents(@Nullable ItemStack[] items);
|
||||
|
||||
/**
|
||||
* Put the given ItemStack into the helmet slot. This does not check if
|
||||
@@ -103,7 +111,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @param helmet The ItemStack to use as helmet
|
||||
*/
|
||||
public void setHelmet(ItemStack helmet);
|
||||
public void setHelmet(@Nullable ItemStack helmet);
|
||||
|
||||
/**
|
||||
* Put the given ItemStack into the chestplate slot. This does not check
|
||||
@@ -111,7 +119,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @param chestplate The ItemStack to use as chestplate
|
||||
*/
|
||||
public void setChestplate(ItemStack chestplate);
|
||||
public void setChestplate(@Nullable ItemStack chestplate);
|
||||
|
||||
/**
|
||||
* Put the given ItemStack into the leg slot. This does not check if the
|
||||
@@ -119,7 +127,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @param leggings The ItemStack to use as leggings
|
||||
*/
|
||||
public void setLeggings(ItemStack leggings);
|
||||
public void setLeggings(@Nullable ItemStack leggings);
|
||||
|
||||
/**
|
||||
* Put the given ItemStack into the boots slot. This does not check if the
|
||||
@@ -127,7 +135,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @param boots The ItemStack to use as boots
|
||||
*/
|
||||
public void setBoots(ItemStack boots);
|
||||
public void setBoots(@Nullable ItemStack boots);
|
||||
|
||||
/**
|
||||
* Gets a copy of the item the player is currently holding
|
||||
@@ -135,6 +143,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @return the currently held item
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack getItemInMainHand();
|
||||
|
||||
/**
|
||||
@@ -142,7 +151,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @param item The item to put into the player's hand
|
||||
*/
|
||||
void setItemInMainHand(ItemStack item);
|
||||
void setItemInMainHand(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Gets a copy of the item the player is currently holding
|
||||
@@ -150,6 +159,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @return the currently held item
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack getItemInOffHand();
|
||||
|
||||
/**
|
||||
@@ -157,7 +167,7 @@ public interface PlayerInventory extends Inventory {
|
||||
*
|
||||
* @param item The item to put into the player's hand
|
||||
*/
|
||||
void setItemInOffHand(ItemStack item);
|
||||
void setItemInOffHand(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Gets a copy of the item the player is currently holding
|
||||
@@ -169,6 +179,7 @@ public interface PlayerInventory extends Inventory {
|
||||
* @return the currently held item
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public ItemStack getItemInHand();
|
||||
|
||||
/**
|
||||
@@ -181,7 +192,7 @@ public interface PlayerInventory extends Inventory {
|
||||
* @param stack The item to put into the player's hand
|
||||
*/
|
||||
@Deprecated
|
||||
public void setItemInHand(ItemStack stack);
|
||||
public void setItemInHand(@Nullable ItemStack stack);
|
||||
|
||||
/**
|
||||
* Get the slot number of the currently held item
|
||||
@@ -201,5 +212,6 @@ public interface PlayerInventory extends Inventory {
|
||||
*/
|
||||
public void setHeldItemSlot(int slot);
|
||||
|
||||
@Nullable
|
||||
public HumanEntity getHolder();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents some type of crafting recipe.
|
||||
*/
|
||||
@@ -10,5 +12,6 @@ public interface Recipe {
|
||||
*
|
||||
* @return The result stack
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack getResult();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a potential item match within a recipe. All choices within a
|
||||
@@ -24,10 +25,15 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
* @deprecated for compatability only
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
ItemStack getItemStack();
|
||||
|
||||
@NotNull
|
||||
RecipeChoice clone();
|
||||
|
||||
@Override
|
||||
boolean test(@NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Represents a choice of multiple matching Materials.
|
||||
*/
|
||||
@@ -35,15 +41,15 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
|
||||
private List<Material> choices;
|
||||
|
||||
public MaterialChoice(Material choice) {
|
||||
public MaterialChoice(@NotNull Material choice) {
|
||||
this(Arrays.asList(choice));
|
||||
}
|
||||
|
||||
public MaterialChoice(Material... choices) {
|
||||
public MaterialChoice(@NotNull Material... choices) {
|
||||
this(Arrays.asList(choices));
|
||||
}
|
||||
|
||||
public MaterialChoice(List<Material> choices) {
|
||||
public MaterialChoice(@NotNull List<Material> choices) {
|
||||
Preconditions.checkArgument(choices != null, "choices");
|
||||
Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice");
|
||||
for (Material choice : choices) {
|
||||
@@ -54,7 +60,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ItemStack t) {
|
||||
public boolean test(@NotNull ItemStack t) {
|
||||
for (Material match : choices) {
|
||||
if (t.getType() == match) {
|
||||
return true;
|
||||
@@ -64,6 +70,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
ItemStack stack = new ItemStack(choices.get(0));
|
||||
@@ -76,10 +83,12 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Material> getChoices() {
|
||||
return Collections.unmodifiableList(choices);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MaterialChoice clone() {
|
||||
try {
|
||||
@@ -135,15 +144,15 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
|
||||
private List<ItemStack> choices;
|
||||
|
||||
public ExactChoice(ItemStack stack) {
|
||||
public ExactChoice(@NotNull ItemStack stack) {
|
||||
this(Arrays.asList(stack));
|
||||
}
|
||||
|
||||
public ExactChoice(ItemStack... stacks) {
|
||||
public ExactChoice(@NotNull ItemStack... stacks) {
|
||||
this(Arrays.asList(stacks));
|
||||
}
|
||||
|
||||
public ExactChoice(List<ItemStack> choices) {
|
||||
public ExactChoice(@NotNull List<ItemStack> choices) {
|
||||
Preconditions.checkArgument(choices != null, "choices");
|
||||
Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice");
|
||||
for (ItemStack choice : choices) {
|
||||
@@ -153,15 +162,18 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
this.choices = new ArrayList<>(choices);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return choices.get(0).clone();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<ItemStack> getChoices() {
|
||||
return Collections.unmodifiableList(choices);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ExactChoice clone() {
|
||||
try {
|
||||
@@ -174,7 +186,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ItemStack t) {
|
||||
public boolean test(@NotNull ItemStack t) {
|
||||
for (ItemStack match : choices) {
|
||||
if (t.isSimilar(match)) {
|
||||
return true;
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.bukkit.Keyed;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a shaped (ie normal) crafting recipe.
|
||||
@@ -23,7 +24,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
private String group = "";
|
||||
|
||||
@Deprecated
|
||||
public ShapedRecipe(ItemStack result) {
|
||||
public ShapedRecipe(@NotNull ItemStack result) {
|
||||
this.key = NamespacedKey.randomKey();
|
||||
this.output = new ItemStack(result);
|
||||
}
|
||||
@@ -40,7 +41,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* @see ShapedRecipe#setIngredient(char, Material, int)
|
||||
* @see ShapedRecipe#setIngredient(char, MaterialData)
|
||||
*/
|
||||
public ShapedRecipe(NamespacedKey key, ItemStack result) {
|
||||
public ShapedRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) {
|
||||
Preconditions.checkArgument(key != null, "key");
|
||||
|
||||
this.key = key;
|
||||
@@ -58,9 +59,10 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* @param shape The rows of the recipe (up to 3 rows).
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public ShapedRecipe shape(final String... shape) {
|
||||
@NotNull
|
||||
public ShapedRecipe shape(@NotNull final String... shape) {
|
||||
Validate.notNull(shape, "Must provide a shape");
|
||||
Validate.isTrue(shape.length > 0 && shape.length < 4, "Crafting recipes should be 1, 2, 3 rows, not ", shape.length);
|
||||
Validate.isTrue(shape.length > 0 && shape.length < 4, "Crafting recipes should be 1, 2 or 3 rows, not ", shape.length);
|
||||
|
||||
int lastLen = -1;
|
||||
for (String row : shape) {
|
||||
@@ -94,7 +96,8 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public ShapedRecipe setIngredient(char key, MaterialData ingredient) {
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull MaterialData ingredient) {
|
||||
return setIngredient(key, ingredient.getItemType(), ingredient.getData());
|
||||
}
|
||||
|
||||
@@ -105,7 +108,8 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public ShapedRecipe setIngredient(char key, Material ingredient) {
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull Material ingredient) {
|
||||
return setIngredient(key, ingredient, 0);
|
||||
}
|
||||
|
||||
@@ -119,7 +123,8 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ShapedRecipe setIngredient(char key, Material ingredient, int raw) {
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull Material ingredient, int raw) {
|
||||
Validate.isTrue(ingredients.containsKey(key), "Symbol does not appear in the shape:", key);
|
||||
|
||||
// -1 is the old wildcard, map to Short.MAX_VALUE as the new one
|
||||
@@ -131,7 +136,8 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ShapedRecipe setIngredient(char key, RecipeChoice ingredient) {
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull RecipeChoice ingredient) {
|
||||
Validate.isTrue(ingredients.containsKey(key), "Symbol does not appear in the shape:", key);
|
||||
|
||||
ingredients.put(key, ingredient);
|
||||
@@ -143,6 +149,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return The mapping of character to ingredients.
|
||||
*/
|
||||
@NotNull
|
||||
public Map<Character, ItemStack> getIngredientMap() {
|
||||
HashMap<Character, ItemStack> result = new HashMap<Character, ItemStack>();
|
||||
for (Map.Entry<Character, RecipeChoice> ingredient : ingredients.entrySet()) {
|
||||
@@ -155,6 +162,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<Character, RecipeChoice> getChoiceMap() {
|
||||
Map<Character, RecipeChoice> result = new HashMap<>();
|
||||
for (Map.Entry<Character, RecipeChoice> ingredient : ingredients.entrySet()) {
|
||||
@@ -171,7 +179,9 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* Get the shape.
|
||||
*
|
||||
* @return The recipe's shape.
|
||||
* @throws NullPointerException when not set yet
|
||||
*/
|
||||
@NotNull
|
||||
public String[] getShape() {
|
||||
return rows.clone();
|
||||
}
|
||||
@@ -181,10 +191,12 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return The result stack.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getResult() {
|
||||
return output.clone();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
@@ -196,6 +208,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return recipe group. An empty string denotes no group. May not be null.
|
||||
*/
|
||||
@NotNull
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
@@ -207,7 +220,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* @param group recipe group. An empty string denotes no group. May not be
|
||||
* null.
|
||||
*/
|
||||
public void setGroup(String group) {
|
||||
public void setGroup(@NotNull String group) {
|
||||
Preconditions.checkArgument(group != null, "group");
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.Keyed;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a shapeless recipe, where the arrangement of the ingredients on
|
||||
@@ -24,7 +25,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
private String group = "";
|
||||
|
||||
@Deprecated
|
||||
public ShapelessRecipe(ItemStack result) {
|
||||
public ShapelessRecipe(@NotNull ItemStack result) {
|
||||
this.key = NamespacedKey.randomKey();
|
||||
this.output = new ItemStack(result);
|
||||
}
|
||||
@@ -43,7 +44,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @see ShapelessRecipe#addIngredient(int,MaterialData)
|
||||
* @see ShapelessRecipe#addIngredient(int,Material,int)
|
||||
*/
|
||||
public ShapelessRecipe(NamespacedKey key, ItemStack result) {
|
||||
public ShapelessRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) {
|
||||
this.key = key;
|
||||
this.output = new ItemStack(result);
|
||||
}
|
||||
@@ -54,7 +55,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to add.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public ShapelessRecipe addIngredient(MaterialData ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(@NotNull MaterialData ingredient) {
|
||||
return addIngredient(1, ingredient);
|
||||
}
|
||||
|
||||
@@ -64,7 +66,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to add.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public ShapelessRecipe addIngredient(Material ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(@NotNull Material ingredient) {
|
||||
return addIngredient(1, ingredient, 0);
|
||||
}
|
||||
|
||||
@@ -77,7 +80,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ShapelessRecipe addIngredient(Material ingredient, int rawdata) {
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(@NotNull Material ingredient, int rawdata) {
|
||||
return addIngredient(1, ingredient, rawdata);
|
||||
}
|
||||
|
||||
@@ -88,7 +92,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to add.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public ShapelessRecipe addIngredient(int count, MaterialData ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(int count, @NotNull MaterialData ingredient) {
|
||||
return addIngredient(count, ingredient.getItemType(), ingredient.getData());
|
||||
}
|
||||
|
||||
@@ -99,7 +104,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to add.
|
||||
* @return The changed recipe, so you can chain calls.
|
||||
*/
|
||||
public ShapelessRecipe addIngredient(int count, Material ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(int count, @NotNull Material ingredient) {
|
||||
return addIngredient(count, ingredient, 0);
|
||||
}
|
||||
|
||||
@@ -113,7 +119,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ShapelessRecipe addIngredient(int count, Material ingredient, int rawdata) {
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(int count, @NotNull Material ingredient, int rawdata) {
|
||||
Validate.isTrue(ingredients.size() + count <= 9, "Shapeless recipes cannot have more than 9 ingredients");
|
||||
|
||||
// -1 is the old wildcard, map to Short.MAX_VALUE as the new one
|
||||
@@ -127,7 +134,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ShapelessRecipe addIngredient(RecipeChoice ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(@NotNull RecipeChoice ingredient) {
|
||||
Validate.isTrue(ingredients.size() + 1 <= 9, "Shapeless recipes cannot have more than 9 ingredients");
|
||||
|
||||
ingredients.add(ingredient);
|
||||
@@ -140,7 +148,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to remove
|
||||
* @return The changed recipe.
|
||||
*/
|
||||
public ShapelessRecipe removeIngredient(RecipeChoice ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(@NotNull RecipeChoice ingredient) {
|
||||
ingredients.remove(ingredient);
|
||||
|
||||
return this;
|
||||
@@ -154,7 +163,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to remove
|
||||
* @return The changed recipe.
|
||||
*/
|
||||
public ShapelessRecipe removeIngredient(Material ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(@NotNull Material ingredient) {
|
||||
return removeIngredient(ingredient, 0);
|
||||
}
|
||||
|
||||
@@ -166,7 +176,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to remove
|
||||
* @return The changed recipe.
|
||||
*/
|
||||
public ShapelessRecipe removeIngredient(MaterialData ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(@NotNull MaterialData ingredient) {
|
||||
return removeIngredient(ingredient.getItemType(), ingredient.getData());
|
||||
}
|
||||
|
||||
@@ -179,7 +190,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to remove
|
||||
* @return The changed recipe.
|
||||
*/
|
||||
public ShapelessRecipe removeIngredient(int count, Material ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(int count, @NotNull Material ingredient) {
|
||||
return removeIngredient(count, ingredient, 0);
|
||||
}
|
||||
|
||||
@@ -192,7 +204,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param ingredient The ingredient to remove.
|
||||
* @return The changed recipe.
|
||||
*/
|
||||
public ShapelessRecipe removeIngredient(int count, MaterialData ingredient) {
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(int count, @NotNull MaterialData ingredient) {
|
||||
return removeIngredient(count, ingredient.getItemType(), ingredient.getData());
|
||||
}
|
||||
|
||||
@@ -207,7 +220,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ShapelessRecipe removeIngredient(Material ingredient, int rawdata) {
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(@NotNull Material ingredient, int rawdata) {
|
||||
return removeIngredient(1, ingredient, rawdata);
|
||||
}
|
||||
|
||||
@@ -223,7 +237,8 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public ShapelessRecipe removeIngredient(int count, Material ingredient, int rawdata) {
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(int count, @NotNull Material ingredient, int rawdata) {
|
||||
Iterator<RecipeChoice> iterator = ingredients.iterator();
|
||||
while (count > 0 && iterator.hasNext()) {
|
||||
ItemStack stack = iterator.next().getItemStack();
|
||||
@@ -240,6 +255,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return The result stack.
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getResult() {
|
||||
return output.clone();
|
||||
}
|
||||
@@ -249,6 +265,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return The input list
|
||||
*/
|
||||
@NotNull
|
||||
public List<ItemStack> getIngredientList() {
|
||||
ArrayList<ItemStack> result = new ArrayList<ItemStack>(ingredients.size());
|
||||
for (RecipeChoice ingredient : ingredients) {
|
||||
@@ -257,6 +274,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<RecipeChoice> getChoiceList() {
|
||||
List<RecipeChoice> result = new ArrayList<>(ingredients.size());
|
||||
for (RecipeChoice ingredient : ingredients) {
|
||||
@@ -265,6 +283,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
@@ -276,6 +295,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
*
|
||||
* @return recipe group. An empty string denotes no group. May not be null.
|
||||
*/
|
||||
@NotNull
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
@@ -287,7 +307,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* @param group recipe group. An empty string denotes no group. May not be
|
||||
* null.
|
||||
*/
|
||||
public void setGroup(String group) {
|
||||
public void setGroup(@NotNull String group) {
|
||||
Preconditions.checkArgument(group != null, "group");
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.inventory.meta;
|
||||
import java.util.List;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface BannerMeta extends ItemMeta {
|
||||
|
||||
@@ -13,6 +15,7 @@ public interface BannerMeta extends ItemMeta {
|
||||
* @deprecated banner color is now stored as the data value, not meta.
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
DyeColor getBaseColor();
|
||||
|
||||
/**
|
||||
@@ -22,13 +25,14 @@ public interface BannerMeta extends ItemMeta {
|
||||
* @deprecated banner color is now stored as the data value, not meta.
|
||||
*/
|
||||
@Deprecated
|
||||
void setBaseColor(DyeColor color);
|
||||
void setBaseColor(@Nullable DyeColor color);
|
||||
|
||||
/**
|
||||
* Returns a list of patterns on this banner
|
||||
*
|
||||
* @return the patterns
|
||||
*/
|
||||
@NotNull
|
||||
List<Pattern> getPatterns();
|
||||
|
||||
/**
|
||||
@@ -36,7 +40,7 @@ public interface BannerMeta extends ItemMeta {
|
||||
*
|
||||
* @param patterns the new list of patterns
|
||||
*/
|
||||
void setPatterns(List<Pattern> patterns);
|
||||
void setPatterns(@NotNull List<Pattern> patterns);
|
||||
|
||||
/**
|
||||
* Adds a new pattern on top of the existing
|
||||
@@ -44,14 +48,16 @@ public interface BannerMeta extends ItemMeta {
|
||||
*
|
||||
* @param pattern the new pattern to add
|
||||
*/
|
||||
void addPattern(Pattern pattern);
|
||||
void addPattern(@NotNull Pattern pattern);
|
||||
|
||||
/**
|
||||
* Returns the pattern at the specified index
|
||||
*
|
||||
* @param i the index
|
||||
* @return the pattern
|
||||
* @throws IndexOutOfBoundsException when index is not in [0, numberOfPatterns()) range
|
||||
*/
|
||||
@NotNull
|
||||
Pattern getPattern(int i);
|
||||
|
||||
/**
|
||||
@@ -59,7 +65,9 @@ public interface BannerMeta extends ItemMeta {
|
||||
*
|
||||
* @param i the index
|
||||
* @return the removed pattern
|
||||
* @throws IndexOutOfBoundsException when index is not in [0, numberOfPatterns()) range
|
||||
*/
|
||||
@NotNull
|
||||
Pattern removePattern(int i);
|
||||
|
||||
/**
|
||||
@@ -67,8 +75,9 @@ public interface BannerMeta extends ItemMeta {
|
||||
*
|
||||
* @param i the index
|
||||
* @param pattern the new pattern
|
||||
* @throws IndexOutOfBoundsException when index is not in [0, numberOfPatterns()) range
|
||||
*/
|
||||
void setPattern(int i, Pattern pattern);
|
||||
void setPattern(int i, @NotNull Pattern pattern);
|
||||
|
||||
/**
|
||||
* Returns the number of patterns on this
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface BlockStateMeta extends ItemMeta {
|
||||
|
||||
@@ -22,6 +23,7 @@ public interface BlockStateMeta extends ItemMeta {
|
||||
*
|
||||
* @return the attached state or a new state
|
||||
*/
|
||||
@NotNull
|
||||
BlockState getBlockState();
|
||||
|
||||
/**
|
||||
@@ -31,5 +33,5 @@ public interface BlockStateMeta extends ItemMeta {
|
||||
* @throws IllegalArgumentException if the blockState is null
|
||||
* or invalid for this item.
|
||||
*/
|
||||
void setBlockState(BlockState blockState);
|
||||
void setBlockState(@NotNull BlockState blockState);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.inventory.meta;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a book ({@link Material#WRITABLE_BOOK} or {@link
|
||||
@@ -47,6 +49,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @return the title of the book
|
||||
*/
|
||||
@Nullable
|
||||
String getTitle();
|
||||
|
||||
/**
|
||||
@@ -57,7 +60,7 @@ public interface BookMeta extends ItemMeta {
|
||||
* @param title the title to set
|
||||
* @return true if the title was successfully set
|
||||
*/
|
||||
boolean setTitle(String title);
|
||||
boolean setTitle(@Nullable String title);
|
||||
|
||||
/**
|
||||
* Checks for the existence of an author in the book.
|
||||
@@ -74,6 +77,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @return the author of the book
|
||||
*/
|
||||
@Nullable
|
||||
String getAuthor();
|
||||
|
||||
/**
|
||||
@@ -81,7 +85,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @param author the author to set
|
||||
*/
|
||||
void setAuthor(String author);
|
||||
void setAuthor(@Nullable String author);
|
||||
|
||||
/**
|
||||
* Checks for the existence of generation level in the book.
|
||||
@@ -98,6 +102,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @return the generation of the book
|
||||
*/
|
||||
@Nullable
|
||||
Generation getGeneration();
|
||||
|
||||
/**
|
||||
@@ -105,7 +110,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @param generation the generation to set
|
||||
*/
|
||||
void setGeneration(Generation generation);
|
||||
void setGeneration(@Nullable Generation generation);
|
||||
|
||||
/**
|
||||
* Checks for the existence of pages in the book.
|
||||
@@ -116,10 +121,13 @@ public interface BookMeta extends ItemMeta {
|
||||
|
||||
/**
|
||||
* Gets the specified page in the book. The given page must exist.
|
||||
* <p>
|
||||
* Pages are 1-indexed.
|
||||
*
|
||||
* @param page the page number to get
|
||||
* @param page the page number to get, in range [1, getPageCount()]
|
||||
* @return the page from the book
|
||||
*/
|
||||
@NotNull
|
||||
String getPage(int page);
|
||||
|
||||
/**
|
||||
@@ -128,17 +136,20 @@ public interface BookMeta extends ItemMeta {
|
||||
* <p>
|
||||
* The data can be up to 256 characters in length, additional characters
|
||||
* are truncated.
|
||||
* <p>
|
||||
* Pages are 1-indexed.
|
||||
*
|
||||
* @param page the page number to set
|
||||
* @param page the page number to set, in range [1, getPageCount()]
|
||||
* @param data the data to set for that page
|
||||
*/
|
||||
void setPage(int page, String data);
|
||||
void setPage(int page, @NotNull String data);
|
||||
|
||||
/**
|
||||
* Gets all the pages in the book.
|
||||
*
|
||||
* @return list of all the pages in the book
|
||||
*/
|
||||
@NotNull
|
||||
List<String> getPages();
|
||||
|
||||
/**
|
||||
@@ -147,7 +158,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @param pages A list of pages to set the book to use
|
||||
*/
|
||||
void setPages(List<String> pages);
|
||||
void setPages(@NotNull List<String> pages);
|
||||
|
||||
/**
|
||||
* Clears the existing book pages, and sets the book to use the provided
|
||||
@@ -155,7 +166,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @param pages A list of strings, each being a page
|
||||
*/
|
||||
void setPages(String... pages);
|
||||
void setPages(@NotNull String... pages);
|
||||
|
||||
/**
|
||||
* Adds new pages to the end of the book. Up to a maximum of 50 pages with
|
||||
@@ -163,7 +174,7 @@ public interface BookMeta extends ItemMeta {
|
||||
*
|
||||
* @param pages A list of strings, each being a page
|
||||
*/
|
||||
void addPage(String... pages);
|
||||
void addPage(@NotNull String... pages);
|
||||
|
||||
/**
|
||||
* Gets the number of pages in the book.
|
||||
@@ -172,5 +183,6 @@ public interface BookMeta extends ItemMeta {
|
||||
*/
|
||||
int getPageCount();
|
||||
|
||||
@NotNull
|
||||
BookMeta clone();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an item that has durability and can take damage.
|
||||
*/
|
||||
@@ -26,5 +28,6 @@ public interface Damageable {
|
||||
*/
|
||||
void setDamage(int damage);
|
||||
|
||||
@NotNull
|
||||
Damageable clone();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* EnchantmentMeta is specific to items that can <i>store</i> enchantments, as
|
||||
@@ -25,7 +26,7 @@ public interface EnchantmentStorageMeta extends ItemMeta {
|
||||
* @param ench enchantment to check
|
||||
* @return true if this enchantment is stored in this meta
|
||||
*/
|
||||
boolean hasStoredEnchant(Enchantment ench);
|
||||
boolean hasStoredEnchant(@NotNull Enchantment ench);
|
||||
|
||||
/**
|
||||
* Checks for the level of the stored enchantment.
|
||||
@@ -34,13 +35,14 @@ public interface EnchantmentStorageMeta extends ItemMeta {
|
||||
* @return The level that the specified stored enchantment has, or 0 if
|
||||
* none
|
||||
*/
|
||||
int getStoredEnchantLevel(Enchantment ench);
|
||||
int getStoredEnchantLevel(@NotNull Enchantment ench);
|
||||
|
||||
/**
|
||||
* Gets a copy the stored enchantments in this ItemMeta.
|
||||
*
|
||||
* @return An immutable copy of the stored enchantments
|
||||
*/
|
||||
@NotNull
|
||||
Map<Enchantment, Integer> getStoredEnchants();
|
||||
|
||||
/**
|
||||
@@ -54,7 +56,7 @@ public interface EnchantmentStorageMeta extends ItemMeta {
|
||||
* otherwise
|
||||
* @throws IllegalArgumentException if enchantment is null
|
||||
*/
|
||||
boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction);
|
||||
boolean addStoredEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction);
|
||||
|
||||
/**
|
||||
* Remove the specified stored enchantment from this item meta.
|
||||
@@ -64,7 +66,7 @@ public interface EnchantmentStorageMeta extends ItemMeta {
|
||||
* otherwise
|
||||
* @throws IllegalArgumentException if enchantment is null
|
||||
*/
|
||||
boolean removeStoredEnchant(Enchantment ench) throws IllegalArgumentException;
|
||||
boolean removeStoredEnchant(@NotNull Enchantment ench) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Checks if the specified enchantment conflicts with any enchantments in
|
||||
@@ -73,7 +75,8 @@ public interface EnchantmentStorageMeta extends ItemMeta {
|
||||
* @param ench enchantment to test
|
||||
* @return true if the enchantment conflicts, false otherwise
|
||||
*/
|
||||
boolean hasConflictingStoredEnchant(Enchantment ench);
|
||||
boolean hasConflictingStoredEnchant(@NotNull Enchantment ench);
|
||||
|
||||
@NotNull
|
||||
EnchantmentStorageMeta clone();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a meta that can store a single FireworkEffect. An example
|
||||
@@ -14,7 +16,7 @@ public interface FireworkEffectMeta extends ItemMeta {
|
||||
*
|
||||
* @param effect the effect to set, or null to indicate none.
|
||||
*/
|
||||
void setEffect(FireworkEffect effect);
|
||||
void setEffect(@Nullable FireworkEffect effect);
|
||||
|
||||
/**
|
||||
* Checks if this meta has an effect.
|
||||
@@ -28,7 +30,9 @@ public interface FireworkEffectMeta extends ItemMeta {
|
||||
*
|
||||
* @return the current effect, or null if none
|
||||
*/
|
||||
@Nullable
|
||||
FireworkEffect getEffect();
|
||||
|
||||
@NotNull
|
||||
FireworkEffectMeta clone();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a {@link Material#FIREWORK_ROCKET} and its effects.
|
||||
@@ -16,7 +17,7 @@ public interface FireworkMeta extends ItemMeta {
|
||||
* @param effect The firework effect to add
|
||||
* @throws IllegalArgumentException If effect is null
|
||||
*/
|
||||
void addEffect(FireworkEffect effect) throws IllegalArgumentException;
|
||||
void addEffect(@NotNull FireworkEffect effect) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Add several effects to this firework.
|
||||
@@ -26,7 +27,7 @@ public interface FireworkMeta extends ItemMeta {
|
||||
* @throws IllegalArgumentException If any effect is null (may be thrown
|
||||
* after changes have occurred)
|
||||
*/
|
||||
void addEffects(FireworkEffect... effects) throws IllegalArgumentException;
|
||||
void addEffects(@NotNull FireworkEffect... effects) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Add several firework effects to this firework.
|
||||
@@ -37,13 +38,14 @@ public interface FireworkMeta extends ItemMeta {
|
||||
* @throws IllegalArgumentException If any effect is null (may be thrown
|
||||
* after changes have occurred)
|
||||
*/
|
||||
void addEffects(Iterable<FireworkEffect> effects) throws IllegalArgumentException;
|
||||
void addEffects(@NotNull Iterable<FireworkEffect> effects) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get the effects in this firework.
|
||||
*
|
||||
* @return An immutable list of the firework effects
|
||||
*/
|
||||
@NotNull
|
||||
List<FireworkEffect> getEffects();
|
||||
|
||||
/**
|
||||
@@ -90,5 +92,6 @@ public interface FireworkMeta extends ItemMeta {
|
||||
*/
|
||||
void setPower(int power) throws IllegalArgumentException;
|
||||
|
||||
@NotNull
|
||||
FireworkMeta clone();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.meta.tags.CustomItemTagContainer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This type represents the storage mechanism for auxiliary item data.
|
||||
@@ -37,6 +39,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the display name that is set
|
||||
*/
|
||||
@NotNull
|
||||
String getDisplayName();
|
||||
|
||||
/**
|
||||
@@ -44,7 +47,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @param name the name to set
|
||||
*/
|
||||
void setDisplayName(String name);
|
||||
void setDisplayName(@Nullable String name);
|
||||
|
||||
/**
|
||||
* Checks for existence of a localized name.
|
||||
@@ -61,6 +64,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the localized name that is set
|
||||
*/
|
||||
@NotNull
|
||||
String getLocalizedName();
|
||||
|
||||
/**
|
||||
@@ -68,7 +72,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @param name the name to set
|
||||
*/
|
||||
void setLocalizedName(String name);
|
||||
void setLocalizedName(@Nullable String name);
|
||||
|
||||
/**
|
||||
* Checks for existence of lore.
|
||||
@@ -85,6 +89,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return a list of lore that is set
|
||||
*/
|
||||
@Nullable
|
||||
List<String> getLore();
|
||||
|
||||
/**
|
||||
@@ -93,7 +98,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @param lore the lore that will be set
|
||||
*/
|
||||
void setLore(List<String> lore);
|
||||
void setLore(@Nullable List<String> lore);
|
||||
|
||||
/**
|
||||
* Checks for the existence of any enchantments.
|
||||
@@ -108,7 +113,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @param ench enchantment to check
|
||||
* @return true if this enchantment exists for this meta
|
||||
*/
|
||||
boolean hasEnchant(Enchantment ench);
|
||||
boolean hasEnchant(@NotNull Enchantment ench);
|
||||
|
||||
/**
|
||||
* Checks for the level of the specified enchantment.
|
||||
@@ -116,7 +121,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @param ench enchantment to check
|
||||
* @return The level that the specified enchantment has, or 0 if none
|
||||
*/
|
||||
int getEnchantLevel(Enchantment ench);
|
||||
int getEnchantLevel(@NotNull Enchantment ench);
|
||||
|
||||
/**
|
||||
* Returns a copy the enchantments in this ItemMeta. <br>
|
||||
@@ -124,6 +129,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return An immutable copy of the enchantments
|
||||
*/
|
||||
@NotNull
|
||||
Map<Enchantment, Integer> getEnchants();
|
||||
|
||||
/**
|
||||
@@ -136,7 +142,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @return true if the item meta changed as a result of this call, false
|
||||
* otherwise
|
||||
*/
|
||||
boolean addEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction);
|
||||
boolean addEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction);
|
||||
|
||||
/**
|
||||
* Removes the specified enchantment from this item meta.
|
||||
@@ -145,7 +151,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @return true if the item meta changed as a result of this call, false
|
||||
* otherwise
|
||||
*/
|
||||
boolean removeEnchant(Enchantment ench);
|
||||
boolean removeEnchant(@NotNull Enchantment ench);
|
||||
|
||||
/**
|
||||
* Checks if the specified enchantment conflicts with any enchantments in
|
||||
@@ -154,27 +160,28 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @param ench enchantment to test
|
||||
* @return true if the enchantment conflicts, false otherwise
|
||||
*/
|
||||
boolean hasConflictingEnchant(Enchantment ench);
|
||||
boolean hasConflictingEnchant(@NotNull 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);
|
||||
void addItemFlags(@NotNull 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);
|
||||
void removeItemFlags(@NotNull ItemFlag... itemFlags);
|
||||
|
||||
/**
|
||||
* Get current set itemFlags. The collection returned is unmodifiable.
|
||||
*
|
||||
* @return A set of all itemFlags set
|
||||
*/
|
||||
@NotNull
|
||||
Set<ItemFlag> getItemFlags();
|
||||
|
||||
/**
|
||||
@@ -183,7 +190,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @param flag the flag to check
|
||||
* @return if it is present
|
||||
*/
|
||||
boolean hasItemFlag(ItemFlag flag);
|
||||
boolean hasItemFlag(@NotNull ItemFlag flag);
|
||||
|
||||
/**
|
||||
* Return if the unbreakable tag is true. An unbreakable item will not lose
|
||||
@@ -215,6 +222,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @return an immutable {@link Multimap} of Attributes
|
||||
* and their AttributeModifiers, or null if none exist
|
||||
*/
|
||||
@Nullable
|
||||
Multimap<Attribute, AttributeModifier> getAttributeModifiers();
|
||||
|
||||
/**
|
||||
@@ -231,7 +239,8 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* respective Attributes and modifiers, or an empty map
|
||||
* if no attributes are set.
|
||||
*/
|
||||
Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlot slot);
|
||||
@NotNull
|
||||
Multimap<Attribute, AttributeModifier> getAttributeModifiers(@NotNull EquipmentSlot slot);
|
||||
|
||||
/**
|
||||
* Return an immutable copy of all {@link AttributeModifier}s
|
||||
@@ -242,7 +251,8 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* or null if no AttributeModifiers exist for the Attribute.
|
||||
* @throws NullPointerException if Attribute is null
|
||||
*/
|
||||
Collection<AttributeModifier> getAttributeModifiers(Attribute attribute);
|
||||
@Nullable
|
||||
Collection<AttributeModifier> getAttributeModifiers(@NotNull Attribute attribute);
|
||||
|
||||
/**
|
||||
* Add an Attribute and it's Modifier.
|
||||
@@ -260,7 +270,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @throws NullPointerException if AttributeModifier is null
|
||||
* @throws IllegalArgumentException if AttributeModifier already exists
|
||||
*/
|
||||
boolean addAttributeModifier(Attribute attribute, AttributeModifier modifier);
|
||||
boolean addAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier);
|
||||
|
||||
/**
|
||||
* Set all {@link Attribute}s and their {@link AttributeModifier}s.
|
||||
@@ -272,7 +282,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @param attributeModifiers the new Multimap containing the Attributes
|
||||
* and their AttributeModifiers
|
||||
*/
|
||||
void setAttributeModifiers(Multimap<Attribute, AttributeModifier> attributeModifiers);
|
||||
void setAttributeModifiers(@Nullable Multimap<Attribute, AttributeModifier> attributeModifiers);
|
||||
|
||||
/**
|
||||
* Remove all {@link AttributeModifier}s associated with the given
|
||||
@@ -285,7 +295,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* removed.
|
||||
* @throws NullPointerException if Attribute is null
|
||||
*/
|
||||
boolean removeAttributeModifier(Attribute attribute);
|
||||
boolean removeAttributeModifier(@NotNull Attribute attribute);
|
||||
|
||||
/**
|
||||
* Remove all {@link Attribute}s and {@link AttributeModifier}s for a
|
||||
@@ -298,7 +308,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @return true if all modifiers were removed that match the given
|
||||
* EquipmentSlot.
|
||||
*/
|
||||
boolean removeAttributeModifier(EquipmentSlot slot);
|
||||
boolean removeAttributeModifier(@NotNull EquipmentSlot slot);
|
||||
|
||||
/**
|
||||
* Remove a specific {@link Attribute} and {@link AttributeModifier}.
|
||||
@@ -313,7 +323,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
* @throws NullPointerException if the Attribute is null
|
||||
* @throws NullPointerException if the AttributeModifier is null
|
||||
*/
|
||||
boolean removeAttributeModifier(Attribute attribute, AttributeModifier modifier);
|
||||
boolean removeAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier);
|
||||
|
||||
/**
|
||||
* Returns a public custom tag container capable of storing tags on the
|
||||
@@ -327,8 +337,10 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
|
||||
*
|
||||
* @return the custom tag container
|
||||
*/
|
||||
@NotNull
|
||||
CustomItemTagContainer getCustomTagContainer();
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
@NotNull
|
||||
ItemMeta clone();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.inventory.meta;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface KnowledgeBookMeta extends ItemMeta {
|
||||
|
||||
@@ -17,6 +18,7 @@ public interface KnowledgeBookMeta extends ItemMeta {
|
||||
*
|
||||
* @return list of all the recipes in the book
|
||||
*/
|
||||
@NotNull
|
||||
List<NamespacedKey> getRecipes();
|
||||
|
||||
/**
|
||||
@@ -25,15 +27,16 @@ public interface KnowledgeBookMeta extends ItemMeta {
|
||||
*
|
||||
* @param recipes A list of recipes to set the book to use
|
||||
*/
|
||||
void setRecipes(List<NamespacedKey> recipes);
|
||||
void setRecipes(@NotNull List<NamespacedKey> recipes);
|
||||
|
||||
/**
|
||||
* Adds new recipe to the end of the book.
|
||||
*
|
||||
* @param recipes A list of recipe keys
|
||||
*/
|
||||
void addRecipe(NamespacedKey... recipes);
|
||||
void addRecipe(@NotNull NamespacedKey... recipes);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
KnowledgeBookMeta clone();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.inventory.meta;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents leather armor ({@link Material#LEATHER_BOOTS}, {@link
|
||||
@@ -17,6 +19,7 @@ public interface LeatherArmorMeta extends ItemMeta {
|
||||
*
|
||||
* @return the color of the armor, never null
|
||||
*/
|
||||
@NotNull
|
||||
Color getColor();
|
||||
|
||||
/**
|
||||
@@ -25,7 +28,8 @@ public interface LeatherArmorMeta extends ItemMeta {
|
||||
* @param color the color to set. Setting it to null is equivalent to
|
||||
* setting it to {@link ItemFactory#getDefaultLeatherColor()}.
|
||||
*/
|
||||
void setColor(Color color);
|
||||
void setColor(@Nullable Color color);
|
||||
|
||||
@NotNull
|
||||
LeatherArmorMeta clone();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.UndefinedNullability;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a map that can be scalable.
|
||||
@@ -71,6 +74,7 @@ public interface MapMeta extends ItemMeta {
|
||||
* @return the map view, or null if the item hasMapView(), but this map does
|
||||
* not exist on the server
|
||||
*/
|
||||
@Nullable
|
||||
MapView getMapView();
|
||||
|
||||
/**
|
||||
@@ -83,7 +87,7 @@ public interface MapMeta extends ItemMeta {
|
||||
*
|
||||
* @param map the map to set
|
||||
*/
|
||||
void setMapView(MapView map);
|
||||
void setMapView(@UndefinedNullability("implementation defined") MapView map);
|
||||
|
||||
/**
|
||||
* Checks to see if this map is scaling.
|
||||
@@ -114,6 +118,7 @@ public interface MapMeta extends ItemMeta {
|
||||
*
|
||||
* @return the location name that is set
|
||||
*/
|
||||
@Nullable
|
||||
String getLocationName();
|
||||
|
||||
/**
|
||||
@@ -122,7 +127,7 @@ public interface MapMeta extends ItemMeta {
|
||||
*
|
||||
* @param name the name to set
|
||||
*/
|
||||
void setLocationName(String name);
|
||||
void setLocationName(@Nullable String name);
|
||||
|
||||
/**
|
||||
* Checks for existence of a map color.
|
||||
@@ -140,6 +145,7 @@ public interface MapMeta extends ItemMeta {
|
||||
*
|
||||
* @return the map color that is set
|
||||
*/
|
||||
@Nullable
|
||||
Color getColor();
|
||||
|
||||
/**
|
||||
@@ -148,7 +154,8 @@ public interface MapMeta extends ItemMeta {
|
||||
*
|
||||
* @param color the color to set
|
||||
*/
|
||||
void setColor(Color color);
|
||||
void setColor(@Nullable Color color);
|
||||
|
||||
@NotNull
|
||||
MapMeta clone();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import org.bukkit.Color;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,13 +19,14 @@ public interface PotionMeta extends ItemMeta {
|
||||
*
|
||||
* @param data PotionData to set the base potion state to
|
||||
*/
|
||||
void setBasePotionData(PotionData data);
|
||||
void setBasePotionData(@NotNull PotionData data);
|
||||
|
||||
/**
|
||||
* Returns the potion data about the base potion
|
||||
*
|
||||
* @return a PotionData object
|
||||
*/
|
||||
@NotNull
|
||||
PotionData getBasePotionData();
|
||||
|
||||
/**
|
||||
@@ -42,6 +45,7 @@ public interface PotionMeta extends ItemMeta {
|
||||
*
|
||||
* @return the immutable list of custom potion effects
|
||||
*/
|
||||
@NotNull
|
||||
List<PotionEffect> getCustomEffects();
|
||||
|
||||
/**
|
||||
@@ -52,7 +56,7 @@ public interface PotionMeta extends ItemMeta {
|
||||
* overwritten
|
||||
* @return true if the potion meta changed as a result of this call
|
||||
*/
|
||||
boolean addCustomEffect(PotionEffect effect, boolean overwrite);
|
||||
boolean addCustomEffect(@NotNull PotionEffect effect, boolean overwrite);
|
||||
|
||||
/**
|
||||
* Removes a custom potion effect from this potion.
|
||||
@@ -60,7 +64,7 @@ public interface PotionMeta extends ItemMeta {
|
||||
* @param type the potion effect type to remove
|
||||
* @return true if the potion meta changed as a result of this call
|
||||
*/
|
||||
boolean removeCustomEffect(PotionEffectType type);
|
||||
boolean removeCustomEffect(@NotNull PotionEffectType type);
|
||||
|
||||
/**
|
||||
* Checks for a specific custom potion effect type on this potion.
|
||||
@@ -68,7 +72,7 @@ public interface PotionMeta extends ItemMeta {
|
||||
* @param type the potion effect type to check for
|
||||
* @return true if the potion has this effect
|
||||
*/
|
||||
boolean hasCustomEffect(PotionEffectType type);
|
||||
boolean hasCustomEffect(@NotNull PotionEffectType type);
|
||||
|
||||
/**
|
||||
* Moves a potion effect to the top of the potion effect list.
|
||||
@@ -80,7 +84,7 @@ public interface PotionMeta extends ItemMeta {
|
||||
* @deprecated use {@link org.bukkit.potion.PotionType#PotionType}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setMainEffect(PotionEffectType type);
|
||||
boolean setMainEffect(@NotNull PotionEffectType type);
|
||||
|
||||
/**
|
||||
* Removes all custom potion effects from this potion.
|
||||
@@ -105,6 +109,7 @@ public interface PotionMeta extends ItemMeta {
|
||||
*
|
||||
* @return the potion color that is set
|
||||
*/
|
||||
@Nullable
|
||||
Color getColor();
|
||||
|
||||
/**
|
||||
@@ -113,7 +118,7 @@ public interface PotionMeta extends ItemMeta {
|
||||
*
|
||||
* @param color the color to set
|
||||
*/
|
||||
void setColor(Color color);
|
||||
void setColor(@Nullable Color color);
|
||||
|
||||
@Override
|
||||
PotionMeta clone();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an item that can be repaired at an anvil.
|
||||
*/
|
||||
@@ -27,5 +29,6 @@ public interface Repairable {
|
||||
void setRepairCost(int cost);
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
@NotNull
|
||||
Repairable clone();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a skull that can have an owner.
|
||||
@@ -14,6 +16,7 @@ public interface SkullMeta extends ItemMeta {
|
||||
* @deprecated see {@link #setOwningPlayer(org.bukkit.OfflinePlayer)}.
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getOwner();
|
||||
|
||||
/**
|
||||
@@ -25,22 +28,20 @@ public interface SkullMeta extends ItemMeta {
|
||||
|
||||
/**
|
||||
* Sets the owner of the skull.
|
||||
* <p>
|
||||
* Plugins should check that hasOwner() returns true before calling this
|
||||
* plugin.
|
||||
*
|
||||
* @param owner the new owner of the skull
|
||||
* @return true if the owner was successfully set
|
||||
* @deprecated see {@link #setOwningPlayer(org.bukkit.OfflinePlayer)}.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setOwner(String owner);
|
||||
boolean setOwner(@Nullable String owner);
|
||||
|
||||
/**
|
||||
* Gets the owner of the skull.
|
||||
*
|
||||
* @return the owner if the skull
|
||||
*/
|
||||
@Nullable
|
||||
OfflinePlayer getOwningPlayer();
|
||||
|
||||
/**
|
||||
@@ -52,7 +53,8 @@ public interface SkullMeta extends ItemMeta {
|
||||
* @param owner the new owner of the skull
|
||||
* @return true if the owner was successfully set
|
||||
*/
|
||||
boolean setOwningPlayer(OfflinePlayer owner);
|
||||
boolean setOwningPlayer(@Nullable OfflinePlayer owner);
|
||||
|
||||
@NotNull
|
||||
SkullMeta clone();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a spawn egg and it's spawned type.
|
||||
@@ -14,6 +16,7 @@ public interface SpawnEggMeta extends ItemMeta {
|
||||
* @deprecated different types are different items
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("-> fail")
|
||||
EntityType getSpawnedType();
|
||||
|
||||
/**
|
||||
@@ -24,8 +27,10 @@ public interface SpawnEggMeta extends ItemMeta {
|
||||
* @deprecated different types are different items
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("_ -> fail")
|
||||
void setSpawnedType(EntityType type);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
SpawnEggMeta clone();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.TropicalFish;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a bucket of tropical fish.
|
||||
@@ -16,6 +17,7 @@ public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
*
|
||||
* @return pattern color
|
||||
*/
|
||||
@NotNull
|
||||
DyeColor getPatternColor();
|
||||
|
||||
/**
|
||||
@@ -26,7 +28,7 @@ public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
*
|
||||
* @param color pattern color
|
||||
*/
|
||||
void setPatternColor(DyeColor color);
|
||||
void setPatternColor(@NotNull DyeColor color);
|
||||
|
||||
/**
|
||||
* Gets the color of the fish's body.
|
||||
@@ -36,6 +38,7 @@ public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
*
|
||||
* @return pattern color
|
||||
*/
|
||||
@NotNull
|
||||
DyeColor getBodyColor();
|
||||
|
||||
/**
|
||||
@@ -46,7 +49,7 @@ public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
*
|
||||
* @param color body color
|
||||
*/
|
||||
void setBodyColor(DyeColor color);
|
||||
void setBodyColor(@NotNull DyeColor color);
|
||||
|
||||
/**
|
||||
* Gets the fish's pattern.
|
||||
@@ -56,6 +59,7 @@ public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
*
|
||||
* @return pattern
|
||||
*/
|
||||
@NotNull
|
||||
TropicalFish.Pattern getPattern();
|
||||
|
||||
/**
|
||||
@@ -66,7 +70,7 @@ public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
*
|
||||
* @param pattern new pattern
|
||||
*/
|
||||
void setPattern(TropicalFish.Pattern pattern);
|
||||
void setPattern(@NotNull TropicalFish.Pattern pattern);
|
||||
|
||||
/**
|
||||
* Checks for existence of a variant tag indicating a specific fish will be
|
||||
@@ -76,5 +80,6 @@ public interface TropicalFishBucketMeta extends ItemMeta {
|
||||
*/
|
||||
boolean hasVariant();
|
||||
|
||||
@NotNull
|
||||
TropicalFishBucketMeta clone();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.bukkit.inventory.meta.tags;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This interface represents a map like object, capable of storing custom tags
|
||||
@@ -28,7 +30,7 @@ public interface CustomItemTagContainer {
|
||||
* @throws IllegalArgumentException if no suitable adapter will be found for
|
||||
* the {@link ItemTagType#getPrimitiveType()}
|
||||
*/
|
||||
<T, Z> void setCustomTag(NamespacedKey key, ItemTagType<T, Z> type, Z value);
|
||||
<T, Z> void setCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType<T, Z> type, @NotNull Z value);
|
||||
|
||||
/**
|
||||
* Returns if the item meta has a custom tag registered matching the
|
||||
@@ -56,7 +58,7 @@ public interface CustomItemTagContainer {
|
||||
* @throws NullPointerException if the type to cast the found object to is
|
||||
* null
|
||||
*/
|
||||
<T, Z> boolean hasCustomTag(NamespacedKey key, ItemTagType<T, Z> type);
|
||||
<T, Z> boolean hasCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType<T, Z> type);
|
||||
|
||||
/**
|
||||
* Returns the custom tag's value that is stored on the item.
|
||||
@@ -75,7 +77,8 @@ public interface CustomItemTagContainer {
|
||||
* @throws IllegalArgumentException if no suitable adapter will be found for
|
||||
* the {@link ItemTagType#getPrimitiveType()}
|
||||
*/
|
||||
<T, Z> Z getCustomTag(NamespacedKey key, ItemTagType<T, Z> type);
|
||||
@Nullable
|
||||
<T, Z> Z getCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType<T, Z> type);
|
||||
|
||||
/**
|
||||
* Removes a custom key from the item meta.
|
||||
@@ -83,7 +86,7 @@ public interface CustomItemTagContainer {
|
||||
* @param key the key
|
||||
* @throws NullPointerException if the provided key is null
|
||||
*/
|
||||
void removeCustomTag(NamespacedKey key);
|
||||
void removeCustomTag(@NotNull NamespacedKey key);
|
||||
|
||||
/**
|
||||
* Returns if the container instance is empty, therefore has no entries
|
||||
@@ -98,5 +101,6 @@ public interface CustomItemTagContainer {
|
||||
*
|
||||
* @return the tag context
|
||||
*/
|
||||
@NotNull
|
||||
ItemTagAdapterContext getAdapterContext();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory.meta.tags;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This interface represents the context in which the {@link ItemTagType} can
|
||||
* serialize and deserialize the passed values.
|
||||
@@ -11,5 +13,6 @@ public interface ItemTagAdapterContext {
|
||||
*
|
||||
* @return the fresh container instance
|
||||
*/
|
||||
@NotNull
|
||||
CustomItemTagContainer newTagContainer();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.inventory.meta.tags;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This class represents an enum with a generic content type. It defines the
|
||||
* types a custom item tag can have.
|
||||
@@ -75,6 +77,7 @@ public interface ItemTagType<T, Z> {
|
||||
*
|
||||
* @return the class
|
||||
*/
|
||||
@NotNull
|
||||
Class<T> getPrimitiveType();
|
||||
|
||||
/**
|
||||
@@ -82,6 +85,7 @@ public interface ItemTagType<T, Z> {
|
||||
*
|
||||
* @return the class type
|
||||
*/
|
||||
@NotNull
|
||||
Class<Z> getComplexType();
|
||||
|
||||
/**
|
||||
@@ -92,7 +96,8 @@ public interface ItemTagType<T, Z> {
|
||||
* @param context the context this operation is running in
|
||||
* @return the primitive value
|
||||
*/
|
||||
T toPrimitive(Z complex, ItemTagAdapterContext context);
|
||||
@NotNull
|
||||
T toPrimitive(@NotNull Z complex, @NotNull ItemTagAdapterContext context);
|
||||
|
||||
/**
|
||||
* Creates a complex object based of the passed primitive value
|
||||
@@ -101,7 +106,8 @@ public interface ItemTagType<T, Z> {
|
||||
* @param context the context this operation is running in
|
||||
* @return the complex object instance
|
||||
*/
|
||||
Z fromPrimitive(T primitive, ItemTagAdapterContext context);
|
||||
@NotNull
|
||||
Z fromPrimitive(@NotNull T primitive, @NotNull ItemTagAdapterContext context);
|
||||
|
||||
/**
|
||||
* A default implementation that simply exists to pass on the retrieved or
|
||||
@@ -116,27 +122,31 @@ public interface ItemTagType<T, Z> {
|
||||
|
||||
private final Class<T> primitiveType;
|
||||
|
||||
PrimitiveTagType(Class<T> primitiveType) {
|
||||
PrimitiveTagType(@NotNull Class<T> primitiveType) {
|
||||
this.primitiveType = primitiveType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Class<T> getPrimitiveType() {
|
||||
return primitiveType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Class<T> getComplexType() {
|
||||
return primitiveType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public T toPrimitive(T complex, ItemTagAdapterContext context) {
|
||||
public T toPrimitive(@NotNull T complex, @NotNull ItemTagAdapterContext context) {
|
||||
return complex;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public T fromPrimitive(T primitive, ItemTagAdapterContext context) {
|
||||
public T fromPrimitive(@NotNull T primitive, @NotNull ItemTagAdapterContext context) {
|
||||
return primitive;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user