Skip to content

Instantly share code, notes, and snippets.

@alalwww
Created November 1, 2012 16:41
Show Gist options
  • Save alalwww/3994923 to your computer and use it in GitHub Desktop.
Save alalwww/3994923 to your computer and use it in GitHub Desktop.
ItemFinder
public static <I extends Item> I findItemByName(String targetName)
{
if (!targetName.startsWith("item."))
{
targetName = "item." + targetName;
}
for (Item item : Item.itemsList)
{
if (item == null || item.getItemName() == null)
{
continue;
}
String name = item.getItemName();
if (name.hashCode() == targetName.hashCode() && name.equals(targetName))
{
return (I) item;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment