<commit_before>package musician101.itembank.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import musician101.itembank.ItemBank;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

/**
 * @author Musician101
 */
public class ItemTranslator 
{
	/** HashMap storing all of the aliases and their respective ItemStacks.*/
	private final Map<String, ItemStack> items = new HashMap<String, ItemStack>();
	
	/**
	 * Loads up the translator for the plugin.
	 * 
	 * @param plugin References the plugin's main class.
	 * @param values List of values used to determine the aliases and their IDs.
	 */
	public ItemTranslator(ItemBank plugin, Iterable<String[]> values)
	{
		for (String[] s : values)
		{
			if (!s[0].startsWith("#"))
			{
				if (s.length < 1) continue;
				Material material;
				ItemStack item;
				String alias = s[0].toLowerCase();
				try
				{
					material = Material.valueOf(s[1].toUpperCase());
					item = new ItemStack(material);
				}
				catch (IllegalArgumentException e)
				{
					plugin.getLogger().warning("Error with Material: " + s[1].toUpperCase());
					continue;
				}
				
				try
				{
					short data = Short.valueOf(s[2]);
					item.setDurability(data);
				}
				catch (NumberFormatException e)
				{
					plugin.getLogger().info("Error with data: " + s[2]);
					continue;
				}
				
				synchronized (items)
				{
					items.put(alias, item);
				}
			}
		}
	}
	
	/**
	 * Retrieves an ItemStack based an a given alias.
	 * 
	 * @param alias The alias used to match the ItemStack.
	 * @return item
	 */
	public ItemStack getItemStackFromAlias(String alias)
	{
		boolean found = false;
		String data = null;
		if (alias.contains(":"))
		{
			String[] datas = alias.split(":");
			data = (datas.length > 1) ? datas[1] : "";
			alias = datas[0];
		}
		
		if (items.keySet().contains(alias.toLowerCase())) found = true;
		<commit_msg>Fix ItemTranslator failing to recognize items if there's spaces.<commit_after>package musician101.itembank.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import musician101.itembank.ItemBank;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

/**
 * @author Musician101
 */
public class ItemTranslator 
{
	/** HashMap storing all of the aliases and their respective ItemStacks.*/
	private final Map<String, ItemStack> items = new HashMap<String, ItemStack>();
	
	/**
	 * Loads up the translator for the plugin.
	 * 
	 * @param plugin References the plugin's main class.
	 * @param values List of values used to determine the aliases and their IDs.
	 */
	public ItemTranslator(ItemBank plugin, Iterable<String[]> values)
	{
		for (String[] s : values)
		{
			if (!s[0].startsWith("#"))
			{
				if (s.length < 1) continue;
				Material material;
				ItemStack item;
				String alias = s[0].toLowerCase().replace(" ", "");
				try
				{
					material = Material.valueOf(s[1].toUpperCase().replace(" ", ""));
					item = new ItemStack(material);
				}
				catch (IllegalArgumentException e)
				{
					plugin.getLogger().warning("Error with Material: " + s[1].toUpperCase().replace(" ", ""));
					continue;
				}
				
				try
				{
					short data = Short.valueOf(s[2].replace(" ", ""));
					item.setDurability(data);
				}
				catch (NumberFormatException e)
				{
					plugin.getLogger().info("Error with data: " + s[2].replace(" ", ""));
					continue;
				}
				
				synchronized (items)
				{
					items.put(alias, item);
				}
			}
		}
	}
	
	/**
	 * Retrieves an ItemStack based an a given alias.
	 * 
	 * @param alias The alias used to match the ItemStack.
	 * @return item
	 */
	public ItemStack getItemStackFromAlias(String alias)
	{
		boolean found = false;
		String data = null;
		if (alias.contains(":"))
		{
			String[] datas = alias.split(":");
			data = (datas.length > 1) ? datas[1] : "";
			alias = datas[0];
		}
		
		if (items.keySet().contains(alias.toLowerCase())) found = true;
		
{'fraction_non_alphanumeric': 0.13781094527363183, 'fraction_numerical': 0.00945273631840796, 'mean_word_length': 3.0493454179254784, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, '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': '4146805', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1262, 'n_words': 334}