@@ -1,9 +1,9 @@
|
||||
package org.bukkit.inventory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Utility;
|
||||
@@ -79,7 +79,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack(@NotNull final Material type, final int amount, final short damage, @Nullable final Byte data) {
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
if (damage != 0) {
|
||||
@@ -98,7 +98,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
* returns an item meta not created by the item factory
|
||||
*/
|
||||
public ItemStack(@NotNull final ItemStack stack) throws IllegalArgumentException {
|
||||
Validate.notNull(stack, "Cannot copy null stack");
|
||||
Preconditions.checkArgument(stack != null, "Cannot copy null stack");
|
||||
this.type = stack.getType();
|
||||
this.amount = stack.getAmount();
|
||||
if (this.type.isLegacy()) {
|
||||
@@ -133,7 +133,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*/
|
||||
@Utility
|
||||
public void setType(@NotNull Material type) {
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||
this.type = type;
|
||||
if (this.meta != null) {
|
||||
this.meta = Bukkit.getItemFactory().asMetaFor(meta, type);
|
||||
@@ -368,7 +368,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*/
|
||||
@Utility
|
||||
public void addEnchantments(@NotNull Map<Enchantment, Integer> enchantments) {
|
||||
Validate.notNull(enchantments, "Enchantments cannot be null");
|
||||
Preconditions.checkArgument(enchantments != null, "Enchantments cannot be null");
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
addEnchantment(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||||
*/
|
||||
@Utility
|
||||
public void addEnchantment(@NotNull Enchantment ench, int level) {
|
||||
Validate.notNull(ench, "Enchantment cannot be null");
|
||||
Preconditions.checkArgument(ench != null, "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() + ")");
|
||||
} else if (!ench.canEnchantItem(this)) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -61,15 +60,15 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
*/
|
||||
@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 or 3 rows, not ", shape.length);
|
||||
Preconditions.checkArgument(shape != null, "Must provide a shape");
|
||||
Preconditions.checkArgument(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) {
|
||||
Validate.notNull(row, "Shape cannot have null rows");
|
||||
Validate.isTrue(row.length() > 0 && row.length() < 4, "Crafting rows should be 1, 2, or 3 characters, not ", row.length());
|
||||
Preconditions.checkArgument(row != null, "Shape cannot have null rows");
|
||||
Preconditions.checkArgument(row.length() > 0 && row.length() < 4, "Crafting rows should be 1, 2, or 3 characters, not ", row.length());
|
||||
|
||||
Validate.isTrue(lastLen == -1 || lastLen == row.length(), "Crafting recipes must be rectangular");
|
||||
Preconditions.checkArgument(lastLen == -1 || lastLen == row.length(), "Crafting recipes must be rectangular");
|
||||
lastLen = row.length();
|
||||
}
|
||||
this.rows = new String[shape.length];
|
||||
@@ -125,7 +124,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull Material ingredient, int raw) {
|
||||
Validate.isTrue(ingredients.containsKey(key), "Symbol does not appear in the shape:", key);
|
||||
Preconditions.checkArgument(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
|
||||
if (raw == -1) {
|
||||
@@ -138,7 +137,7 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
|
||||
@NotNull
|
||||
public ShapedRecipe setIngredient(char key, @NotNull RecipeChoice ingredient) {
|
||||
Validate.isTrue(ingredients.containsKey(key), "Symbol does not appear in the shape:", key);
|
||||
Preconditions.checkArgument(ingredients.containsKey(key), "Symbol does not appear in the shape:", key);
|
||||
|
||||
ingredients.put(key, ingredient);
|
||||
return this;
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -121,7 +120,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
@Deprecated
|
||||
@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");
|
||||
Preconditions.checkArgument(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
|
||||
if (rawdata == -1) {
|
||||
@@ -136,7 +135,7 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
|
||||
@NotNull
|
||||
public ShapelessRecipe addIngredient(@NotNull RecipeChoice ingredient) {
|
||||
Validate.isTrue(ingredients.size() + 1 <= 9, "Shapeless recipes cannot have more than 9 ingredients");
|
||||
Preconditions.checkArgument(ingredients.size() + 1 <= 9, "Shapeless recipes cannot have more than 9 ingredients");
|
||||
|
||||
ingredients.add(ingredient);
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user