2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.util;
|
|
|
|
|
2013-03-08 21:46:05 +01:00
|
|
|
import org.bukkit.ChatColor;
|
2013-12-02 18:08:12 +01:00
|
|
|
import org.bukkit.CoalType;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.DyeColor;
|
2013-07-25 20:52:21 +02:00
|
|
|
import org.bukkit.Material;
|
2013-10-31 18:25:06 +01:00
|
|
|
import org.bukkit.inventory.FurnaceRecipe;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2013-10-31 18:25:06 +01:00
|
|
|
import org.bukkit.inventory.Recipe;
|
2013-03-08 21:46:05 +01:00
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
2013-12-02 18:08:12 +01:00
|
|
|
import org.bukkit.material.Coal;
|
2013-09-05 20:55:08 +02:00
|
|
|
import org.bukkit.material.Dye;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-31 18:25:06 +01:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-04-17 16:03:34 +02:00
|
|
|
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
2014-12-29 06:12:46 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2013-05-02 21:02:12 +02:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-31 19:29:06 +01:00
|
|
|
public final class ItemUtils {
|
|
|
|
private ItemUtils() {}
|
2013-09-25 16:42:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is a bow.
|
|
|
|
*
|
|
|
|
* @param item Item to check
|
|
|
|
* @return true if the item is a bow, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean isBow(ItemStack item) {
|
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case BOW:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomBow(type);
|
2013-09-25 16:42:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Checks if the item is a sword.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a sword, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isSword(ItemStack item) {
|
2013-09-22 17:31:54 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_SWORD:
|
|
|
|
case GOLD_SWORD:
|
|
|
|
case IRON_SWORD:
|
|
|
|
case STONE_SWORD:
|
|
|
|
case WOOD_SWORD:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomSword(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is a hoe.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a hoe, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isHoe(ItemStack item) {
|
2013-09-22 17:31:54 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_HOE:
|
|
|
|
case GOLD_HOE:
|
|
|
|
case IRON_HOE:
|
|
|
|
case STONE_HOE:
|
|
|
|
case WOOD_HOE:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomHoe(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is a shovel.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a shovel, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isShovel(ItemStack item) {
|
2013-09-22 17:31:54 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_SPADE:
|
|
|
|
case GOLD_SPADE:
|
|
|
|
case IRON_SPADE:
|
|
|
|
case STONE_SPADE:
|
|
|
|
case WOOD_SPADE:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomShovel(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is an axe.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is an axe, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isAxe(ItemStack item) {
|
2013-09-22 17:31:54 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_AXE:
|
|
|
|
case GOLD_AXE:
|
|
|
|
case IRON_AXE:
|
|
|
|
case STONE_AXE:
|
|
|
|
case WOOD_AXE:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomAxe(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is a pickaxe.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a pickaxe, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isPickaxe(ItemStack item) {
|
2013-09-22 17:31:54 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_PICKAXE:
|
|
|
|
case GOLD_PICKAXE:
|
|
|
|
case IRON_PICKAXE:
|
|
|
|
case STONE_PICKAXE:
|
|
|
|
case WOOD_PICKAXE:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomPickaxe(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 06:12:46 +01:00
|
|
|
/**
|
|
|
|
* Checks if the item counts as unarmed.
|
|
|
|
*
|
|
|
|
* @param item Item to check
|
|
|
|
* @return true if the item counts as unarmed, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean isUnarmed(ItemStack item) {
|
|
|
|
if (Config.getInstance().getUnarmedItemsAsUnarmed()) {
|
|
|
|
return !isMinecraftTool(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return item.getType() == Material.AIR;
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Checks if the item is a helmet.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a helmet, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isHelmet(ItemStack item) {
|
2013-09-20 16:03:02 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_HELMET:
|
|
|
|
case GOLD_HELMET:
|
|
|
|
case IRON_HELMET:
|
2013-05-16 14:13:01 +02:00
|
|
|
case CHAINMAIL_HELMET:
|
2013-03-01 06:52:01 +01:00
|
|
|
case LEATHER_HELMET:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomHelmet(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is a chestplate.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a chestplate, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isChestplate(ItemStack item) {
|
2013-09-20 16:03:02 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_CHESTPLATE:
|
|
|
|
case GOLD_CHESTPLATE:
|
|
|
|
case IRON_CHESTPLATE:
|
2013-05-16 14:13:01 +02:00
|
|
|
case CHAINMAIL_CHESTPLATE:
|
2013-03-01 06:52:01 +01:00
|
|
|
case LEATHER_CHESTPLATE:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomChestplate(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is a pair of pants.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a pair of pants, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isLeggings(ItemStack item) {
|
2013-09-20 16:03:02 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_LEGGINGS:
|
|
|
|
case GOLD_LEGGINGS:
|
|
|
|
case IRON_LEGGINGS:
|
2013-05-16 14:13:01 +02:00
|
|
|
case CHAINMAIL_LEGGINGS:
|
2013-03-01 06:52:01 +01:00
|
|
|
case LEATHER_LEGGINGS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomLeggings(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the item is a pair of boots.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a pair of boots, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isBoots(ItemStack item) {
|
2013-09-20 16:03:02 +02:00
|
|
|
Material type = item.getType();
|
|
|
|
|
|
|
|
switch (type) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_BOOTS:
|
|
|
|
case GOLD_BOOTS:
|
|
|
|
case IRON_BOOTS:
|
2013-05-16 14:13:01 +02:00
|
|
|
case CHAINMAIL_BOOTS:
|
2013-03-01 06:52:01 +01:00
|
|
|
case LEATHER_BOOTS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomBoots(type);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a wearable armor piece.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is armor, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isArmor(ItemStack item) {
|
|
|
|
return isHelmet(item) || isChestplate(item) || isLeggings(item) || isBoots(item);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-16 14:13:01 +02:00
|
|
|
* Checks to see if an item is a wearable *vanilla* armor piece.
|
2013-03-01 06:52:01 +01:00
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is armor, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isMinecraftArmor(ItemStack item) {
|
|
|
|
return isLeatherArmor(item) || isGoldArmor(item) || isIronArmor(item) || isDiamondArmor(item) || isChainmailArmor(item);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a leather armor piece.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is leather armor, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isLeatherArmor(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case LEATHER_BOOTS:
|
|
|
|
case LEATHER_CHESTPLATE:
|
|
|
|
case LEATHER_HELMET:
|
|
|
|
case LEATHER_LEGGINGS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a gold armor piece.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is gold armor, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isGoldArmor(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case GOLD_BOOTS:
|
|
|
|
case GOLD_CHESTPLATE:
|
|
|
|
case GOLD_HELMET:
|
|
|
|
case GOLD_LEGGINGS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is an iron armor piece.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is iron armor, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isIronArmor(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case IRON_BOOTS:
|
|
|
|
case IRON_CHESTPLATE:
|
|
|
|
case IRON_HELMET:
|
|
|
|
case IRON_LEGGINGS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a diamond armor piece.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is diamond armor, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isDiamondArmor(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_BOOTS:
|
|
|
|
case DIAMOND_CHESTPLATE:
|
|
|
|
case DIAMOND_HELMET:
|
|
|
|
case DIAMOND_LEGGINGS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-16 14:13:01 +02:00
|
|
|
* Checks to see if an item is a chainmail armor piece.
|
|
|
|
*
|
|
|
|
* @param item Item to check
|
|
|
|
* @return true if the item is chainmail armor, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean isChainmailArmor(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
|
|
|
case CHAINMAIL_BOOTS:
|
|
|
|
case CHAINMAIL_CHESTPLATE:
|
|
|
|
case CHAINMAIL_HELMET:
|
|
|
|
case CHAINMAIL_LEGGINGS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a *vanilla* tool.
|
2013-03-01 06:52:01 +01:00
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a tool, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isMinecraftTool(ItemStack item) {
|
|
|
|
return isStoneTool(item) || isWoodTool(item) || isGoldTool(item) || isIronTool(item) || isDiamondTool(item) || isStringTool(item);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a stone tool.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a stone tool, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isStoneTool(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case STONE_AXE:
|
|
|
|
case STONE_HOE:
|
|
|
|
case STONE_PICKAXE:
|
|
|
|
case STONE_SPADE:
|
|
|
|
case STONE_SWORD:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a wooden tool.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a wooden tool, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isWoodTool(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case WOOD_AXE:
|
|
|
|
case WOOD_HOE:
|
|
|
|
case WOOD_PICKAXE:
|
|
|
|
case WOOD_SPADE:
|
|
|
|
case WOOD_SWORD:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a string tool.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a string tool, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isStringTool(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case BOW:
|
|
|
|
case CARROT_STICK:
|
|
|
|
case FISHING_ROD:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a gold tool.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a stone tool, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isGoldTool(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case GOLD_AXE:
|
|
|
|
case GOLD_HOE:
|
|
|
|
case GOLD_PICKAXE:
|
|
|
|
case GOLD_SPADE:
|
|
|
|
case GOLD_SWORD:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is an iron tool.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is an iron tool, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isIronTool(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case BUCKET:
|
|
|
|
case FLINT_AND_STEEL:
|
|
|
|
case IRON_AXE:
|
|
|
|
case IRON_HOE:
|
|
|
|
case IRON_PICKAXE:
|
|
|
|
case IRON_SPADE:
|
|
|
|
case IRON_SWORD:
|
|
|
|
case SHEARS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a diamond tool.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a diamond tool, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isDiamondTool(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case DIAMOND_AXE:
|
|
|
|
case DIAMOND_HOE:
|
|
|
|
case DIAMOND_PICKAXE:
|
|
|
|
case DIAMOND_SPADE:
|
|
|
|
case DIAMOND_SWORD:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is enchantable.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is enchantable, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isEnchantable(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
|
|
|
case SHEARS:
|
|
|
|
case FISHING_ROD:
|
|
|
|
case CARROT_STICK:
|
|
|
|
case FLINT_AND_STEEL:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2013-09-25 16:42:19 +02:00
|
|
|
return isArmor(item) || isSword(item) || isAxe(item) || isShovel(item) || isPickaxe(item) || isBow(item);
|
2013-05-16 14:13:01 +02:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isSmeltable(ItemStack item) {
|
2014-02-27 16:56:21 +01:00
|
|
|
return item != null && MaterialUtils.isOre(item.getData());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isSmelted(ItemStack item) {
|
2013-06-12 21:56:42 +02:00
|
|
|
if (item == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-31 19:29:06 +01:00
|
|
|
for (Recipe recipe : mcMMO.p.getServer().getRecipesFor(item)) {
|
|
|
|
if (recipe instanceof FurnaceRecipe) {
|
|
|
|
return MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getData());
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-10-31 19:29:06 +01:00
|
|
|
|
|
|
|
return false;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if an item is sharable.
|
|
|
|
*
|
|
|
|
* @param item Item that will get shared
|
|
|
|
* @return True if the item can be shared.
|
|
|
|
*/
|
2013-07-25 20:52:21 +02:00
|
|
|
public static boolean isSharable(ItemStack item) {
|
|
|
|
if (item == null || item.getType() == Material.AIR) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
return isMiningDrop(item) || isWoodcuttingDrop(item) || isMobDrop(item) || isHerbalismDrop(item) || isMiscDrop(item);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks to see if an item is a mining drop.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the item is a mining drop, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isMiningDrop(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case COAL:
|
|
|
|
case COAL_ORE:
|
|
|
|
case DIAMOND:
|
|
|
|
case DIAMOND_ORE:
|
|
|
|
case EMERALD:
|
|
|
|
case EMERALD_ORE:
|
|
|
|
case GOLD_ORE:
|
|
|
|
case IRON_ORE:
|
|
|
|
case LAPIS_ORE:
|
2013-05-16 14:13:01 +02:00
|
|
|
case REDSTONE_ORE: // Should we also have Glowing Redstone Ore here?
|
2013-03-01 06:52:01 +01:00
|
|
|
case REDSTONE:
|
2013-05-16 14:13:01 +02:00
|
|
|
case GLOWSTONE_DUST: // Should we also have Glowstone here?
|
|
|
|
case QUARTZ:
|
|
|
|
case QUARTZ_ORE:
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case INK_SACK:
|
2013-09-05 20:55:08 +02:00
|
|
|
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 16:03:34 +02:00
|
|
|
/**
|
|
|
|
* Checks to see if an item is a herbalism drop.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-04-17 16:03:34 +02:00
|
|
|
* @return true if the item is a herbalism drop, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isHerbalismDrop(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case WHEAT:
|
|
|
|
case SEEDS:
|
2013-03-28 12:46:22 +01:00
|
|
|
case CARROT_ITEM:
|
2016-03-11 15:20:23 +01:00
|
|
|
case CHORUS_FRUIT:
|
|
|
|
case CHORUS_FLOWER:
|
2013-03-28 12:46:22 +01:00
|
|
|
case POTATO_ITEM:
|
2016-06-26 23:14:19 +02:00
|
|
|
case BEETROOT:
|
|
|
|
case BEETROOT_SEEDS:
|
2013-03-01 06:52:01 +01:00
|
|
|
case NETHER_WARTS:
|
|
|
|
case BROWN_MUSHROOM:
|
|
|
|
case RED_MUSHROOM:
|
|
|
|
case RED_ROSE:
|
|
|
|
case YELLOW_FLOWER:
|
|
|
|
case CACTUS:
|
|
|
|
case SUGAR_CANE:
|
|
|
|
case MELON:
|
2013-04-20 16:11:07 +02:00
|
|
|
case MELON_SEEDS:
|
2013-03-01 06:52:01 +01:00
|
|
|
case PUMPKIN:
|
2013-04-20 16:11:07 +02:00
|
|
|
case PUMPKIN_SEEDS:
|
2013-03-01 06:52:01 +01:00
|
|
|
case WATER_LILY:
|
|
|
|
case VINE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case LONG_GRASS:
|
|
|
|
case DOUBLE_PLANT:
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case INK_SACK:
|
2013-09-05 20:55:08 +02:00
|
|
|
return ((Dye) item.getData()).getColor() == DyeColor.BROWN;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 16:03:34 +02:00
|
|
|
/**
|
|
|
|
* Checks to see if an item is a mob drop.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-04-17 16:03:34 +02:00
|
|
|
* @return true if the item is a mob drop, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isMobDrop(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case STRING:
|
|
|
|
case FEATHER:
|
|
|
|
case RAW_CHICKEN:
|
|
|
|
case COOKED_CHICKEN:
|
|
|
|
case LEATHER:
|
|
|
|
case RAW_BEEF:
|
|
|
|
case COOKED_BEEF:
|
|
|
|
case PORK:
|
|
|
|
case GRILLED_PORK:
|
|
|
|
case WOOL:
|
|
|
|
case IRON_INGOT:
|
|
|
|
case SNOW_BALL:
|
|
|
|
case BLAZE_ROD:
|
|
|
|
case SPIDER_EYE:
|
|
|
|
case SULPHUR:
|
|
|
|
case ENDER_PEARL:
|
|
|
|
case GHAST_TEAR:
|
|
|
|
case MAGMA_CREAM:
|
|
|
|
case BONE:
|
|
|
|
case ARROW:
|
|
|
|
case SLIME_BALL:
|
|
|
|
case NETHER_STAR:
|
|
|
|
case ROTTEN_FLESH:
|
|
|
|
case GOLD_NUGGET:
|
|
|
|
case EGG:
|
|
|
|
return true;
|
|
|
|
|
2013-12-02 18:08:12 +01:00
|
|
|
case COAL: // Not sure we should include this, as it will also trigger when mining
|
|
|
|
return (((Coal) item.getData()).getType() == CoalType.COAL);
|
|
|
|
|
|
|
|
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
|
|
|
|
return (item.getData().getData() == 0x0);
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 16:03:34 +02:00
|
|
|
/**
|
|
|
|
* Checks to see if an item is a woodcutting drop.
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-04-17 16:03:34 +02:00
|
|
|
* @return true if the item is a woodcutting drop, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isWoodcuttingDrop(ItemStack item) {
|
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case LOG:
|
2013-12-02 18:08:12 +01:00
|
|
|
case LOG_2:
|
2013-03-01 06:52:01 +01:00
|
|
|
case LEAVES:
|
2013-12-02 18:08:12 +01:00
|
|
|
case LEAVES_2:
|
2013-03-01 06:52:01 +01:00
|
|
|
case SAPLING:
|
|
|
|
case APPLE:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-03-08 21:46:05 +01:00
|
|
|
|
2013-04-17 16:03:34 +02:00
|
|
|
/**
|
|
|
|
* Checks to see if an item is a miscellaneous drop. These items are read from the config file
|
|
|
|
*
|
2013-05-16 14:13:01 +02:00
|
|
|
* @param item Item to check
|
2013-04-17 16:03:34 +02:00
|
|
|
* @return true if the item is a miscellaneous drop, false otherwise
|
|
|
|
*/
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isMiscDrop(ItemStack item) {
|
|
|
|
return ItemWeightConfig.getInstance().getMiscItems().contains(item.getType());
|
2013-04-17 16:03:34 +02:00
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isMcMMOItem(ItemStack item) {
|
|
|
|
if (!item.hasItemMeta()) {
|
2013-03-09 04:20:26 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
|
|
|
return itemMeta.hasLore() && itemMeta.getLore().contains("mcMMO Item");
|
2013-03-08 21:46:05 +01:00
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isChimaeraWing(ItemStack item) {
|
|
|
|
if (!isMcMMOItem(item)) {
|
2013-03-08 21:46:05 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
2013-05-18 22:41:42 +02:00
|
|
|
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
|
2013-03-08 21:46:05 +01:00
|
|
|
}
|
2014-12-22 16:58:22 +01:00
|
|
|
|
|
|
|
public static boolean isFluxPickaxe(ItemStack item) {
|
|
|
|
if (!isMcMMOItem(item)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
|
|
|
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.FluxPickaxe.Name"));
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|