use of com.laytonsmith.core.exceptions.CRE.CREFormatException in project CommandHelper by EngineHub.
the class Static method ParseItemNotation.
/**
* Returns an item stack from the given item notation. Defaulting to the specified qty, this will throw an exception
* if the notation is invalid.
*
* @param functionName
* @param notation
* @param qty
* @throws CREFormatException If the notation is invalid.
* @return
*/
@Deprecated
public static MCItemStack ParseItemNotation(String functionName, String notation, int qty, Target t) {
int type;
short data = 0;
try {
int separatorIndex = notation.indexOf(':');
if (separatorIndex != -1) {
type = Integer.parseInt(notation.substring(0, separatorIndex));
data = (short) Integer.parseInt(notation.substring(separatorIndex + 1));
} else {
type = Integer.parseInt(notation);
}
} catch (NumberFormatException e) {
throw new CREFormatException("Invalid item notation: " + notation, t);
}
return StaticLayer.GetItemStack(type, data, qty);
}
Aggregations