Added isUnarmed Method

Checks if the player is not holding a tool, as opposed to checking if
the player is holding air. This means that attacking with something such
as a dirt block would count as unarmed.
This commit is contained in:
mjkaufer
2014-12-29 00:12:46 -05:00
committed by TfT_02
parent af7ff3df58
commit 9426f44cdd
6 changed files with 23 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ import org.bukkit.material.Dye;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
public final class ItemUtils {
@@ -146,6 +147,20 @@ public final class ItemUtils {
}
}
/**
* 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;
}
/**
* Checks if the item is a helmet.
*