<commit_before>package com.countrygamer.racesforminecraft.common.lib;

import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import java.util.HashSet;

/**
 * @author CountryGamer
 */
public class NameParser {

	public static String getName(ItemStack itemStack) {
		String name;

		Item item = itemStack.getItem();
		// is item
		if (Block.getBlockFromItem(item) == Blocks.air) {
			name = GameData.getItemRegistry().getNameForObject(item);
		}
		// is block
		else {
			name = GameData.getBlockRegistry()
					.getNameForObject(Block.getBlockFromItem(item));
		}

		return name;
	}

	public static ItemStack getItemStack(String name) {
		int endNameIndex = name.length();
		int metadata = 0;
		if (name.matches("(.*):(.*):(.*)")) {
			endNameIndex = name.lastIndexOf(':');
			metadata = Integer.parseInt(name.substring(endNameIndex + 1, name.length()));
		}
		String modid = name.substring(0, name.indexOf(':'));
		String itemName = name.substring(name.indexOf(':') + 1, endNameIndex);
		ItemStack itemStack = GameRegistry.findItemStack(modid, itemName, 1);
		if (itemStack != null)
			itemStack.setItemDamage(metadata);
		return itemStack;
	}

	public static boolean isInList(ItemStack itemStack, HashSet<String> list) {
		String itemStack_nonMetadata, itemStack_fullName;

		itemStack_nonMetadata = NameParser.getName(itemStack);
		itemStack_fullName = itemStack_nonMetadata + ":" + itemStack.getItemDamage();

		boolean item_is_in_list = list.contains(itemStack_fullName);
		if (!item_is_in_list) {
			item_is_in_list = list.contains(itemStack_nonMetadata);
		}

		return item_is_in_list;
	}
<commit_msg>Added ability for empty metadata's to represent ANY metadata<commit_after>package com.countrygamer.racesforminecraft.common.lib;

import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import java.util.HashSet;

/**
 * @author CountryGamer
 */
public class NameParser {

	public static String getName(ItemStack itemStack) {
		String name;

		Item item = itemStack.getItem();
		// is item
		if (Block.getBlockFromItem(item) == Blocks.air) {
			name = GameData.getItemRegistry().getNameForObject(item);
		}
		// is block
		else {
			name = GameData.getBlockRegistry()
					.getNameForObject(Block.getBlockFromItem(item));
		}

		return name;
	}

	public static ItemStack getItemStack(String name) {
		int endNameIndex = name.length();
		int metadata = OreDictionary.WILDCARD_VALUE;
		if (name.matches("(.*):(.*):(.*)")) {
			endNameIndex = name.lastIndexOf(':');
			metadata = Integer.parseInt(name.substring(endNameIndex + 1, name.length()));
		}
		String modid = name.substring(0, name.indexOf(':'));
		String itemName = name.substring(name.indexOf(':') + 1, endNameIndex);
		ItemStack itemStack = GameRegistry.findItemStack(modid, itemName, 1);
		if (itemStack != null)
			itemStack.setItemDamage(metadata);
		return itemStack;
	}

	public static boolean isInList(ItemStack itemStack, HashSet<String> list) {
		String itemStack_nonMetadata, itemStack_fullName;

		itemStack_nonMetadata = NameParser.getName(itemStack);
		itemStack_fullName = itemStack_nonMetadata + ":" + itemStack.getItemDamage();

		boolean item_is_in_list = list.contains(itemStack_fullName);
		if (!item_is_in_list) {
			item_is_in_list = list.contains(itemStack_nonMetadata);
		}

		return item_is_in_list;
	}

{'fraction_non_alphanumeric': 0.12543930792105976, 'fraction_numerical': 0.0024330900243309003, 'mean_word_length': 4.958132045088567, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5631157', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1213, 'n_words': 228}