boolean itemsOnly = args.hasFlag('i');
try {
int id = Integer.parseInt(query);
ItemType type = ItemType.fromID(id);
if (type != null) {
actor.print("#" + type.getID() + " (" + type.getName() + ")");
} else {
actor.printError("No item found by ID " + id);
}
return;
} catch (NumberFormatException ignored) {
}
if (query.length() <= 2) {
actor.printError("Enter a longer search string (len > 2).");
return;
}
if (!blocksOnly && !itemsOnly) {
actor.print("Searching for: " + query);
} else if (blocksOnly && itemsOnly) {
actor.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
return;
} else if (blocksOnly) {
actor.print("Searching for blocks: " + query);
} else {
actor.print("Searching for items: " + query);
}
int found = 0;
for (ItemType type : ItemType.values()) {
if (found >= 15) {
actor.print("Too many results!");
break;
}
if (blocksOnly && type.getID() > 255) {
continue;
}
if (itemsOnly && type.getID() <= 255) {
continue;
}
for (String alias : type.getAliases()) {
if (alias.contains(query)) {
actor.print("#" + type.getID() + " (" + type.getName() + ")");
++found;
break;
}
}
}