2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.util;
|
|
|
|
|
2020-08-19 03:41:31 +02:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2018-07-24 04:13:57 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
|
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-03-08 21:46:05 +01:00
|
|
|
import org.bukkit.ChatColor;
|
2013-07-25 20:52:21 +02:00
|
|
|
import org.bukkit.Material;
|
2020-08-19 03:41:31 +02:00
|
|
|
import org.bukkit.enchantments.Enchantment;
|
2019-07-07 10:55:23 +02:00
|
|
|
import org.bukkit.entity.Player;
|
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;
|
2020-08-19 05:24:45 +02:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2020-08-19 03:41:31 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isBow(item.getType().getKey().getKey());
|
2013-09-25 16:42:19 +02:00
|
|
|
}
|
|
|
|
|
2019-07-07 10:55:23 +02:00
|
|
|
public static boolean hasItemInEitherHand(Player player, Material material) {
|
|
|
|
return player.getInventory().getItemInMainHand().getType() == material || player.getInventory().getItemInOffHand().getType() == material;
|
|
|
|
}
|
|
|
|
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isSword(item.getType().getKey().getKey());
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isHoe(item.getType().getKey().getKey());
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isShovel(item.getType().getKey().getKey());
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isAxe(item.getType().getKey().getKey());
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isPickAxe(item.getType().getKey().getKey());
|
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 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isArmor(item.getType());
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isLeatherArmor(item.getType());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isGoldArmor(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isIronArmor(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isDiamondArmor(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 02:52:02 +01:00
|
|
|
public static boolean isNetheriteArmor(ItemStack itemStack) {
|
|
|
|
return mcMMO.getMaterialMapStore().isNetheriteArmor(itemStack.getType().getKey().getKey());
|
2020-02-29 01:44:37 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 02:52:02 +01:00
|
|
|
public static boolean isNetheriteTool(ItemStack itemStack) {
|
|
|
|
return mcMMO.getMaterialMapStore().isNetheriteTool(itemStack.getType().getKey().getKey());
|
2020-02-29 01:44:37 +01:00
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isChainmailArmor(item.getType().getKey().getKey());
|
2013-05-16 14:13:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isTool(item.getType().getKey().getKey());
|
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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isStoneTool(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isWoodTool(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isStringTool(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isGoldTool(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isIronTool(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isDiamondTool(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2020-03-02 23:52:51 +01:00
|
|
|
return mcMMO.getMaterialMapStore().isEnchantable(item.getType().getKey().getKey());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-05-16 14:13:01 +02:00
|
|
|
public static boolean isSmeltable(ItemStack item) {
|
2018-10-10 03:56:47 +02:00
|
|
|
return item != null && item.getType().isBlock() && MaterialUtils.isOre(item.getType());
|
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)) {
|
2019-01-26 02:14:10 +01:00
|
|
|
if (recipe instanceof FurnaceRecipe
|
|
|
|
&& ((FurnaceRecipe) recipe).getInput().getType().isBlock()
|
|
|
|
&& MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getType())) {
|
2017-09-01 06:32:11 +02:00
|
|
|
return true;
|
2013-10-31 19:29:06 +01:00
|
|
|
}
|
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) {
|
2019-04-23 08:54:02 +02:00
|
|
|
//TODO: 1.14 This needs to be updated
|
2013-05-16 14:13:01 +02:00
|
|
|
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:
|
2018-07-24 04:13:57 +02:00
|
|
|
case NETHER_QUARTZ_ORE:
|
|
|
|
case LAPIS_LAZULI:
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
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) {
|
2019-04-23 08:54:02 +02:00
|
|
|
//TODO: 1.14 This needs to be updated
|
2013-05-16 14:13:01 +02:00
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case WHEAT:
|
2018-07-24 04:13:57 +02:00
|
|
|
case WHEAT_SEEDS:
|
|
|
|
case CARROT:
|
2016-03-11 15:20:23 +01:00
|
|
|
case CHORUS_FRUIT:
|
|
|
|
case CHORUS_FLOWER:
|
2018-07-24 04:13:57 +02:00
|
|
|
case POTATO:
|
2016-06-26 23:14:19 +02:00
|
|
|
case BEETROOT:
|
|
|
|
case BEETROOT_SEEDS:
|
2018-07-24 04:13:57 +02:00
|
|
|
case NETHER_WART:
|
2013-03-01 06:52:01 +01:00
|
|
|
case BROWN_MUSHROOM:
|
|
|
|
case RED_MUSHROOM:
|
2019-04-23 08:54:02 +02:00
|
|
|
case ROSE_BUSH:
|
|
|
|
case DANDELION:
|
2013-03-01 06:52:01 +01:00
|
|
|
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:
|
2018-07-24 04:13:57 +02:00
|
|
|
case LILY_PAD:
|
2013-03-01 06:52:01 +01:00
|
|
|
case VINE:
|
2018-07-24 04:13:57 +02:00
|
|
|
case TALL_GRASS:
|
|
|
|
case COCOA_BEANS:
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
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) {
|
2019-04-23 08:54:02 +02:00
|
|
|
//TODO: 1.14 This needs to be updated
|
2013-05-16 14:13:01 +02:00
|
|
|
switch (item.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case STRING:
|
|
|
|
case FEATHER:
|
2018-07-24 04:13:57 +02:00
|
|
|
case CHICKEN:
|
2013-03-01 06:52:01 +01:00
|
|
|
case COOKED_CHICKEN:
|
|
|
|
case LEATHER:
|
2018-07-24 04:13:57 +02:00
|
|
|
case BEEF:
|
2013-03-01 06:52:01 +01:00
|
|
|
case COOKED_BEEF:
|
2018-07-24 04:13:57 +02:00
|
|
|
case PORKCHOP:
|
|
|
|
case COOKED_PORKCHOP:
|
|
|
|
case WHITE_WOOL:
|
|
|
|
case BLACK_WOOL:
|
|
|
|
case BLUE_WOOL:
|
|
|
|
case BROWN_WOOL:
|
|
|
|
case CYAN_WOOL:
|
|
|
|
case GRAY_WOOL:
|
|
|
|
case GREEN_WOOL:
|
|
|
|
case LIGHT_BLUE_WOOL:
|
|
|
|
case LIGHT_GRAY_WOOL:
|
|
|
|
case LIME_WOOL:
|
|
|
|
case MAGENTA_WOOL:
|
|
|
|
case ORANGE_WOOL:
|
|
|
|
case PINK_WOOL:
|
|
|
|
case PURPLE_WOOL:
|
|
|
|
case RED_WOOL:
|
|
|
|
case YELLOW_WOOL:
|
2013-03-01 06:52:01 +01:00
|
|
|
case IRON_INGOT:
|
2018-07-24 04:13:57 +02:00
|
|
|
case SNOWBALL:
|
2013-03-01 06:52:01 +01:00
|
|
|
case BLAZE_ROD:
|
|
|
|
case SPIDER_EYE:
|
2018-07-24 04:13:57 +02:00
|
|
|
case GUNPOWDER:
|
2013-03-01 06:52:01 +01:00
|
|
|
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:
|
2019-04-23 08:54:02 +02:00
|
|
|
case ROSE_BUSH:
|
2018-07-24 04:13:57 +02:00
|
|
|
case COAL:
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
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()) {
|
2018-07-24 04:13:57 +02:00
|
|
|
case ACACIA_LOG:
|
|
|
|
case BIRCH_LOG:
|
|
|
|
case DARK_OAK_LOG:
|
|
|
|
case JUNGLE_LOG:
|
|
|
|
case OAK_LOG:
|
|
|
|
case SPRUCE_LOG:
|
|
|
|
case STRIPPED_ACACIA_LOG:
|
|
|
|
case STRIPPED_BIRCH_LOG:
|
|
|
|
case STRIPPED_DARK_OAK_LOG:
|
|
|
|
case STRIPPED_JUNGLE_LOG:
|
|
|
|
case STRIPPED_OAK_LOG:
|
|
|
|
case STRIPPED_SPRUCE_LOG:
|
|
|
|
case ACACIA_SAPLING:
|
|
|
|
case SPRUCE_SAPLING:
|
|
|
|
case BIRCH_SAPLING:
|
|
|
|
case DARK_OAK_SAPLING:
|
|
|
|
case JUNGLE_SAPLING:
|
|
|
|
case OAK_SAPLING:
|
|
|
|
case ACACIA_LEAVES:
|
|
|
|
case BIRCH_LEAVES:
|
|
|
|
case DARK_OAK_LEAVES:
|
|
|
|
case JUNGLE_LEAVES:
|
|
|
|
case OAK_LEAVES:
|
|
|
|
case SPRUCE_LEAVES:
|
2013-03-01 06:52:01 +01:00
|
|
|
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();
|
2020-07-13 21:31:30 +02:00
|
|
|
|
|
|
|
if(itemMeta == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return itemMeta.getLore() != null
|
|
|
|
&& 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();
|
2020-07-13 21:31:30 +02:00
|
|
|
|
|
|
|
if(itemMeta == null)
|
|
|
|
return false;
|
|
|
|
|
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
|
|
|
}
|
2020-08-19 03:41:31 +02:00
|
|
|
|
2020-08-19 05:24:45 +02:00
|
|
|
public static void addAbilityLore(@NotNull ItemStack itemStack) {
|
2020-08-19 03:41:31 +02:00
|
|
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
|
|
|
List<String> itemLore = new ArrayList<>();
|
|
|
|
|
|
|
|
if(itemMeta == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (itemMeta.hasLore()) {
|
|
|
|
itemLore = itemMeta.getLore();
|
|
|
|
}
|
|
|
|
|
|
|
|
itemLore.add("mcMMO Ability Tool");
|
|
|
|
|
|
|
|
itemMeta.setLore(itemLore);
|
|
|
|
itemStack.setItemMeta(itemMeta);
|
|
|
|
}
|
|
|
|
|
2020-08-19 05:24:45 +02:00
|
|
|
public static void removeAbilityLore(@NotNull ItemStack itemStack) {
|
2020-08-19 03:41:31 +02:00
|
|
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
|
|
|
|
|
|
|
if(itemMeta == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (itemMeta.hasLore()) {
|
|
|
|
List<String> itemLore = itemMeta.getLore();
|
|
|
|
|
|
|
|
if(itemLore == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (itemLore.remove("mcMMO Ability Tool")) {
|
|
|
|
itemMeta.setLore(itemLore);
|
|
|
|
itemStack.setItemMeta(itemMeta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-19 05:24:45 +02:00
|
|
|
public static void addDigSpeedToItem(@NotNull ItemStack itemStack, int existingEnchantLevel) {
|
2020-08-19 03:41:31 +02:00
|
|
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
2020-08-19 04:47:15 +02:00
|
|
|
|
|
|
|
if(itemMeta == null)
|
|
|
|
return;
|
|
|
|
|
2020-08-19 03:41:31 +02:00
|
|
|
itemMeta.addEnchant(Enchantment.DIG_SPEED, existingEnchantLevel + AdvancedConfig.getInstance().getEnchantBuff(), true);
|
2020-08-19 04:47:15 +02:00
|
|
|
itemStack.setItemMeta(itemMeta);
|
2020-08-19 03:41:31 +02:00
|
|
|
}
|
2020-08-19 05:24:45 +02:00
|
|
|
|
|
|
|
public static boolean canBeSuperAbilityDigBoosted(@NotNull ItemStack itemStack) {
|
|
|
|
return isShovel(itemStack) || isPickaxe(itemStack);
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|